-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
typing.Literal[True] is implicitly converted to typing.Literal[1] #89842
Comments
When you create Why is this inaccuracy important? from typing import Literal
SomeUsefulAlias = Literal[1, "abc"]
def func(arg: Literal[True, "abc"]):
if arg is not True:
arg.capitalize() If we look at |
This happens to all Example:
Moveover, this behavior is not tested in Original issue: https://bugs.python.org/issue13227 |
I see several ways of solving this:
I am going to send a PR with the second option. |
I agree. lru_cache(typed=True) itself should not look into iterable internals. It would be not only slow, but a change of semantic. The simplest way to solve this issue is to remove caching of __getitem__(). The more sophisticated way is to move caching to lower level and apply it to a function with a var-positional parameter. |
Closing this issue as the bug has been solved. @nikita could you please open a new issue for your tests PR and link to that instead? It seems like an enhancement over the current test suite for lru_cache. Thanks! |
typing.Literal
with more than one type arg #29333tuple
tests withlru_cache
totest_functools
#29339Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: