[issue45679] typing.Literal[True] is implicitly converted to typing.Literal[1]

Nikita Sobolev report at bugs.python.org
Sat Oct 30 12:54:44 EDT 2021


Nikita Sobolev <mail at sobolevn.me> added the comment:

This happens to all `lru_cache` calls, where we deal with container types.

Example:

```
from functools import lru_cache

@lru_cache(typed=True)
def test(arg):
    return str(arg)

print(test((1, 'a')))  # (1, 'a')
print(test((True, 'a')))  # (1, 'a')
```

Moveover, this behavior is not tested in `test_functools`: https://github.com/python/cpython/blame/aae18a17401dc36917c0f64f971d60ab1a5b477e/Lib/test/test_functools.py#L1482-L1496

Original issue: https://bugs.python.org/issue13227
Original commit: https://github.com/python/cpython/commit/cd9fdfd652cdaca959b1c5d4cddf60d90a331b47

----------
nosy: +gvanrossum, kj, rhettinger, sobolevn

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45679>
_______________________________________


More information about the Python-bugs-list mailing list