Skip to content

Fixed a bug in the type narrowing logic for the S in D type guard p…#10378

Merged
erictraut merged 1 commit intomainfrom
issue-10377
Apr 26, 2025
Merged

Fixed a bug in the type narrowing logic for the S in D type guard p…#10378
erictraut merged 1 commit intomainfrom
issue-10377

Conversation

@erictraut
Copy link
Collaborator

…attern (where S is a string literal and D is a TypedDict). If the TypedDict is not closed, the absence of the key within the TypedDict definition cannot eliminate the type during narrowing. This addresses #10376.

…attern (where S is a string literal and D is a TypedDict). If the TypedDict is not closed, the absence of the key within the TypedDict definition cannot eliminate the type during narrowing. This addresses #10376.
@github-actions
Copy link
Contributor

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

sympy (https://github.com/sympy/sympy)
-   /tmp/mypy_primer/projects/sympy/sympy/utilities/matchpy_connector.py:288:16 - error: Type "Basic" is not assignable to declared type "Expr"
-     "Basic" is not assignable to "Expr" (reportAssignmentType)
- 32773 errors, 72 warnings, 0 informations 
+ 32772 errors, 72 warnings, 0 informations 

strawberry (https://github.com/strawberry-graphql/strawberry)
-   /tmp/mypy_primer/projects/strawberry/strawberry/channels/testing.py:153:54 - error: Argument of type "list[GraphQLFormattedError] | object | Unknown" cannot be assigned to parameter "errors" of type "list[GraphQLFormattedError]" in function "process_errors"
+   /tmp/mypy_primer/projects/strawberry/strawberry/channels/testing.py:153:54 - error: Argument of type "Any | list[GraphQLFormattedError] | object | Unknown" cannot be assigned to parameter "errors" of type "list[GraphQLFormattedError]" in function "process_errors"
-     Type "list[GraphQLFormattedError] | object | Unknown" is not assignable to type "list[GraphQLFormattedError]"
+     Type "Any | list[GraphQLFormattedError] | object | Unknown" is not assignable to type "list[GraphQLFormattedError]"

@erictraut erictraut merged commit 907f49f into main Apr 26, 2025
17 checks passed
@erictraut erictraut deleted the issue-10377 branch April 26, 2025 19:36
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