Skip to content

Fix testLiteralMeets failure #15659

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion test-data/unit/check-literal.test
Original file line number Diff line number Diff line change
Expand Up @@ -1797,7 +1797,8 @@ def f5(x: Literal[1], y: Union[Literal[1], Literal[2]]) -> None: pass
def f6(x: Optional[Literal[1]], y: Optional[Literal[2]]) -> None: pass

reveal_type(unify(f1)) # N: Revealed type is "Literal[1]"
reveal_type(unify(f2)) # N: Revealed type is "<nothing>"
if object():
Copy link
Member

Choose a reason for hiding this comment

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

This seems like a regression to me, because this is not "really <nothing>, execution is stopped", it is just "we cannot do a better job with two literal values".

In the long run we need to figure out how to tell these two cases apart.

Copy link
Contributor Author

@ikonst ikonst Jul 13, 2023

Choose a reason for hiding this comment

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

This was always the case for function scope. I only made module scope work the same way.

I agree that entire behavior leaves a lot to be desired, and I'll try to work on that next.

(Fwiw, it's also broken that "cannot call function of unknown type" is treated differently than "expression has uninhibited type".)

reveal_type(unify(f2)) # N: Revealed type is "<nothing>"
reveal_type(unify(f3)) # N: Revealed type is "Literal[1]"
reveal_type(unify(f4)) # N: Revealed type is "Literal[1]"
reveal_type(unify(f5)) # N: Revealed type is "Literal[1]"
Expand Down