Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[do not merge] Fixes type inference for generic calls in if expr #15140

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

hauntsaninja
Copy link
Collaborator

This is @sobolevn 's work from #11128, resubmitting since the old PR can't be saved because Nikita's repo got deleted

Copy link
Member

@sobolevn sobolevn 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 for reviving this!

[case testUnificationEmptySetRight]
def f(): pass
a = {0} if f() else set()
a() # E: "Set[int]" not callable
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
a() # E: "Set[int]" not callable
reveal_type(a()) # N: Revealed type is "Set[int]"

@@ -10,7 +10,8 @@ class object:
class type: pass
class tuple(Generic[T]): pass
class function: pass
class int: pass
class int:
def conjugate(self) -> int: pass
Copy link
Member

Choose a reason for hiding this comment

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

I think we can use our own classes here, so we can simplify the stub

@hauntsaninja hauntsaninja changed the title Fixes type inference for generic calls in if expr [do not merge] Fixes type inference for generic calls in if expr Apr 28, 2023
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