summaryrefslogtreecommitdiff
path: root/tools/testing/kunit/mypy.ini
diff options
context:
space:
mode:
authorDaniel Latypov <dlatypov@google.com>2023-05-01 11:16:10 -0700
committerShuah Khan <skhan@linuxfoundation.org>2023-05-08 08:39:41 -0600
commite30f65c4b3d671115bf2a9d9ef142285387f2aff (patch)
tree2a97aad6f9053be727b69e741865f4b5741c5128 /tools/testing/kunit/mypy.ini
parentac9a78681b921877518763ba0e89202254349d1b (diff)
kunit: tool: undo type subscripts for subprocess.Popen
Writing `subprocess.Popen[str]` requires python 3.9+. kunit.py has an assertion that the python version is 3.7+, so we should try to stay backwards compatible. This conflicts a bit with commit 1da2e6220e11 ("kunit: tool: fix pre-existing `mypy --strict` errors and update run_checks.py"), since mypy complains like so > kunit_kernel.py:95: error: Missing type parameters for generic type "Popen" [type-arg] Note: `mypy --strict --python-version 3.7` does not work. We could annotate each file with comments like `# mypy: disable-error-code="type-arg" but then we might still get nudged to break back-compat in other files. This patch adds a `mypy.ini` file since it seems like the only way to disable specific error codes for all our files. Note: run_checks.py doesn't need to specify `--config_file mypy.ini`, but I think being explicit is better, particularly since most kernel devs won't be familiar with how mypy works. Fixes: 695e26030858 ("kunit: tool: add subscripts for type annotations where appropriate") Reported-by: SeongJae Park <sj@kernel.org> Link: https://lore.kernel.org/linux-kselftest/20230501171520.138753-1-sj@kernel.org Signed-off-by: Daniel Latypov <dlatypov@google.com> Tested-by: SeongJae Park <sj@kernel.org> Reviewed-by: David Gow <davidgow@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'tools/testing/kunit/mypy.ini')
-rw-r--r--tools/testing/kunit/mypy.ini6
1 files changed, 6 insertions, 0 deletions
diff --git a/tools/testing/kunit/mypy.ini b/tools/testing/kunit/mypy.ini
new file mode 100644
index 000000000000..ddd288309efa
--- /dev/null
+++ b/tools/testing/kunit/mypy.ini
@@ -0,0 +1,6 @@
+[mypy]
+strict = True
+
+# E.g. we can't write subprocess.Popen[str] until Python 3.9+.
+# But kunit.py tries to support Python 3.7+, so let's disable it.
+disable_error_code = type-arg