Skip to content
Discussion options

You must be logged in to vote

This is expected behavior. Literal values are not retained when inferring the type of a list, dict, or set expression. You can override the default inference rules by adding a type annotation on the target variable. Pyright will then use bidirectional type inference.

changes: set[Literal[" ", "+", "-"]] = {change for change, _ in diff}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by injust
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants