-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Add basic support for typing_extensions.TypeVar
#14313
Merged
Merged
Conversation
This file contains 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
Diff from mypy_primer, showing the effect of this PR on open source code: steam.py (https://github.com/Gobot1234/steam.py)
+ steam/types/user.py:45: error: Unexpected argument to "TypeVar()": "default" [misc]
+ steam/types/user.py:47: error: Unexpected argument to "TypeVar()": "default" [misc]
+ steam/id.py:222: error: Unexpected argument to "TypeVar()": "default" [misc]
- steam/role.py:48: error: MemberT? has no attribute "roles" [attr-defined]
+ steam/app.py:50: error: Unexpected argument to "TypeVar()": "default" [misc]
+ steam/trade.py:39: error: Unexpected argument to "TypeVar()": "default" [misc]
+ steam/trade.py:239: error: Unexpected argument to "TypeVar()": "default" [misc]
+ steam/package.py:37: error: Unexpected argument to "TypeVar()": "default" [misc]
+ steam/profile.py:77: error: Unexpected argument to "TypeVar()": "default" [misc]
+ steam/abc.py:53: error: Unexpected argument to "TypeVar()": "default" [misc]
+ steam/event.py:33: error: Unexpected argument to "TypeVar()": "default" [misc]
+ steam/event.py:34: error: Unexpected argument to "TypeVar()": "default" [misc]
+ steam/comment.py:23: error: Unexpected argument to "TypeVar()": "default" [misc]
- steam/chat.py:130: error: "ChatGroup" expects no type arguments, but 2 given [type-arg]
+ steam/chat.py:158: error: Unexpected argument to "TypeVar()": "default" [misc]
- steam/chat.py:178: error: Variable "steam.chat.MemberT" is not valid as a type [valid-type]
- steam/chat.py:178: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/chat.py:292: error: Variable "steam.chat.ChatMessageT" is not valid as a type [valid-type]
- steam/chat.py:292: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/chat.py:296: error: "ChatGroup" expects no type arguments, but 2 given [type-arg]
- steam/chat.py:303: error: Variable "steam.chat.ChatMessageT" is not valid as a type [valid-type]
- steam/chat.py:303: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/chat.py:340: error: Variable "steam.chat.ChatMessageT" is not valid as a type [valid-type]
- steam/chat.py:340: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/chat.py:352: error: Variable "steam.chat.ChatMessageT" is not valid as a type [valid-type]
- steam/chat.py:352: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/chat.py:369: error: Variable "steam.chat.ChatMessageT" is not valid as a type [valid-type]
- steam/chat.py:369: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/chat.py:372: error: No overload variant of "__new__" of "type" matches argument type "Type[ChatMessageT?]" [call-overload]
+ steam/chat.py:372: error: No overload variant of "__new__" of "type" matches argument type "Type[ChatMessageT]" [call-overload]
+ steam/chat.py:422: error: Unexpected argument to "TypeVar()": "default" [misc]
- steam/chat.py:466: error: Variable "steam.chat.MemberT" is not valid as a type [valid-type]
- steam/chat.py:466: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/chat.py:468: error: Variable "steam.chat.ChatT" is not valid as a type [valid-type]
- steam/chat.py:468: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/chat.py:522: error: Variable "steam.chat.MemberT" is not valid as a type [valid-type]
- steam/chat.py:522: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/chat.py:523: error: Argument 2 to "__get__" of "classproperty" has incompatible type "Type[ChatGroup]"; expected "Type[Self]" [arg-type]
+ steam/chat.py:523: error: Argument 2 to "__get__" of "classproperty" has incompatible type "Type[ChatGroup[MemberT, ChatT]]"; expected "Type[Self]" [arg-type]
- steam/chat.py:527: error: Cannot instantiate type "Type[MemberT?]" [misc]
- steam/chat.py:534: error: Variable "steam.chat.MemberT" is not valid as a type [valid-type]
- steam/chat.py:534: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/chat.py:544: error: Argument 2 to "__get__" of "classproperty" has incompatible type "Type[ChatGroup]"; expected "Type[Self]" [arg-type]
+ steam/chat.py:544: error: Argument 2 to "__get__" of "classproperty" has incompatible type "Type[ChatGroup[MemberT, ChatT]]"; expected "Type[Self]" [arg-type]
- steam/chat.py:549: error: Cannot instantiate type "Type[ChatT?]" [misc]
- steam/chat.py:550: error: ChatT? has no attribute "id" [attr-defined]
- steam/chat.py:552: error: ChatT? has no attribute "_update" [attr-defined]
- steam/chat.py:578: error: Variable "steam.chat.MemberT" is not valid as a type [valid-type]
- steam/chat.py:578: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/chat.py:582: error: Variable "steam.chat.MemberT" is not valid as a type [valid-type]
- steam/chat.py:582: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/chat.py:590: note: def get(self, ID32, /) -> Optional[MemberT?]
+ steam/chat.py:590: note: def get(self, ID32, /) -> Optional[MemberT]
- steam/chat.py:590: note: def [_T] get(self, ID32, Union[MemberT?, _T], /) -> Union[MemberT?, _T]
+ steam/chat.py:590: note: def [_T] get(self, ID32, Union[MemberT, _T], /) -> Union[MemberT, _T]
- steam/chat.py:596: error: Variable "steam.chat.MemberT" is not valid as a type [valid-type]
- steam/chat.py:596: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/chat.py:601: error: Variable "steam.chat.MemberT" is not valid as a type [valid-type]
- steam/chat.py:601: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/chat.py:608: error: Variable "steam.chat.MemberT" is not valid as a type [valid-type]
- steam/chat.py:608: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/chat.py:612: error: Variable "steam.chat.MemberT" is not valid as a type [valid-type]
- steam/chat.py:612: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/chat.py:617: error: Variable "steam.chat.MemberT" is not valid as a type [valid-type]
- steam/chat.py:617: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/chat.py:622: error: Variable "steam.chat.ChatT" is not valid as a type [valid-type]
- steam/chat.py:622: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/chat.py:626: error: Variable "steam.chat.ChatT" is not valid as a type [valid-type]
- steam/chat.py:626: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/chat.py:637: error: Variable "steam.chat.ChatT" is not valid as a type [valid-type]
- steam/chat.py:637: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/chat.py:667: error: Variable "steam.chat.MemberT" is not valid as a type [valid-type]
- steam/chat.py:667: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/chat.py:673: error: Variable "steam.chat.MemberT" is not valid as a type [valid-type]
- steam/chat.py:673: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- steam/chat.py:691: error: Argument 2 to "__get__" of "classproperty" has incompatible type "Type[ChatGroup]"; expected "Type[Self]" [arg-type]
+ steam/chat.py:691: error: Argument 2 to "__get__" of "classproperty" has incompatible type "Type[ChatGroup[MemberT, ChatT]]"; expected "Type[Self]" [arg-type]
- steam/chat.py:693: error: Cannot instantiate type "Type[MemberT?]" [misc]
+ steam/message.py:29: error: Unexpected argument to "TypeVar()": "default" [misc]
+ steam/message.py:104: error: Unexpected argument to "TypeVar()": "default" [misc]
- steam/message.py:109: error: "ChatMessage" expects no type arguments, but 2 given [type-arg]
+ steam/message.py:109: error: "ChatMessage" expects 1 type argument, but 2 given [type-arg]
+ steam/message.py:120: error: Unexpected argument to "TypeVar()": "default" [misc]
- steam/message.py:125: error: "ChatMessage" expects no type arguments, but 2 given [type-arg]
+ steam/message.py:125: error: "ChatMessage" expects 1 type argument, but 2 given [type-arg]
- steam/channel.py:171: error: "Chat" expects no type arguments, but 1 given [type-arg]
- steam/channel.py:197: error: "Chat" expects no type arguments, but 1 given [type-arg]
- steam/group.py:32: error: "ChatGroup" expects no type arguments, but 3 given [type-arg]
+ steam/group.py:32: error: "ChatGroup" expects 2 type arguments, but 3 given [type-arg]
- steam/clan.py:281: error: "ChatGroup" expects no type arguments, but 3 given [type-arg]
+ steam/clan.py:281: error: "ChatGroup" expects 2 type arguments, but 3 given [type-arg]
- steam/clan.py:366: error: Incompatible types in assignment (expression has type "Dict[int, ClanChannel]", base class "ChatGroup" defined the type as "Dict[ChatID, ChatT?]") [assignment]
+ steam/clan.py:366: error: Incompatible types in assignment (expression has type "Dict[int, ClanChannel]", base class "ChatGroup" defined the type as "Dict[ChatID, Any]") [assignment]
+ steam/bundle.py:23: error: Unexpected argument to "TypeVar()": "default" [misc]
|
The primer output looks as expected, since we don't support |
JelleZijlstra
approved these changes
Dec 19, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, surprised only one place in the code needed to change. I verified with grep.
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.
This PR only adds the existing
TypeVar
support for thetyping_extensions
variant.I.e. it does not include support for
default
orinfer_variance
.Fixes #14312