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

[red-knot] Narrowing on s == "foo" where s is of type LiteralString #14648

Closed
InSyncWithFoo opened this issue Nov 28, 2024 · 0 comments · Fixed by #14649
Closed

[red-knot] Narrowing on s == "foo" where s is of type LiteralString #14648

InSyncWithFoo opened this issue Nov 28, 2024 · 0 comments · Fixed by #14649
Labels
red-knot Multi-file analysis & type inference

Comments

@InSyncWithFoo
Copy link
Contributor

InSyncWithFoo commented Nov 28, 2024

For any symbol s of type LiteralString, it should be safe to narrow it according to comparisons of the pattern s == "...".

a: LiteralString

if a == "foo":
	reveal_type(a)  # revealed: Literal["foo"]

This issue is part of #13694.

@AlexWaygood AlexWaygood added the red-knot Multi-file analysis & type inference label Nov 28, 2024
carljm added a commit that referenced this issue Dec 3, 2024
## Summary

Resolves #14648.

## Test Plan

Markdown tests.

---------

Co-authored-by: Carl Meyer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
red-knot Multi-file analysis & type inference
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants