Skip to content

Comments

Better handling of generics when narrowing#20863

Open
hauntsaninja wants to merge 2 commits intopython:masterfrom
hauntsaninja:narrow94
Open

Better handling of generics when narrowing#20863
hauntsaninja wants to merge 2 commits intopython:masterfrom
hauntsaninja:narrow94

Conversation

@hauntsaninja
Copy link
Collaborator

@hauntsaninja hauntsaninja commented Feb 22, 2026

Notably we preserve behaviour on the testNarrowingCollections test I added in a previous PR

Closes #20673

hauntsaninja and others added 2 commits February 22, 2026 13:32
Notably we preserve behaviour on the testNarrowingCollections test I added
if from_equality:
# We erase generic args because values with different generic types can compare equal
# For instance, cast(list[str], []) and cast(list[int], [])
proposed_type = shallow_erase_type_for_equality(proposed_type)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the one line difference (the rest is just refactoring for clarity)

@github-actions
Copy link
Contributor

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

graphql-core (https://github.com/graphql-python/graphql-core)
- tests/execution/test_resolve.py:322: error: Value of type "list[SourceLocation] | None" is not indexable  [index]

rotki (https://github.com/rotki/rotki)
+ rotkehlchen/tests/integration/test_premium.py:820: error: Statement is unreachable  [unreachable]
+ rotkehlchen/tests/integration/test_premium.py:834: error: Statement is unreachable  [unreachable]

xarray (https://github.com/pydata/xarray)
+ xarray/tests/test_dataarray.py:291: error: Unused "type: ignore" comment  [unused-ignore]

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