tests/qemu-iotests/testrunner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mypy 2.4.0 infers the unannotated class attribute "shared_self = None"
as having type "None" and rejects the later assignment of a TestRunner
instance in run_tests_pool():
testrunner.py:126: error: Incompatible types in assignment
(expression has type "TestRunner", variable has type "None")
Earlier mypy versions treated the attribute as a partial type and
accepted the assignment. Give the attribute an explicit
Optional['TestRunner'] annotation so both old and new mypy agree.
Fixes tests/linters.py::TestLinters::test_mypy_iotests with mypy >= 2.4.
Signed-off-by: Tim Pambor <timpambor@gmail.com>
---
CI run with mypy 2.4: https://gitlab.com/tpambor/qemu/-/pipelines/2905639361
---
tests/qemu-iotests/testrunner.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/qemu-iotests/testrunner.py b/tests/qemu-iotests/testrunner.py
index cc36867719..729680da4a 100644
--- a/tests/qemu-iotests/testrunner.py
+++ b/tests/qemu-iotests/testrunner.py
@@ -108,7 +108,7 @@ def __init__(self, status: str, description: str = '',
class TestRunner(contextlib.AbstractContextManager['TestRunner']):
- shared_self = None
+ shared_self: Optional['TestRunner'] = None
@staticmethod
def proc_run_test(test: str, test_field_width: int) -> TestResult:
---
base-commit: f7ada39edacaa5c26b30e98b94017b0b2ccbcf94
change-id: 20261002-mypy-2-4-2544da3f4e17
Best regards,
--
Tim Pambor <timpambor@gmail.com>
Am 02.10.2026 um 09:04 hat Tim Pambor geschrieben: > mypy 2.4.0 infers the unannotated class attribute "shared_self = None" > as having type "None" and rejects the later assignment of a TestRunner > instance in run_tests_pool(): > > testrunner.py:126: error: Incompatible types in assignment > (expression has type "TestRunner", variable has type "None") > > Earlier mypy versions treated the attribute as a partial type and > accepted the assignment. Give the attribute an explicit > Optional['TestRunner'] annotation so both old and new mypy agree. > > Fixes tests/linters.py::TestLinters::test_mypy_iotests with mypy >= 2.4. > > Signed-off-by: Tim Pambor <timpambor@gmail.com> > --- > CI run with mypy 2.4: https://gitlab.com/tpambor/qemu/-/pipelines/2905639361 Thanks, applied to the block branch. Kevin
© 2016 - 2026 Red Hat, Inc.