Source: python-qemu-qmp
Version: 0.0.6-1
Severity: grave
Control: affects -1 + src:urwid
Control: tags -1 + patch
X-Debbugs-CC: [email protected]
Dear Debian python-qemu-qmp maintainer,
Your package, python-qemu-qmp, fails to build from source with urwid/4.1.3-1
in Debian Unstable. Its autopkgtest would also fail.
There is no functionality regression; the issue comes from the linter tests:
|
FAILED tests/linters.py::TestLinters::test_mypy
FAILED tests/linters.py::TestLinters::test_pylint
|
There are independent causes, both in qemu/qmp/qmp_tui.py (which the
Debian package does not even ship as a command, since debian/rules
removes usr/bin/qmp-tui):
1. urwid 4.1 started shipping a py.typed marker. mypy therefore
stops treating urwid as an untyped library, the existing
"ignore_missing_imports = True" for urwid has no effect any more,
and qmp_tui.py fails with nine errors such as:
qmp_tui.py:538: error: Argument 1 of "mouse_event" is incompatible
with supertype "urwid.widget.widget.Widget" [override]
qmp_tui.py:498: error: Missing type arguments for generic type
"Filler" [type-arg]
qmp_tui.py:400: error: Argument "unhandled_input" to "MainLoop" has
incompatible type "Callable[[str], None]" [arg-type]
2. urwid 4 deepened its widget class hierarchy, so pylint now reports
R0901 too-many-ancestors (8-10 of 7) for the four widget subclasses
in qmp_tui.py.|
The attached patch keeps both linters passing by making mypy treat urwid as untyped again ("follow_imports = skip" for
urwid and urwid.*) and by disabling too-many-ancestors, since the ancestor count comes from urwid rather than from this
code base. With the patch applied, a build in a clean sid chroot (python3-urwid 4.1.3-1, python3-mypy 2.2.0-5, pylint
4.0.8-1) succeeds and the autopkgtest passes with 31 tests. The change is backwards compatible with urwid 3.x and could
be forwarded upstream as is. If you do not have time for this, I am happy to do an NMU with the attached patch with
DELAYED/5. Let me know if you find that necessary. Thanks, Boyuan Yang|
--- a/setup.cfg
+++ b/setup.cfg
@@ -96,8 +96,11 @@
# The following missing import directives are because these libraries do not
# provide type stubs. Allow them on an as-needed basis for mypy.
-[mypy-urwid]
+# urwid >= 4.1 ships py.typed, but qmp_tui.py predates those annotations;
+# keep treating it as untyped.
+[mypy-urwid,urwid.*]
ignore_missing_imports = True
+follow_imports = skip
[mypy-urwid_readline]
ignore_missing_imports = True
@@ -120,6 +123,7 @@
too-many-arguments,
too-many-function-args, # mypy handles this with less false positives.
too-many-instance-attributes,
+ too-many-ancestors, # urwid >= 4 widget hierarchy is deeper.
no-member, # mypy also handles this better.
unknown-option-value, # pre and post "too-many-positional-arguments"