Skip to content

Add TypeGuard and TypeIs traversing in TypeTraverserVisitor (fixes #17029)#17071

Merged
hauntsaninja merged 2 commits intopython:masterfrom
sloboegen:issue-17029
Mar 29, 2024
Merged

Add TypeGuard and TypeIs traversing in TypeTraverserVisitor (fixes #17029)#17071
hauntsaninja merged 2 commits intopython:masterfrom
sloboegen:issue-17029

Conversation

@sloboegen
Copy link
Copy Markdown
Contributor

Fixes #17029.

Comment thread mypy/typetraverser.py
Comment on lines +89 to +90
if t.type_guard is not None:
t.type_guard.accept(self)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this an issue for TypeIs as well? Probably as easy as adding an if t.type_is is not None clause here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, please add an analogous test for TypeIs as well. It should behave exactly the same here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, thanks! It was interesting to learn about TypeIs :)

@github-actions

This comment has been minimized.

@sloboegen sloboegen changed the title Add TypeGuard traversing in TypeTraverserVisitor (fixes #17029) Add TypeGuard and TypeIs traversing in TypeTraverserVisitor (fixes #17029) Mar 28, 2024
Copy link
Copy Markdown
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

Thanks!

@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.

A callable typed function is not recognised as a TypeVar-ed argument

4 participants