diff mbox series

[RFC,1/9] python: update for mypy 0.950

Message ID 20220513000609.197906-2-jsnow@redhat.com
State New
Headers show
Series tests: run python tests under the build/tests/venv environment | expand

Commit Message

John Snow May 13, 2022, 12:06 a.m. UTC
typeshed (included in mypy) recently updated to improve the typing for
WriteTransport objects. I was working around this, but now there's a
version where I shouldn't work around it.

Unfortunately this creates some minor ugliness if I want to support both
pre- and post-0.950 versions. For now, for my sanity, just disable the
unused-ignores warning.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 python/qemu/qmp/util.py | 4 +++-
 python/setup.cfg        | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

Comments

Paolo Bonzini May 13, 2022, 8:42 a.m. UTC | #1
On 5/13/22 02:06, John Snow wrote:
> typeshed (included in mypy) recently updated to improve the typing for
> WriteTransport objects. I was working around this, but now there's a
> version where I shouldn't work around it.
> 
> Unfortunately this creates some minor ugliness if I want to support both
> pre- and post-0.950 versions. For now, for my sanity, just disable the
> unused-ignores warning.
> 
> Signed-off-by: John Snow <jsnow@redhat.com>

Whatever floats your boat :)

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

Paolo
John Snow May 13, 2022, 2:09 p.m. UTC | #2
On Fri, May 13, 2022, 4:42 AM Paolo Bonzini <pbonzini@redhat.com> wrote:

> On 5/13/22 02:06, John Snow wrote:
> > typeshed (included in mypy) recently updated to improve the typing for
> > WriteTransport objects. I was working around this, but now there's a
> > version where I shouldn't work around it.
> >
> > Unfortunately this creates some minor ugliness if I want to support both
> > pre- and post-0.950 versions. For now, for my sanity, just disable the
> > unused-ignores warning.
> >
> > Signed-off-by: John Snow <jsnow@redhat.com>
>
> Whatever floats your boat :)
>
> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
>
> Paolo
>

Maybe I'll move towards pinning specific versions of analysis tools once we
move to always using a venv, and I won't have to try so hard to target a
wide spread of versions for mypy, pylint, etc.

I've tried pretty hard to "just have it work", but with the prevailing
idioms in the Python world being what they are, I am playing whackamole
virtually every release.

But, yeah, for now... meh. This keeps the boat afloat.
diff mbox series

Patch

diff --git a/python/qemu/qmp/util.py b/python/qemu/qmp/util.py
index eaa5fc7d5f9..ca6225e9cda 100644
--- a/python/qemu/qmp/util.py
+++ b/python/qemu/qmp/util.py
@@ -40,7 +40,9 @@  async def flush(writer: asyncio.StreamWriter) -> None:
     drain. The flow control limits are restored after the call is
     completed.
     """
-    transport = cast(asyncio.WriteTransport, writer.transport)
+    transport = cast(  # type: ignore[redundant-cast]
+        asyncio.WriteTransport, writer.transport
+    )
 
     # https://github.com/python/typeshed/issues/5779
     low, high = transport.get_write_buffer_limits()  # type: ignore
diff --git a/python/setup.cfg b/python/setup.cfg
index e877ea56475..c2c61c75190 100644
--- a/python/setup.cfg
+++ b/python/setup.cfg
@@ -79,6 +79,7 @@  strict = True
 python_version = 3.6
 warn_unused_configs = True
 namespace_packages = True
+warn_unused_ignores = False
 
 [mypy-qemu.utils.qom_fuse]
 # fusepy has no type stubs: