qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] python: first step towards Python 3.12 support
@ 2023-07-05 11:25 Paolo Bonzini
  2023-07-05 11:25 ` [PATCH 1/2] python: work around mypy false positive Paolo Bonzini
  2023-07-05 11:25 ` [PATCH 2/2] python: bump minimum requirements so they are compatible with 3.12 Paolo Bonzini
  0 siblings, 2 replies; 3+ messages in thread
From: Paolo Bonzini @ 2023-07-05 11:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: jsnow

The Python 3.12 situation is a mess, with both flake8 and pylint giving
false positives that do not happen with Python 3.11.  As a first step
towards understanding these issues, drop support for old linter versions
that do not work with it.  This at least makes it possible to install
easily the same versions of the linters on any version of Python, and
put the blame on the interpreter.

Paolo

Paolo Bonzini (2):
  python: work around mypy false positive
  python: bump minimum requirements so they are compatible with 3.12

 python/qemu/qmp/qmp_tui.py | 3 ++-
 python/setup.cfg           | 2 +-
 python/tests/minreqs.txt   | 9 ++++-----
 3 files changed, 7 insertions(+), 7 deletions(-)

-- 
2.41.0



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] python: work around mypy false positive
  2023-07-05 11:25 [PATCH 0/2] python: first step towards Python 3.12 support Paolo Bonzini
@ 2023-07-05 11:25 ` Paolo Bonzini
  2023-07-05 11:25 ` [PATCH 2/2] python: bump minimum requirements so they are compatible with 3.12 Paolo Bonzini
  1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2023-07-05 11:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: jsnow

mypy 1.4.0 signals an error:

qemu/qmp/qmp_tui.py:350: error: Non-overlapping equality check (left operand type: "Literal[Runstate.DISCONNECTING]", right operand type: "Literal[Runstate.IDLE]")  [comparison-overlap]

This is because it does not realiez that self.disconnect() could change
the value of self.runstate.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 python/qemu/qmp/qmp_tui.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/python/qemu/qmp/qmp_tui.py b/python/qemu/qmp/qmp_tui.py
index 83691447231..1b68a71397f 100644
--- a/python/qemu/qmp/qmp_tui.py
+++ b/python/qemu/qmp/qmp_tui.py
@@ -346,7 +346,8 @@ async def manage_connection(self) -> None:
                 self._set_status('[Disconnected]')
                 await self.disconnect()
                 # check if a retry is needed
-                if self.runstate == Runstate.IDLE:
+                # mypy bug - doesn't realize self.runstate could change
+                if self.runstate == Runstate.IDLE:  # type: ignore
                     continue
             await self.runstate_changed()
 
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] python: bump minimum requirements so they are compatible with 3.12
  2023-07-05 11:25 [PATCH 0/2] python: first step towards Python 3.12 support Paolo Bonzini
  2023-07-05 11:25 ` [PATCH 1/2] python: work around mypy false positive Paolo Bonzini
@ 2023-07-05 11:25 ` Paolo Bonzini
  1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2023-07-05 11:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: jsnow

There are many Python 3.12 issues right now, but a particularly
problematic one when debugging them is that one cannot even use
minreqs.txt in a Python 3.12 virtual environment to test with
locked package versions.

Bump the mypy and wrapt versions to fix this, while remaining
within the realm of versions compatible with Python 3.7.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 python/setup.cfg         | 2 +-
 python/tests/minreqs.txt | 9 ++++-----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/python/setup.cfg b/python/setup.cfg
index 42f0b0be07d..5d7e95f5d24 100644
--- a/python/setup.cfg
+++ b/python/setup.cfg
@@ -39,7 +39,7 @@ devel =
     flake8 >= 5.0.4
     fusepy >= 2.0.4
     isort >= 5.1.2
-    mypy >= 0.780
+    mypy >= 1.4.0
     pylint >= 2.17.3
     tox >= 3.18.0
     urwid >= 2.1.2
diff --git a/python/tests/minreqs.txt b/python/tests/minreqs.txt
index 1ce72cef6d8..979461be6bb 100644
--- a/python/tests/minreqs.txt
+++ b/python/tests/minreqs.txt
@@ -28,7 +28,7 @@ avocado-framework==90.0
 # Linters
 flake8==5.0.4
 isort==5.1.2
-mypy==0.780
+mypy==1.4.0
 pylint==2.17.3
 
 # Transitive flake8 dependencies
@@ -37,12 +37,11 @@ pycodestyle==2.9.1
 pyflakes==2.5.0
 
 # Transitive mypy dependencies
-mypy-extensions==0.4.3
-typed-ast==1.4.0
-typing-extensions==4.5.0
+mypy-extensions==1.0.0
+typing-extensions==4.7.1
 
 # Transitive pylint dependencies
 astroid==2.15.4
 lazy-object-proxy==1.4.0
 toml==0.10.0
-wrapt==1.12.1
+wrapt==1.14.0
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-07-05 11:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-05 11:25 [PATCH 0/2] python: first step towards Python 3.12 support Paolo Bonzini
2023-07-05 11:25 ` [PATCH 1/2] python: work around mypy false positive Paolo Bonzini
2023-07-05 11:25 ` [PATCH 2/2] python: bump minimum requirements so they are compatible with 3.12 Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).