KEMBAR78
fix: TypeGuard becomes bool instead of Any when passed as TypeVar (fixes #17117) by sloboegen · Pull Request #17145 · python/mypy · GitHub
Skip to content

Conversation

sloboegen
Copy link
Contributor

Fixes #17117.

Comment on lines 1028 to 1029
elif template.type_guard is not None:
template_ret_type = AnyType(TypeOfAny.special_form)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does this branch make sense?
When we use TypeGuard or TypeIs in template it seems that we should use TypeGuard/TypeIs in actual too. Otherwise, we get Never type in the previous steps. Is it true? I'm a little confused here...

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we can get rid of this branch as well. And yeah, all tests pass if I do.

(There's might also be some latent bug with TypeGuard and TypeIs mixing)

Copy link
Member

Choose a reason for hiding this comment

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

Yes, it's probably better to remove this branch too. I think when I implemented TypeIs I assumed we needed this to make bool and TypeGuard/TypeIs unify, but that doesn't seem to be the case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, thanks for your comments! Removed that elif-s for TypeGuard/TypeIs.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

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

@hauntsaninja hauntsaninja merged commit 5d9b1f9 into python:master Oct 18, 2024
17 checks passed
@hauntsaninja
Copy link
Collaborator

Thank you!

@sloboegen sloboegen deleted the issue-17117 branch October 18, 2024 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(🐞) TypeGuard passed to a TypeVar becomes Any, not bool

3 participants