Test is_proper_subtype with string literals#14011
Test is_proper_subtype with string literals#14011ikonst wants to merge 1 commit intopython:masterfrom
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) # OKNote 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']??