fix: mention type aliases in "Type application" error message#21122
Open
nuglifeleoji wants to merge 1 commit intopython:masterfrom
Open
fix: mention type aliases in "Type application" error message#21122nuglifeleoji wants to merge 1 commit intopython:masterfrom
nuglifeleoji wants to merge 1 commit intopython:masterfrom
Conversation
The error fired when calling e.g. func[int]() on a generic function said: Type application is only supported for generic classes but PEP 695 type aliases (type TA[T] = ...) also support type application, making the message inaccurate. Updated to: Type application is only supported for generic classes and type aliases Updated the message in message_registry.py and all matching test fixtures. Closes python#20927 Made-with: Cursor
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: Tanjun (https://github.com/FasterSpeeding/Tanjun)
- tanjun/commands/menu.py:63: error: Type application is only supported for generic classes [misc]
+ tanjun/commands/menu.py:63: error: Type application is only supported for generic classes and type aliases [misc]
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #20927.
The error message raised when type arguments are applied to a non-class expression (e.g. a generic function):
is inaccurate because PEP 695 type aliases (
type TA[T] = list[T]) also support type application (TA[int]). Updated to:Updated
mypy/message_registry.py(ONLY_CLASS_APPLICATION) and all matching test fixtures.Made with Cursor