* [PATCH] iotests: annotate TestRunner.shared_self for mypy 2.4
@ 2026-10-02 7:04 Tim Pambor
2026-10-05 10:23 ` Kevin Wolf
0 siblings, 1 reply; 2+ messages in thread
From: Tim Pambor @ 2026-10-02 7:04 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Hanna Reitz, qemu-block, qemu-trivial, Tim Pambor
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>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iotests: annotate TestRunner.shared_self for mypy 2.4
2026-10-02 7:04 [PATCH] iotests: annotate TestRunner.shared_self for mypy 2.4 Tim Pambor
@ 2026-10-05 10:23 ` Kevin Wolf
0 siblings, 0 replies; 2+ messages in thread
From: Kevin Wolf @ 2026-10-05 10:23 UTC (permalink / raw)
To: Tim Pambor; +Cc: qemu-devel, Hanna Reitz, qemu-block, qemu-trivial
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-05 10:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-02 7:04 [PATCH] iotests: annotate TestRunner.shared_self for mypy 2.4 Tim Pambor
2026-10-05 10:23 ` Kevin Wolf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.