-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Improved the handling of a TypeVar whose definition involves a circul… #9377
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
…ar definition. This partially addresses #9353.
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/chat.py:422:25 - error: Argument of type "ClanMessage[PartialMember | ClanMember]* | GroupMessage[PartialMember | GroupMember]*" cannot be assigned to parameter "message" of type "Message[PartialUser, Channel[Message[UserT@Message, ChannelT@Message], Clan | None, Group | None]]" in function "__init__"
- Type "ClanMessage[PartialMember | ClanMember]* | GroupMessage[PartialMember | GroupMember]*" is not assignable to type "Message[PartialUser, Channel[Message[UserT@Message, ChannelT@Message], Clan | None, Group | None]]"
- "ClanMessage[PartialMember | ClanMember]*" is not assignable to "Message[PartialUser, Channel[Message[UserT@Message, ChannelT@Message], Clan | None, Group | None]]"
- Type parameter "ChannelT@Message" is covariant, but "ClanMember" is not a subtype of "Channel[Message[UserT@Message, ChannelT@Message], Clan | None, Group | None]"
- "ClanMember" is not assignable to "Channel[Message[UserT@Message, ChannelT@Message], Clan | None, Group | None]" (reportArgumentType)
- /tmp/mypy_primer/projects/steam.py/steam/message.py:87:68 - error: Too many type arguments provided for "ChatMessage"; expected 2 but received 3 (reportInvalidTypeArguments)
- /tmp/mypy_primer/projects/steam.py/steam/message.py:96:33 - error: Argument of type "GroupChannel" cannot be assigned to parameter "channel" of type "GroupMember" in function "__init__"
- "GroupChannel" is not assignable to "GroupMember" (reportArgumentType)
- /tmp/mypy_primer/projects/steam.py/steam/message.py:104:65 - error: Too many type arguments provided for "ChatMessage"; expected 2 but received 3 (reportInvalidTypeArguments)
- /tmp/mypy_primer/projects/steam.py/steam/message.py:113:33 - error: Argument of type "ClanChannel" cannot be assigned to parameter "channel" of type "ClanMember" in function "__init__"
- "ClanChannel" is not assignable to "ClanMember" (reportArgumentType)
- /tmp/mypy_primer/projects/steam.py/steam/state.py:1482:31 - error: Argument of type "ClanMessage[GroupMember | PartialMember | ClanMember] | GroupMessage[PartialMember | GroupMember]" cannot be assigned to parameter "x" of type "Message[PartialUser, Channel[Message[UserT@Message, ChannelT@Message], Clan | None, Group | None]]" in function "append"
- Type "ClanMessage[GroupMember | PartialMember | ClanMember] | GroupMessage[PartialMember | GroupMember]" is not assignable to type "Message[PartialUser, Channel[Message[UserT@Message, ChannelT@Message], Clan | None, Group | None]]"
- "ClanMessage[GroupMember | PartialMember | ClanMember]" is not assignable to "Message[PartialUser, Channel[Message[UserT@Message, ChannelT@Message], Clan | None, Group | None]]"
- Type parameter "ChannelT@Message" is covariant, but "ClanMember" is not a subtype of "Channel[Message[UserT@Message, ChannelT@Message], Clan | None, Group | None]"
- "ClanMember" is not assignable to "Channel[Message[UserT@Message, ChannelT@Message], Clan | None, Group | None]" (reportArgumentType)
- /tmp/mypy_primer/projects/steam.py/steam/state.py:1521:31 - error: Argument of type "ClanMessage[GroupMember | ClanMember] | GroupMessage[PartialMember | GroupMember]" cannot be assigned to parameter "x" of type "Message[PartialUser, Channel[Message[UserT@Message, ChannelT@Message], Clan | None, Group | None]]" in function "append"
- Type "ClanMessage[GroupMember | ClanMember] | GroupMessage[PartialMember | GroupMember]" is not assignable to type "Message[PartialUser, Channel[Message[UserT@Message, ChannelT@Message], Clan | None, Group | None]]"
- "ClanMessage[GroupMember | ClanMember]" is not assignable to "Message[PartialUser, Channel[Message[UserT@Message, ChannelT@Message], Clan | None, Group | None]]"
- Type parameter "ChannelT@Message" is covariant, but "ClanMember" is not a subtype of "Channel[Message[UserT@Message, ChannelT@Message], Clan | None, Group | None]"
- "ClanMember" is not assignable to "Channel[Message[UserT@Message, ChannelT@Message], Clan | None, Group | None]" (reportArgumentType)
- /tmp/mypy_primer/projects/steam.py/steam/state.py:1578:21 - error: Type of "_location" is unknown (reportUnknownMemberType)
- /tmp/mypy_primer/projects/steam.py/steam/state.py:1578:37 - error: Cannot access attribute "_location" for class "ClanMember"
- Attribute "_location" is unknown (reportAttributeAccessIssue)
- /tmp/mypy_primer/projects/steam.py/steam/state.py:1578:37 - error: Cannot access attribute "_location" for class "GroupMember"
- Attribute "_location" is unknown (reportAttributeAccessIssue)
- Type of "message" is "ChatMessage[Unknown, Unknown]" (reportUnknownMemberType)
+ Type of "message" is "ChatMessage[Unknown, Unknown, Unknown]" (reportUnknownMemberType)
- /tmp/mypy_primer/projects/steam.py/tests/unit/mocks.py:69:7 - error: Base classes of MockClanMessage are mutually incompatible
- Base class "ClanMessage[PartialMember | ClanMember]" derives from "Message[PartialMember | ClanMember, ClanMember]" which is incompatible with type "Message[PartialUser, Channel[Message[UserT@Message, ChannelT@Message], Clan | None, Group | None]]" (reportGeneralTypeIssues)
- /tmp/mypy_primer/projects/steam.py/tests/unit/mocks.py:73:7 - error: Base classes of MockGroupMessage are mutually incompatible
- Base class "GroupMessage[PartialMember | GroupMember]" derives from "Message[PartialMember | GroupMember, GroupMember]" which is incompatible with type "Message[PartialUser, Channel[Message[UserT@Message, ChannelT@Message], Clan | None, Group | None]]" (reportGeneralTypeIssues)
- 8443 errors, 95 warnings, 0 informations
+ 8431 errors, 95 warnings, 0 informations
core (https://github.com/home-assistant/core)
- /tmp/mypy_primer/projects/core/homeassistant/components/unifi/button.py:85:63 - error: Too many type arguments provided for "UnifiEntityDescription"; expected 1 but received 2 (reportInvalidTypeArguments)
- /tmp/mypy_primer/projects/core/homeassistant/components/unifi/button.py:146:47 - error: Too many type arguments provided for "UnifiEntity"; expected 1 but received 2 (reportInvalidTypeArguments)
- Override type "UnifiButtonEntityDescription[HandlerT@UnifiButtonEntity]" is not the same as base type "UnifiEntityDescription[HandlerT@UnifiButtonEntity]" (reportIncompatibleVariableOverride)
+ Override type "UnifiButtonEntityDescription[HandlerT@UnifiButtonEntity]" is not the same as base type "UnifiEntityDescription[HandlerT@UnifiButtonEntity, Unknown]" (reportIncompatibleVariableOverride)
- /tmp/mypy_primer/projects/core/homeassistant/components/unifi/device_tracker.py:146:38 - error: Too many type arguments provided for "UnifiEntityDescription"; expected 1 but received 2 (reportInvalidTypeArguments)
- /tmp/mypy_primer/projects/core/homeassistant/components/unifi/device_tracker.py:234:48 - error: Too many type arguments provided for "UnifiEntity"; expected 1 but received 2 (reportInvalidTypeArguments)
- Override type "UnifiTrackerEntityDescription[Unknown]" is not the same as base type "UnifiEntityDescription[HandlerT@UnifiScannerEntity]" (reportIncompatibleVariableOverride)
+ Override type "UnifiTrackerEntityDescription[Unknown]" is not the same as base type "UnifiEntityDescription[HandlerT@UnifiScannerEntity, Unknown]" (reportIncompatibleVariableOverride)
- /tmp/mypy_primer/projects/core/homeassistant/components/unifi/entity.py:134:58 - error: Too many type arguments provided for "UnifiEntityDescription"; expected 1 but received 2 (reportInvalidTypeArguments)
- /tmp/mypy_primer/projects/core/homeassistant/components/unifi/entity.py:141:55 - error: Too many type arguments provided for "UnifiEntityDescription"; expected 1 but received 2 (reportInvalidTypeArguments)
- Override type "UnifiEntityDescription[HandlerT@UnifiEntity]" is not the same as base type "EntityDescription" (reportIncompatibleVariableOverride)
+ Override type "UnifiEntityDescription[HandlerT@UnifiEntity, Unknown]" is not the same as base type "EntityDescription" (reportIncompatibleVariableOverride)
- /tmp/mypy_primer/projects/core/homeassistant/components/unifi/image.py:41:62 - error: Too many type arguments provided for "UnifiEntityDescription"; expected 1 but received 2 (reportInvalidTypeArguments)
- /tmp/mypy_primer/projects/core/homeassistant/components/unifi/image.py:78:46 - error: Too many type arguments provided for "UnifiEntity"; expected 1 but received 2 (reportInvalidTypeArguments)
- Override type "UnifiImageEntityDescription[HandlerT@UnifiImageEntity]" is not the same as base type "UnifiEntityDescription[HandlerT@UnifiImageEntity]" (reportIncompatibleVariableOverride)
+ Override type "UnifiImageEntityDescription[HandlerT@UnifiImageEntity]" is not the same as base type "UnifiEntityDescription[HandlerT@UnifiImageEntity, Unknown]" (reportIncompatibleVariableOverride)
- /tmp/mypy_primer/projects/core/homeassistant/components/unifi/image.py:91:55 - error: Too many type arguments provided for "UnifiEntityDescription"; expected 1 but received 2 (reportInvalidTypeArguments)
- /tmp/mypy_primer/projects/core/homeassistant/components/unifi/sensor.py:361:63 - error: Too many type arguments provided for "UnifiEntityDescription"; expected 1 but received 2 (reportInvalidTypeArguments)
- /tmp/mypy_primer/projects/core/homeassistant/components/unifi/sensor.py:656:47 - error: Too many type arguments provided for "UnifiEntity"; expected 1 but received 2 (reportInvalidTypeArguments)
- Override type "UnifiSensorEntityDescription[HandlerT@UnifiSensorEntity]" is not the same as base type "UnifiEntityDescription[HandlerT@UnifiSensorEntity]" (reportIncompatibleVariableOverride)
+ Override type "UnifiSensorEntityDescription[HandlerT@UnifiSensorEntity]" is not the same as base type "UnifiEntityDescription[HandlerT@UnifiSensorEntity, Unknown]" (reportIncompatibleVariableOverride)
- /tmp/mypy_primer/projects/core/homeassistant/components/unifi/switch.py:180:63 - error: Too many type arguments provided for "UnifiEntityDescription"; expected 1 but received 2 (reportInvalidTypeArguments)
- /tmp/mypy_primer/projects/core/homeassistant/components/unifi/switch.py:342:47 - error: Too many type arguments provided for "UnifiEntity"; expected 1 but received 2 (reportInvalidTypeArguments)
- Override type "UnifiSwitchEntityDescription[HandlerT@UnifiSwitchEntity]" is not the same as base type "UnifiEntityDescription[HandlerT@UnifiSwitchEntity]" (reportIncompatibleVariableOverride)
+ Override type "UnifiSwitchEntityDescription[HandlerT@UnifiSwitchEntity]" is not the same as base type "UnifiEntityDescription[HandlerT@UnifiSwitchEntity, Unknown]" (reportIncompatibleVariableOverride)
- /tmp/mypy_primer/projects/core/homeassistant/components/unifi/update.py:45:64 - error: Too many type arguments provided for "UnifiEntityDescription"; expected 1 but received 2 (reportInvalidTypeArguments)
- /tmp/mypy_primer/projects/core/homeassistant/components/unifi/update.py:50:46 - error: Type variable "_DataT" has no meaning in this context (reportGeneralTypeIssues)
- /tmp/mypy_primer/projects/core/homeassistant/components/unifi/update.py:54:43 - error: Too many type arguments provided for "UnifiUpdateEntityDescription"; expected 1 but received 2 (reportInvalidTypeArguments)
- /tmp/mypy_primer/projects/core/homeassistant/components/unifi/update.py:81:54 - error: Too many type arguments provided for "UnifiEntity"; expected 1 but received 2 (reportInvalidTypeArguments)
- Override type "UnifiUpdateEntityDescription[_HandlerT@UnifiDeviceUpdateEntity]" is not the same as base type "UnifiEntityDescription[_HandlerT@UnifiDeviceUpdateEntity]" (reportIncompatibleVariableOverride)
+ Override type "UnifiUpdateEntityDescription[_HandlerT@UnifiDeviceUpdateEntity, _DataT@UnifiDeviceUpdateEntity]" is not the same as base type "UnifiEntityDescription[_HandlerT@UnifiDeviceUpdateEntity, Unknown]" (reportIncompatibleVariableOverride)
- Override type "UnifiUpdateEntityDescription[_HandlerT@UnifiDeviceUpdateEntity]" is not the same as base type "UpdateEntityDescription" (reportIncompatibleVariableOverride)
+ Override type "UnifiUpdateEntityDescription[_HandlerT@UnifiDeviceUpdateEntity, _DataT@UnifiDeviceUpdateEntity]" is not the same as base type "UpdateEntityDescription" (reportIncompatibleVariableOverride)
- /tmp/mypy_primer/projects/core/homeassistant/components/unifi/update.py:84:65 - error: Type variable "_DataT" has no meaning in this context (reportGeneralTypeIssues)
- /tmp/mypy_primer/projects/core/homeassistant/components/unifi/update.py:84:65 - error: Too many type arguments provided for "UnifiUpdateEntityDescription"; expected 1 but received 2 (reportInvalidTypeArguments)
- 22496 errors, 322 warnings, 0 informations
+ 22477 errors, 322 warnings, 0 informations
pytest-robotframework (https://github.com/detachhead/pytest-robotframework)
- /tmp/mypy_primer/projects/pytest-robotframework/pytest_robotframework/__init__.py:206:53 - error: Expected no type arguments for class "SuppressableContextManager" (reportInvalidTypeArguments)
- /tmp/mypy_primer/projects/pytest-robotframework/pytest_robotframework/__init__.py:261:17 - error: Expected no type arguments for class "SuppressableContextManager" (reportInvalidTypeArguments)
- /tmp/mypy_primer/projects/pytest-robotframework/pytest_robotframework/_internal/robot/library.py:72:2 - error: Argument of type "(arg: Cloaked) -> None" cannot be assigned to parameter "fn" of type "() -> Unknown" in function "keyword"
+ /tmp/mypy_primer/projects/pytest-robotframework/pytest_robotframework/_internal/robot/library.py:72:2 - error: Argument of type "(arg: Cloaked[Unknown]) -> None" cannot be assigned to parameter "fn" of type "() -> Unknown" in function "keyword"
- Type "(arg: Cloaked) -> None" is not assignable to type "() -> Unknown"
+ Type "(arg: Cloaked[Unknown]) -> None" is not assignable to type "() -> Unknown"
- /tmp/mypy_primer/projects/pytest-robotframework/pytest_robotframework/_internal/robot/library.py:73:24 - error: Expected no type arguments for class "Cloaked" (reportInvalidTypeArguments)
- /tmp/mypy_primer/projects/pytest-robotframework/pytest_robotframework/_internal/robot/library.py:86:2 - error: Argument of type "(arg: Cloaked) -> None" cannot be assigned to parameter "fn" of type "() -> Unknown" in function "keyword"
+ /tmp/mypy_primer/projects/pytest-robotframework/pytest_robotframework/_internal/robot/library.py:86:2 - error: Argument of type "(arg: Cloaked[Unknown]) -> None" cannot be assigned to parameter "fn" of type "() -> Unknown" in function "keyword"
- Type "(arg: Cloaked) -> None" is not assignable to type "() -> Unknown"
+ Type "(arg: Cloaked[Unknown]) -> None" is not assignable to type "() -> Unknown"
- /tmp/mypy_primer/projects/pytest-robotframework/pytest_robotframework/_internal/robot/library.py:87:27 - error: Expected no type arguments for class "Cloaked" (reportInvalidTypeArguments)
- /tmp/mypy_primer/projects/pytest-robotframework/pytest_robotframework/_internal/robot/library.py:104:2 - error: Argument of type "(arg: Cloaked) -> None" cannot be assigned to parameter "fn" of type "() -> Unknown" in function "keyword"
+ /tmp/mypy_primer/projects/pytest-robotframework/pytest_robotframework/_internal/robot/library.py:104:2 - error: Argument of type "(arg: Cloaked[Unknown]) -> None" cannot be assigned to parameter "fn" of type "() -> Unknown" in function "keyword"
- Type "(arg: Cloaked) -> None" is not assignable to type "() -> Unknown"
+ Type "(arg: Cloaked[Unknown]) -> None" is not assignable to type "() -> Unknown"
- /tmp/mypy_primer/projects/pytest-robotframework/pytest_robotframework/_internal/robot/library.py:105:27 - error: Expected no type arguments for class "Cloaked" (reportInvalidTypeArguments)
- /tmp/mypy_primer/projects/pytest-robotframework/pytest_robotframework/_internal/robot/listeners_and_suite_visitors.py:314:59 - error: Argument of type "(arg: Cloaked) -> None" cannot be assigned to parameter "fn" of type "() -> None" in function "_create_running_keyword"
+ /tmp/mypy_primer/projects/pytest-robotframework/pytest_robotframework/_internal/robot/listeners_and_suite_visitors.py:314:59 - error: Argument of type "(arg: Cloaked[Unknown]) -> None" cannot be assigned to parameter "fn" of type "() -> None" in function "_create_running_keyword"
- Type "(arg: Cloaked) -> None" is not assignable to type "() -> None"
+ Type "(arg: Cloaked[Unknown]) -> None" is not assignable to type "() -> None"
- /tmp/mypy_primer/projects/pytest-robotframework/pytest_robotframework/_internal/robot/listeners_and_suite_visitors.py:317:72 - error: Argument of type "(arg: Cloaked) -> None" cannot be assigned to parameter "fn" of type "() -> None" in function "_create_running_keyword"
+ /tmp/mypy_primer/projects/pytest-robotframework/pytest_robotframework/_internal/robot/listeners_and_suite_visitors.py:317:72 - error: Argument of type "(arg: Cloaked[Unknown]) -> None" cannot be assigned to parameter "fn" of type "() -> None" in function "_create_running_keyword"
- Type "(arg: Cloaked) -> None" is not assignable to type "() -> None"
+ Type "(arg: Cloaked[Unknown]) -> None" is not assignable to type "() -> None"
- /tmp/mypy_primer/projects/pytest-robotframework/pytest_robotframework/_internal/robot/listeners_and_suite_visitors.py:320:65 - error: Argument of type "(arg: Cloaked) -> None" cannot be assigned to parameter "fn" of type "() -> None" in function "_create_running_keyword"
+ /tmp/mypy_primer/projects/pytest-robotframework/pytest_robotframework/_internal/robot/listeners_and_suite_visitors.py:320:65 - error: Argument of type "(arg: Cloaked[Unknown]) -> None" cannot be assigned to parameter "fn" of type "() -> None" in function "_create_running_keyword"
- Type "(arg: Cloaked) -> None" is not assignable to type "() -> None"
+ Type "(arg: Cloaked[Unknown]) -> None" is not assignable to type "() -> None"
- 306 errors, 18 warnings, 0 informations
+ 301 errors, 18 warnings, 0 informations
|
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.
…ar definition. This partially addresses #9353.