Skip to content

bpo-44635: Convert None to NoneType in the union type constructor#27136

Merged
serhiy-storchaka merged 2 commits intopython:mainfrom
serhiy-storchaka:union-args-none
Jul 14, 2021
Merged

bpo-44635: Convert None to NoneType in the union type constructor#27136
serhiy-storchaka merged 2 commits intopython:mainfrom
serhiy-storchaka:union-args-none

Conversation

@serhiy-storchaka
Copy link
Copy Markdown
Member

@serhiy-storchaka serhiy-storchaka commented Jul 14, 2021

Copy link
Copy Markdown
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.

Comment thread Lib/test/test_types.py
self.assertEqual((int | (str | list)).__args__, (int, str, list))
self.assertEqual((int | None).__args__, (int, type(None)))
self.assertEqual((int | type(None)).__args__, (int, type(None)))

Copy link
Copy Markdown
Member

@Fidget-Spinner Fidget-Spinner Jul 14, 2021

Choose a reason for hiding this comment

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

I recommend one more simple test to test equality of two unions.

Suggested change
self.assertEqual(int | type(None), int | None)

@serhiy-storchaka serhiy-storchaka merged commit b81cac0 into python:main Jul 14, 2021
@miss-islington
Copy link
Copy Markdown
Contributor

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

@miss-islington
Copy link
Copy Markdown
Contributor

Sorry @serhiy-storchaka, I had trouble checking out the 3.10 backport branch.
Please backport using cherry_picker on command line.
cherry_picker b81cac05606c84958b52ada09f690463a3c7e949 3.10

@bedevere-bot
Copy link
Copy Markdown

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

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Jul 14, 2021
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Jul 14, 2021
…tor (pythonGH-27136).

(cherry picked from commit b81cac0)

Co-authored-by: Serhiy Storchaka <[email protected]>
serhiy-storchaka added a commit that referenced this pull request Jul 15, 2021
@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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants