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

Fixed bug that results in false positive error when a dataclass field… #9223

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

erictraut
Copy link
Collaborator

… is annotated with a class-scoped type variable and includes a default value whose type require bidirectional type inference. This addresses #9222.

… is annotated with a class-scoped type variable and includes a default value whose type require bidirectional type inference. This addresses #9222.
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/app.py:767:16 - error: Type "Leaderboard[Self@PartialApp[NameT@PartialApp], DisplayNameT@Leaderboard]" is not assignable to return type "Leaderboard[Self@PartialApp[NameT@PartialApp], None]"
-     "Leaderboard[Self@PartialApp[NameT@PartialApp], DisplayNameT@Leaderboard]" is not assignable to "Leaderboard[Self@PartialApp[NameT@PartialApp], None]"
-       Type parameter "DisplayNameT@Leaderboard" is covariant, but "DisplayNameT@Leaderboard" is not a subtype of "None"
-         Type "str* | None" is not assignable to type "None"
-           "str*" is not assignable to "None" (reportReturnType)
-   /tmp/mypy_primer/projects/steam.py/steam/app.py:788:16 - error: Type "Leaderboard[Self@PartialApp[NameT@PartialApp], DisplayNameT@Leaderboard]" is not assignable to return type "Leaderboard[Self@PartialApp[NameT@PartialApp], None]"
-     "Leaderboard[Self@PartialApp[NameT@PartialApp], DisplayNameT@Leaderboard]" is not assignable to "Leaderboard[Self@PartialApp[NameT@PartialApp], None]"
-       Type parameter "DisplayNameT@Leaderboard" is covariant, but "DisplayNameT@Leaderboard" is not a subtype of "None"
-         Type "str* | None" is not assignable to type "None"
-           "str*" is not assignable to "None" (reportReturnType)
- /tmp/mypy_primer/projects/steam.py/steam/channel.py
-   /tmp/mypy_primer/projects/steam.py/steam/channel.py:40:9 - error: Argument of type "ClanT@Channel" cannot be assigned to parameter "clan" of type "None" in function "__init__"
-     Type "Clan* | None" is not assignable to type "None"
-       "Clan*" is not assignable to "None" (reportArgumentType)
-   /tmp/mypy_primer/projects/steam.py/steam/channel.py:40:9 - error: Argument of type "GroupT@Channel" cannot be assigned to parameter "group" of type "None" in function "__init__"
-     Type "Group* | None" is not assignable to type "None"
-       "Group*" is not assignable to "None" (reportArgumentType)
- 8455 errors, 96 warnings, 0 informations 
+ 8451 errors, 96 warnings, 0 informations 

core (https://github.com/home-assistant/core)
-   /tmp/mypy_primer/projects/core/homeassistant/components/shelly/button.py:42:5 - error: Argument of type "(_: _ShellyCoordinatorT@ShellyButtonDescription) -> Literal[True]" cannot be assigned to parameter "supported" of type "(ShellyBlockCoordinator | ShellyRpcCoordinator) -> bool" in function "__init__"
-     Type "(_: _ShellyCoordinatorT@ShellyButtonDescription) -> Literal[True]" is not assignable to type "(ShellyBlockCoordinator | ShellyRpcCoordinator) -> bool"
-       Parameter 1: type "ShellyBlockCoordinator | ShellyRpcCoordinator" is incompatible with type "_ShellyCoordinatorT@ShellyButtonDescription"
-         Type "ShellyBlockCoordinator | ShellyRpcCoordinator" is not assignable to type "_ShellyCoordinatorT@ShellyButtonDescription" (reportArgumentType)
- 22416 errors, 323 warnings, 0 informations 
+ 22415 errors, 323 warnings, 0 informations 

@erictraut erictraut merged commit 8b5d9a3 into main Oct 15, 2024
18 checks passed
@erictraut erictraut deleted the issue-9222 branch October 15, 2024 02:20
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.

1 participant