Skip to content
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

Added code to enforce invariance of class-scoped variables in overrid… #5934

Closed
wants to merge 1 commit into from

Conversation

erictraut
Copy link
Collaborator

…es when the reportIncompatibleVariableOverride rule is enabled. This addresses #5933.

…es when the `reportIncompatibleVariableOverride` rule is enabled. This addresses #5933.
@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

steam.py (https://github.com/Gobot1234/steam.py)
+ /tmp/mypy_primer/projects/steam.py/steam/channel.py
+   /tmp/mypy_primer/projects/steam.py/steam/channel.py:41:14 - error: "clan" overrides symbol of same name in class "Channel"
+     Variable is mutable so its type is invariant
+       Override type "None" is not the same as base type "Clan | None" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/steam.py/steam/channel.py:42:14 - error: "group" overrides symbol of same name in class "Channel"
+     Variable is mutable so its type is invariant
+       Override type "None" is not the same as base type "Group | None" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/steam.py/steam/channel.py:101:5 - error: "clan" overrides symbol of same name in class "Channel"
+     Variable is mutable so its type is invariant
+       Override type "None" is not the same as base type "Clan | None" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/steam.py/steam/channel.py:105:14 - error: "group" overrides symbol of same name in class "Channel"
+     Variable is mutable so its type is invariant
+       Override type "Group" is not the same as base type "Group | None" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/steam.py/steam/channel.py:113:5 - error: "group" overrides symbol of same name in class "Channel"
+     Variable is mutable so its type is invariant
+       Override type "None" is not the same as base type "Group | None" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/steam.py/steam/channel.py:117:14 - error: "clan" overrides symbol of same name in class "Channel"
+     Variable is mutable so its type is invariant
+       Override type "Clan" is not the same as base type "Clan | None" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/steam.py/steam/clan.py:59:5 - error: "group" overrides symbol of same name in class "Member"
+     Variable is mutable so its type is invariant
+       Override type "None" is not the same as base type "Group | None" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/steam.py/steam/clan.py:64:14 - error: "clan" overrides symbol of same name in class "Member"
+     Variable is mutable so its type is invariant
+       Override type "Clan" is not the same as base type "Clan | None" (reportIncompatibleVariableOverride)
+ /tmp/mypy_primer/projects/steam.py/steam/comment.py
+   /tmp/mypy_primer/projects/steam.py/steam/comment.py:44:5 - error: "id" overrides symbol of same name in class "Awardable"
+     Variable is mutable so its type is invariant
+       Override type "CommentID" is not the same as base type "int" (reportIncompatibleVariableOverride)
+ /tmp/mypy_primer/projects/steam.py/steam/event.py
+   /tmp/mypy_primer/projects/steam.py/steam/event.py:275:14 - error: "server_password" overrides symbol of same name in class "BaseEvent"
+     Variable is mutable so its type is invariant
+       Override type "str" is not the same as base type "str | None" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/steam.py/steam/event.py:297:5 - error: "server_password" overrides symbol of same name in class "BaseEvent"
+     Variable is mutable so its type is invariant
+       Override type "None" is not the same as base type "str | None" (reportIncompatibleVariableOverride)
+ /tmp/mypy_primer/projects/steam.py/steam/group.py
+   /tmp/mypy_primer/projects/steam.py/steam/group.py:30:14 - error: "group" overrides symbol of same name in class "Member"
+     Variable is mutable so its type is invariant
+       Override type "Group" is not the same as base type "Group | None" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/steam.py/steam/group.py:26:5 - error: "clan" overrides symbol of same name in class "Member"
+     Variable is mutable so its type is invariant
+       Override type "None" is not the same as base type "Clan | None" (reportIncompatibleVariableOverride)
+ /tmp/mypy_primer/projects/steam.py/steam/invite.py
+   /tmp/mypy_primer/projects/steam.py/steam/invite.py:84:5 - error: "clan" overrides symbol of same name in class "_ChatGroupInvite"
+     Variable is mutable so its type is invariant
+       Override type "Clan | PartialClan" is not the same as base type "Clan | PartialClan | None" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/steam.py/steam/invite.py:86:5 - error: "relationship" overrides symbol of same name in class "_Invite"
+     Variable is mutable so its type is invariant
+       Override type "FriendRelationship" is not the same as base type "FriendRelationship | None" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/steam.py/steam/invite.py:88:5 - error: "group" overrides symbol of same name in class "_ChatGroupInvite"
+     Variable is mutable so its type is invariant
+       Override type "None" is not the same as base type "Group | None" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/steam.py/steam/invite.py:104:5 - error: "group" overrides symbol of same name in class "_ChatGroupInvite"
+     Variable is mutable so its type is invariant
+       Override type "Group" is not the same as base type "Group | None" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/steam.py/steam/invite.py:107:5 - error: "clan" overrides symbol of same name in class "_ChatGroupInvite"
+     Variable is mutable so its type is invariant
+       Override type "None" is not the same as base type "Clan | PartialClan | None" (reportIncompatibleVariableOverride)
+ /tmp/mypy_primer/projects/steam.py/steam/message.py
+   /tmp/mypy_primer/projects/steam.py/steam/message.py:95:5 - error: "channel" overrides symbol of same name in class "ChatMessage"
+     Variable is mutable so its type is invariant
+       Override type "GroupChannel" is not the same as base type "GroupChannel | ClanChannel" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/steam.py/steam/message.py:113:5 - error: "channel" overrides symbol of same name in class "ChatMessage"
+     Variable is mutable so its type is invariant
+       Override type "ClanChannel" is not the same as base type "GroupChannel | ClanChannel" (reportIncompatibleVariableOverride)
+ /tmp/mypy_primer/projects/steam.py/steam/post.py
+   /tmp/mypy_primer/projects/steam.py/steam/post.py:25:5 - error: "id" overrides symbol of same name in class "Awardable"
+     Variable is mutable so its type is invariant
+       Override type "PostID" is not the same as base type "int" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/steam.py/steam/published_file.py:204:14 - error: "id" overrides symbol of same name in class "Awardable"
+     Variable is mutable so its type is invariant
+       Override type "PublishedFileID" is not the same as base type "int" (reportIncompatibleVariableOverride)
+ /tmp/mypy_primer/projects/steam.py/steam/_gc/state.py
+   /tmp/mypy_primer/projects/steam.py/steam/_gc/state.py:64:5 - error: "user" overrides symbol of same name in class "ConnectionState"
+     Variable is mutable so its type is invariant
+       Override type "cached_property[Self@GCState[Inv@GCState], ClientUser]" is not the same as base type "cached_property[Self@ConnectionState, ClientUser]" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/steam.py/steam/ext/csgo/client.py:49:5 - error: "user" overrides symbol of same name in class "Client"
+     Variable is mutable so its type is invariant
+       Override type "cached_property[Self@Client, ClientUser]" is not the same as base type "cached_property[Self@Client, ClientUser]" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/steam.py/steam/ext/csgo/client.py:50:5 - error: "_state" overrides symbol of same name in class "Client"
+     Variable is mutable so its type is invariant
+       Override type "GCState" is not the same as base type "GCState[Any]" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/steam.py/steam/ext/csgo/state.py:40:5 - error: "client" overrides symbol of same name in class "GCState"
+     Variable is mutable so its type is invariant
+       Override type "Client" is not the same as base type "Client" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/steam.py/steam/ext/tf2/client.py:48:5 - error: "user" overrides symbol of same name in class "Client"
+     Variable is mutable so its type is invariant
+       Override type "cached_property[Self@Client, ClientUser]" is not the same as base type "cached_property[Self@Client, ClientUser]" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/steam.py/steam/ext/tf2/client.py:49:5 - error: "_state" overrides symbol of same name in class "Client"
+     Variable is mutable so its type is invariant
+       Override type "GCState" is not the same as base type "GCState[Any]" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/steam.py/steam/ext/tf2/state.py:28:5 - error: "client" overrides symbol of same name in class "GCState"
+     Variable is mutable so its type is invariant
+       Override type "Client" is not the same as base type "Client" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/steam.py/steam/protobufs/msg.py:140:14 - error: "header" overrides symbol of same name in class "NotProtobufWrapped"
+     Variable is mutable so its type is invariant
+       Override type "MessageHeader" is not the same as base type "MessageHeader | GCMessageHeader" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/steam.py/steam/protobufs/msg.py:169:14 - error: "header" overrides symbol of same name in class "MessageBase"
+     Variable is mutable so its type is invariant
+       Override type "ProtobufMessageHeader" is not the same as base type "MessageHeader | ProtobufMessageHeader | GCMessageHeader" (reportIncompatibleVariableOverride)
- 7904 errors, 25 warnings, 0 informations 

... (truncated 1 lines) ...

Tanjun (https://github.com/FasterSpeeding/Tanjun)
+   /tmp/mypy_primer/projects/Tanjun/tanjun/errors.py:348:5 - error: "parameter" overrides symbol of same name in class "ParserError"
+     Variable is mutable so its type is invariant
+       Override type "str" is not the same as base type "str | None" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/Tanjun/tanjun/errors.py:368:5 - error: "parameter" overrides symbol of same name in class "ParserError"
+     Variable is mutable so its type is invariant
+       Override type "str" is not the same as base type "str | None" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/Tanjun/tanjun/errors.py:387:5 - error: "parameter" overrides symbol of same name in class "ParserError"
+     Variable is mutable so its type is invariant
+       Override type "str" is not the same as base type "str | None" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/Tanjun/tanjun/errors.py:467:5 - error: "__cause__" overrides symbol of same name in class "BaseException"
+     Variable is mutable so its type is invariant
+       Override type "Exception" is not the same as base type "BaseException | None" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/Tanjun/tanjun/errors.py:496:5 - error: "__cause__" overrides symbol of same name in class "BaseException"
+     Variable is mutable so its type is invariant
+       Override type "Exception" is not the same as base type "BaseException | None" (reportIncompatibleVariableOverride)
- 2355 errors, 9831 warnings, 0 informations 
+ 2360 errors, 9831 warnings, 0 informations 

hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
+   /tmp/mypy_primer/projects/hydra-zen/src/hydra_zen/typing/_implementations.py:155:5 - error: "_target_" overrides symbol of same name in class "Builds"
+     Variable is mutable so its type is invariant
+       Override type "Literal['hydra_zen.funcs.get_obj']" is not the same as base type "str" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/hydra-zen/src/hydra_zen/typing/_implementations.py:169:5 - error: "_target_" overrides symbol of same name in class "Builds"
+     Variable is mutable so its type is invariant
+       Override type "Literal['hydra_zen.funcs.zen_processing']" is not the same as base type "str" (reportIncompatibleVariableOverride)
- 182 errors, 0 warnings, 0 informations 
+ 184 errors, 0 warnings, 0 informations 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants