Fix Unpack imported from typing#14378
Conversation
This comment has been minimized.
This comment has been minimized.
| return None | ||
| return unbound.name, sym.node | ||
| if sym and sym.fullname == "typing_extensions.Unpack": | ||
| if sym and sym.fullname in {"typing.Unpack", "typing_extensions.Unpack"}: |
There was a problem hiding this comment.
| if sym and sym.fullname in {"typing.Unpack", "typing_extensions.Unpack"}: | |
| if sym and sym.fullname in ("typing.Unpack", "typing_extensions.Unpack"): |
Nit, but this is what most other similar checks look like and I suspect mypyc handles it better. It's likely also faster in non-compiled Python to use a tuple here.
There was a problem hiding this comment.
Not sure about mypyc, but for non-compiled Python it's actually a toss-up for two items. However, starting with three, sets are usually better.
There was a problem hiding this comment.
I ran some local benchmarks and set is faster even for two-element tuples when the element is the second one. Still, better to be consistent with the other mypy code.
Co-authored-by: Jelle Zijlstra <[email protected]>
|
According to mypy_primer, this change has no effect on the checked open source code. π€π |
Add missing check for
typing.Unpackto fix running with--python 3.11.