From: Tim Pambor <[email protected]> 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 <[email protected]> Message-ID: <[email protected]> Reviewed-by: Kevin Wolf <[email protected]> Signed-off-by: Kevin Wolf <[email protected]> --- 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 cc36867719d..729680da4aa 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: -- 2.56.0
