diff mbox series

[RFC,1/2] python: be more selective in hiding mypy subclassing warning

Message ID 20250224191152.2123003-2-berrange@redhat.com (mailing list archive)
State New
Headers show
Series python: integrate linter tests natively with meson | expand

Commit Message

Daniel P. Berrangé Feb. 24, 2025, 7:11 p.m. UTC
Use an annotation inline to the file instead of in setup.cfg

This has the added advantage that the mypy checks now pass when
using 'mypy /path/to/python/qemu' as well as 'mypy -p qemu'.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 python/qemu/qmp/qmp_tui.py    | 12 ++++++------
 python/qemu/utils/qom_fuse.py |  2 +-
 python/setup.cfg              |  8 --------
 3 files changed, 7 insertions(+), 15 deletions(-)
diff mbox series

Patch

diff --git a/python/qemu/qmp/qmp_tui.py b/python/qemu/qmp/qmp_tui.py
index 2d9ebbd20b..8720d70e60 100644
--- a/python/qemu/qmp/qmp_tui.py
+++ b/python/qemu/qmp/qmp_tui.py
@@ -401,7 +401,7 @@  def run(self, debug: bool = False) -> None:
             raise err
 
 
-class StatusBar(urwid.Text):
+class StatusBar(urwid.Text):  # type: ignore
     """
     A simple statusbar modelled using the Text widget. The status can be
     set using the set_text function. All text set is aligned to right.
@@ -412,7 +412,7 @@  def __init__(self, text: str = ''):
         super().__init__(text, align='right')
 
 
-class Editor(urwid_readline.ReadlineEdit):
+class Editor(urwid_readline.ReadlineEdit):  # type: ignore
     """
     A simple editor modelled using the urwid_readline.ReadlineEdit widget.
     Mimcs GNU readline shortcuts and provides history support.
@@ -485,7 +485,7 @@  def keypress(self, size: Tuple[int, int], key: str) -> Optional[str]:
         return None
 
 
-class EditorWidget(urwid.Filler):
+class EditorWidget(urwid.Filler):  # type: ignore
     """
     Wrapper around the editor widget.
 
@@ -498,7 +498,7 @@  def __init__(self, parent: App) -> None:
         super().__init__(Editor(parent), valign='top')
 
 
-class HistoryBox(urwid.ListBox):
+class HistoryBox(urwid.ListBox):  # type: ignore
     """
     This widget is modelled using the ListBox widget, contains the list of
     all messages both QMP messages and log messages to be shown in the TUI.
@@ -535,7 +535,7 @@  def mouse_event(self, size: Tuple[int, int], _event: str, button: float,
             super().keypress(size, 'down')
 
 
-class HistoryWindow(urwid.Frame):
+class HistoryWindow(urwid.Frame):  # type: ignore
     """
     This window composes the HistoryBox and EditorWidget in a horizontal split.
     By default the first focus is given to the history box.
@@ -572,7 +572,7 @@  def cb_add_to_history(self, msg: str, level: Optional[str] = None) -> None:
         self.history.add_to_history(formatted)
 
 
-class Window(urwid.Frame):
+class Window(urwid.Frame):  # type: ignore
     """
     This window is the top most widget of the TUI and will contain other
     windows. Each child of this widget is responsible for displaying a specific
diff --git a/python/qemu/utils/qom_fuse.py b/python/qemu/utils/qom_fuse.py
index cf7e344bd5..0a1e02af87 100644
--- a/python/qemu/utils/qom_fuse.py
+++ b/python/qemu/utils/qom_fuse.py
@@ -56,7 +56,7 @@ 
 fuse.fuse_python_api = (0, 2)
 
 
-class QOMFuse(QOMCommand, Operations):
+class QOMFuse(QOMCommand, Operations):  # type: ignore
     """
     QOMFuse implements both fuse.Operations and QOMCommand.
 
diff --git a/python/setup.cfg b/python/setup.cfg
index cf5af7e664..8dcd4c946e 100644
--- a/python/setup.cfg
+++ b/python/setup.cfg
@@ -83,14 +83,6 @@  warn_unused_configs = True
 namespace_packages = True
 warn_unused_ignores = False
 
-[mypy-qemu.utils.qom_fuse]
-# fusepy has no type stubs:
-allow_subclassing_any = True
-
-[mypy-qemu.qmp.qmp_tui]
-# urwid and urwid_readline have no type stubs:
-allow_subclassing_any = True
-
 # The following missing import directives are because these libraries do not
 # provide type stubs. Allow them on an as-needed basis for mypy.
 [mypy-fuse]