-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix Datagram Received Type #15184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Datagram Received Type #15184
Conversation
This comment has been minimized.
This comment has been minimized.
|
You can see the problem in the primer hits: |
I think to support this use-case the type would need to be Edit: Needed |
|
Diff from mypy_primer, showing the effect of this PR on open source code: core (https://github.com/home-assistant/core)
+ homeassistant/components/esphome/assist_satellite.py:777: error: Argument 2 of "datagram_received" is incompatible with supertype "asyncio.protocols.DatagramProtocol"; supertype defines the argument type as "tuple[Any, int, *tuple[Any, ...]]" [override]
+ homeassistant/components/esphome/assist_satellite.py:777: note: This violates the Liskov substitution principle
+ homeassistant/components/esphome/assist_satellite.py:777: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
anyio (https://github.com/agronholm/anyio)
+ src/anyio/_backends/_asyncio.py:1229: error: Argument 2 of "datagram_received" is incompatible with supertype "asyncio.protocols.DatagramProtocol"; supertype defines the argument type as "tuple[Any, int, *tuple[Any, ...]]" [override]
+ src/anyio/_backends/_asyncio.py:1229: note: This violates the Liskov substitution principle
+ src/anyio/_backends/_asyncio.py:1229: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
|
I take this back, MyPy doesn't like this where-as I had luck testing with Pyright. I'll re-open assuming I get this working for both. |
This PR addressed #15169, and also makes the type more accurate by, instead of accepting
str | Anyfor the first tuple value, simply accepting| tuple[int | str, int]. Let me know if there's context I'm missing but I'm not seeing any reason why we can't do things this way.