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

2021-11-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset 60b5333fa936a7e7f078a82e0fa3752cc9b6c5fb by Nikita Sobolev in branch 'main': bpo-45679: add `tuple` tests with `lru_cache` to `test_functools` (GH-29339) https://github.com/python/cpython/commit/60b5333fa936a7e7f078a82e0fa3752cc9b6c5fb

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

2021-11-03 Thread Ken Jin
Ken Jin added the comment: 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! -- resolution: -> fixed stage: patch

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

2021-11-03 Thread Ken Jin
Ken Jin added the comment: New changeset bbcf06bf95b448810f1b6f4f119c32e871bfb84c by Serhiy Storchaka in branch '3.9': [3.9] bpo-45679: Fix caching of multi-value typing.Literal (GH-29334) (GH-29342) https://github.com/python/cpython/commit/bbcf06bf95b448810f1b6f4f119c32e871bfb84c

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

2021-10-31 Thread miss-islington
miss-islington added the comment: New changeset 3997f3ce8ab15269fc800062f75411865dbc0d55 by Miss Islington (bot) in branch '3.10': bpo-45679: Fix caching of multi-value typing.Literal (GH-29334) https://github.com/python/cpython/commit/3997f3ce8ab15269fc800062f75411865dbc0d55 --

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

2021-10-31 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- pull_requests: +27607 pull_request: https://github.com/python/cpython/pull/29342 ___ Python tracker ___

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

2021-10-31 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset 634984d7dbdd91e0a51a793eed4d870e139ae1e0 by Serhiy Storchaka in branch 'main': bpo-45679: Fix caching of multi-value typing.Literal (GH-29334) https://github.com/python/cpython/commit/634984d7dbdd91e0a51a793eed4d870e139ae1e0 --

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

2021-10-31 Thread miss-islington
Change by miss-islington : -- nosy: +miss-islington nosy_count: 6.0 -> 7.0 pull_requests: +27606 pull_request: https://github.com/python/cpython/pull/29340 ___ Python tracker

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

2021-10-31 Thread Nikita Sobolev
Change by Nikita Sobolev : -- pull_requests: +27605 pull_request: https://github.com/python/cpython/pull/29339 ___ Python tracker ___

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

2021-10-30 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- pull_requests: +27602 pull_request: https://github.com/python/cpython/pull/29334 ___ Python tracker ___

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

2021-10-30 Thread Nikita Sobolev
Change by Nikita Sobolev : -- keywords: +patch pull_requests: +27601 stage: -> patch review pull_request: https://github.com/python/cpython/pull/29333 ___ Python tracker ___

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

2021-10-30 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: 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

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

2021-10-30 Thread Nikita Sobolev
Nikita Sobolev added the comment: I see several ways of solving this: 1. Make `lru_cache(typed=True)` to look into iterable internals. This might be slow. And very slow for large iterables. Maybe even infinite for infinite ones 2. Adapt `Literal` / possibly other types to be treated

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

2021-10-30 Thread Nikita Sobolev
Nikita Sobolev 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') ```

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

2021-10-30 Thread Van Burgerberg
New submission from Van Burgerberg : When you create `Literal[1]` annotation and then create `Literal[True]` annotation, in the second case you will actually get `Literal[1]` instead. This is happening because `typing` performs caching of the outcome of parameterizing generics and