-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Test is_proper_subtype with string literals #14011
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
base: master
Are you sure you want to change the base?
Test is_proper_subtype with string literals #14011
Conversation
cc @ilevkivskyi being |
Btw I noticed that it is used currently in one place in (Also this cc @JukkaL who approved the PR. |
Fortunately, it looks like this issue doesn't leak to the user, since |
Thanks for the thorough explanation. My rationale is that I've been experimenting with narrowing expressions that are operands of Was this taken as a shortcut, or is there some principle I'm missing?
Would it break too many things to replace that repr? |
I don't remember all details, but IIRC v: Final = 1
def foo(x: Literal[1, 2]) -> None: ...
foo(v) # OK
def bar(x: list[int]) -> None: ...
w = [v]
bar(w) # OK Note that we can't infer type of
You will probably need to update like 40-50 tests, also
But in general it will be OK. I would prefer something like |
This part is puzzling me:
Why is
Literal['bar']
a subtype ofLiteral['Foo']?
?