Skip to content

Conversation

@hauntsaninja
Copy link
Collaborator

@hauntsaninja hauntsaninja commented Jan 30, 2026

I have some changes planned to improve final support, which will pair nicely with this

Fixes biggest thing in #10302 (original issue in there is not an issue; fixes this comment #10302 (comment) )


T_value = TypeVar("T_value", A, B)

def f2(self, obj: T_value) -> T_value:
Copy link
Member

Choose a reason for hiding this comment

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

What is the difference between f1 and f2? Both are generic in a type variable with values.

Copy link
Member

Choose a reason for hiding this comment

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

Nvm, I see you just fixed it.

Copy link
Collaborator Author

@hauntsaninja hauntsaninja Jan 30, 2026

Choose a reason for hiding this comment

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

Oh sorry, I fixed that already :-)

More generally, the behaviour here isn't yet perfect.

I opened this PR to fix the testTypeEqualsCheckUsingIsNonOverlappingChild-xfail case, discovered we had an open issue it affected sterliakov/mypy-issues#259 , so adding the test case for it.

The test case I added highlights two preexisting issues. Ideally a) the narrowing works in the unconstrained case, b) we issue an error in both branches in the bad constrained case

[builtins fixtures/isinstance.pyi]

[case testTypeEqualsCheckUsingIsNonOverlappingChild-xfail]
[case testTypeEqualsCheckUsingIsNonOverlappingChild]
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 test case I was targeting with this PR

@github-actions

This comment has been minimized.

@hauntsaninja
Copy link
Collaborator Author

static-frame primer has a wrong type annotation and they already have a type-ignore for it

@github-actions
Copy link
Contributor

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

static-frame (https://github.com/static-frame/static-frame)
+ static_frame/core/archive_npy.py:232: error: Statement is unreachable  [unreachable]

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.

2 participants