Skip to content

Apply union expansion when checking ops involving typevars - #19455

Open
sterliakov wants to merge 8 commits into
python:masterfrom
sterliakov:bugfix/gh-19454-ops-on-typevr
Open

sterliakov wants to merge 8 commits into
python:masterfrom
sterliakov:bugfix/gh-19454-ops-on-typevr

Conversation

@sterliakov

@sterliakov sterliakov commented Jul 16, 2025 •

Copy link
Copy Markdown
Collaborator

Fixes #19454.
Fixes #18203.
Fixes #12899 (one error remains, but it is correct).

This might not be the most disciplined approach, but it should match the general expectations. In essence, here I apply union expansion to upper bounds the same way it was applied to plain unions.

@sterliakov sterliakov changed the title Apply union expansion when checking ops to typevars Apply union expansion when checking ops involving typevars Jul 16, 2025
@github-actions

This comment has been minimized.

@sterliakov
sterliakov marked this pull request as ready for review July 16, 2025 14:39
@github-actions

This comment has been minimized.

… have other places that create same-id copies of typevars
@github-actions

This comment has been minimized.

@sterliakov
sterliakov marked this pull request as draft August 8, 2025 16:56
@github-actions

This comment has been minimized.

@sterliakov
sterliakov marked this pull request as ready for review August 8, 2025 18:11
@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

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.

Comparison operators emit "Unsupported operand types" when using isinstance to narrow TypeVar to union of numeric types Arithmetic with type variables fails to typecheck ("Unsupported operand types") it's not possible to define an 'add' that works with more than one kind of number when using number types directly

1 participant