Skip to content

Conversation

@George-Ogden
Copy link
Contributor

Test cases added from #20277 (initial PR) after issue #20600 (failing test cases), caused by #20492 (type narrowing PR).
Failing cases have been marked with -xfail

@George-Ogden George-Ogden force-pushed the xfail-narrowing branch 4 times, most recently from 743acf4 to 96fffd3 Compare January 16, 2026 22:04
if type(y) is int: # E: Subclass of "str" and "int" cannot exist: would have incompatible method signatures
y # E: Statement is unreachable
if type(y) is int:
y
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't quite get the change here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nothing can be a subclass of an integer and a string at the same time. This error existed in previous versions of Mypy, so I think we should not change it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like you removed the error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes - I have fixed that now

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

Thank you! This conflicts with some of the changes I have queued up (meta issue #20564 ) / those changes fix some of this, so I will wait for those to land and rebase on top

@hauntsaninja
Copy link
Collaborator

Okay, now that I've landed #20634 and #20637 it's a good time to rebase this PR. Some of this will now be fixed (and more will be fixed by later commits I have ready)

@hauntsaninja
Copy link
Collaborator

I think I preserved the relevant changes over the merge, but it was a little messy so lmk if I made a mistake

@George-Ogden
Copy link
Contributor Author

Looks okay to me

@hauntsaninja hauntsaninja changed the title Failing Test cases For Type Narrowing Add more test cases for type narrowing Jan 23, 2026
@hauntsaninja hauntsaninja merged commit 0c63401 into python:master Jan 23, 2026
16 checks passed
@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Jan 23, 2026

Rebased again because #20639 was merged, fixing some more of this.

Thanks for the PR and for the issues!

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.

3 participants