Skip to content

Commit

Permalink
python: bump minimum requirements so they are compatible with 3.12
Browse files Browse the repository at this point in the history
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.

This requires a workaround for a mypy false positive

    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]

where mypy does not realize that self.disconnect() could change
the value of self.runstate.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
bonzini committed Jul 7, 2023
1 parent 97c81ef commit 3d7b897
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
5 changes: 4 additions & 1 deletion python/qemu/qmp/qmp_tui.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,10 @@ 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 1.4.0 doesn't believe runstate can change after
# disconnect(), hence the cast.
state = cast(Runstate, self.runstate)
if state == Runstate.IDLE:
continue
await self.runstate_changed()

Expand Down
2 changes: 1 addition & 1 deletion python/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions python/tests/minreqs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 3d7b897

Please sign in to comment.