GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||
GeezerVison is showing github.com — Include tuple fallback in constraints built from tuple types by sterliakov · Pull Request #19100 · python/mypy Conversation
Collaborator
Fixes #19093.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
This comment has been minimized.
A5rocks
reviewed
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes sense. I think NamedTuples also use
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
There was an error while loading. Please reload this page.
|
will this also stop mypy from crashing in case of a typo like this? class MyTuple[*Ts](tuple[*_Ts]): ... # oh no a typo https://mypy-play.net/?mypy=1.15.0&python=3.13&gist=1b2a9f33efc227902750f06f5b9c54e4 or should I open a new issue for this? edit: the same crash also seems to happen in case of valid code, btw: class Shape0(tuple[*tuple[()]]): ... https://mypy-play.net/?mypy=latest&python=3.13&gist=e201c77b05e55f03d4b475342475dd83 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
And similarly, how about this one: class Shape[*Ts](tuple[*Ts]): ... reveal_type((42, )) # tuple[Literal[42]?] reveal_type(Shape((42, ))) # __main__.Shape[Unpack[builtins.tuple[Never, ...]]] https://mypy-play.net/?mypy=1.15.0&python=3.13&gist=2e2ba990a2112c97ca8d9d071c559a56 is this also covered by this fix, or a different issue? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@jorenham No, this will definitely not fix a crash, and I highly recommend reporting that one separately ASAP as a crash (not a bug). I'll try to look into it when I have some time - that should be an easy fix. The second snippet is also a different issue (probably unrelated to both this PR and the crash, please report too). @A5rocks namedtuples are handled by a different branch and we should (hopefully) already have tests for that; constraints for namedtuples are built as if they were just their fallbacks, ignoring tuple items. Any ideas what's that |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Diff from mypy_primer, showing the effect of this PR on open source code: mongo-python-driver (https://github.com/mongodb/mongo-python-driver) + bson/__init__.py:1330: error: Unused "type: ignore" comment [unused-ignore] + bson/__init__.py:1376: error: Unused "type: ignore[arg-type]" comment [unused-ignore] |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Nice! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Argument 1 totype_check_only has incompatible type type[S[T, *Ts]]; expected type[S[T, *Ts]]
There was an error while loading. Please reload this page.