Skip to content
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

bpo-45679: Fix caching of multi-value typing.Literal #29334

Merged

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Oct 30, 2021

Literal[True, 2] is no longer equal to Literal[1, 2].

https://bugs.python.org/issue45679

Literal[True, 2] is no longer equal to Literal[1, 2].
Copy link
Member

@Fidget-Spinner Fidget-Spinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks Serhiy.

typing.Literal[1, 2]: 'Literal',
typing.Literal[True, 2]: 'Literal',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if these tests for anything useful? It should still pass even without the fix.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, it passes without the fix because due to the bug typing.Literal[True, 2] and typing.Literal[1, 2] are the same.

But it fails with the PR originally proposed by @sobolevn. Some tests are added to catch possible similar errors.

@serhiy-storchaka serhiy-storchaka merged commit 634984d into python:main Oct 31, 2021
12 checks passed
@miss-islington
Copy link
Contributor

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10.
🐍🍒🤖

@serhiy-storchaka serhiy-storchaka deleted the typing-literal-caching branch Oct 31, 2021
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 31, 2021
Literal[True, 2] is no longer equal to Literal[1, 2].
(cherry picked from commit 634984d)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@miss-islington
Copy link
Contributor

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.9 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 634984d7dbdd91e0a51a793eed4d870e139ae1e0 3.9

@bedevere-bot
Copy link

GH-29340 is a backport of this pull request to the 3.10 branch.

serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Oct 31, 2021
…29334)

Literal[True, 2] is no longer equal to Literal[1, 2]..
(cherry picked from commit 634984d)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-bot
Copy link

GH-29342 is a backport of this pull request to the 3.9 branch.

miss-islington added a commit that referenced this pull request Oct 31, 2021
Literal[True, 2] is no longer equal to Literal[1, 2].
(cherry picked from commit 634984d)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Fidget-Spinner pushed a commit that referenced this pull request Nov 3, 2021
…GH-29342)

Literal[True, 2] is no longer equal to Literal[1, 2]..
(cherry picked from commit 634984d)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@serhiy-storchaka serhiy-storchaka removed their assignment Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants