aboutsummaryrefslogtreecommitdiff
path: root/tests/qemu-iotests
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2021-10-19 10:49:16 -0400
committerJohn Snow <jsnow@redhat.com>2021-11-01 11:54:59 -0400
commit558dbe9935445af6ab20e18b3664ba6c43eb2311 (patch)
tree2c3d029f0ac0d95c65aaef1100261affc1ef965c /tests/qemu-iotests
parenta4294435309d8429e8ee89908b5d7cebf6a648df (diff)
iotests/linters: Add workaround for mypy bug #9852
This one is insidious: if you write an import as "from {namespace} import {subpackage}" as mirror-top-perms (now) does, mypy will fail on every-other invocation *if* the package being imported is a typed, installed, namespace-scoped package. Upsettingly, that's exactly what 'qemu.[aqmp|qmp|machine]' et al are in the context of Python CI tests. Now, I could just edit mirror-top-perms to avoid this invocation, but since I tripped on a landmine, I might as well head it off at the pass and make sure nobody else trips on that same landmine. It seems to have something to do with the order in which files are checked as well, meaning the random order in which set(os.listdir()) produces the list of files to test will cause problems intermittently and not just strictly "every other run". This will be fixed in mypy >= 0.920, which is not released yet. The workaround for now is to disable incremental checking, which avoids the issue. Note: This workaround is not applied when running iotest 297 directly, because the bug does not surface there! Given the nature of CI jobs not starting with any stale cache to begin with, this really only has a half-second impact on manual runs of the Python test suite when executed directly by a developer on their local machine. The workaround may be removed when the Python package requirements can stipulate mypy 0.920 or higher, which can happen as soon as it is released. (Barring any unforseen compatibility issues that 0.920 may bring with it.) See also: https://github.com/python/mypy/issues/11010 https://github.com/python/mypy/issues/9852 Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Message-id: 20211019144918.3159078-14-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
Diffstat (limited to 'tests/qemu-iotests')
-rw-r--r--tests/qemu-iotests/linters.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/tests/qemu-iotests/linters.py b/tests/qemu-iotests/linters.py
index 46c28fdcda..65c4c4e827 100644
--- a/tests/qemu-iotests/linters.py
+++ b/tests/qemu-iotests/linters.py
@@ -93,7 +93,9 @@ def main() -> None:
if sys.argv[1] == '--pylint':
run_linter('pylint', files)
elif sys.argv[1] == '--mypy':
- run_linter('mypy', files)
+ # mypy bug #9852; disable incremental checking as a workaround.
+ args = ['--no-incremental'] + files
+ run_linter('mypy', args)
else:
print(f"Unrecognized argument: '{sys.argv[1]}'", file=sys.stderr)
show_usage()