Skip to content

bpo-42059: Fixed required/optional keys with old-style TypedDict#22736

Merged
brandtbucher merged 3 commits into
python:masterfrom
agronholm:fix-issue-42059
Dec 10, 2020
Merged

bpo-42059: Fixed required/optional keys with old-style TypedDict#22736
brandtbucher merged 3 commits into
python:masterfrom
agronholm:fix-issue-42059

Conversation

@agronholm

@agronholm agronholm commented Oct 17, 2020

Copy link
Copy Markdown
Contributor

The TypedDict() function now passes the value of total as a metaclass argument instead of putting it directly in the attribute namespace.

https://bugs.python.org/issue42059

@brandtbucher brandtbucher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for your patience, and for taking the time to fix this @agronholm!

This looks good; I just have have some suggestions to clarify the NEWS entry a bit:

Comment thread Misc/NEWS.d/next/Library/2020-10-17-12-42-08.bpo-42059.ZGMZ3D.rst Outdated
@bedevere-bot

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@brandtbucher

Copy link
Copy Markdown
Member

Note to self: the 3.8 backport will need to be done manually, since TypedDict was refactored a bit in 3.9.

Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
@brandtbucher

Copy link
Copy Markdown
Member

Thanks!

@ambv, am I correct in assuming that the 3.8 backport should not be merged until 3.8.7 is released in ~2 weeks?

@brandtbucher brandtbucher merged commit 67b769f into python:master Dec 10, 2020
@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @agronholm for the PR, and @brandtbucher for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8, 3.9.
🐍🍒⛏🤖

@brandtbucher

Copy link
Copy Markdown
Member

Hm, looks like the bot is stuck. I'm going to try removing and re-adding the backport labels.

@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @agronholm for the PR, and @brandtbucher for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @agronholm for the PR, and @brandtbucher for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9.
🐍🍒⛏🤖

@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @agronholm for the PR, and @brandtbucher for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9.
🐍🍒⛏🤖

@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @agronholm for the PR, and @brandtbucher for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9.
🐍🍒⛏🤖

@bedevere-bot

Copy link
Copy Markdown

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 13, 2020
…pythonGH-22736)

(cherry picked from commit 67b769f)

Co-authored-by: Alex Grönholm <alex.gronholm@nextday.fi>
brandtbucher pushed a commit that referenced this pull request Dec 14, 2020
…GH-22736) (GH-23747)

(cherry picked from commit 67b769f)

Co-authored-by: Alex Grönholm <alex.gronholm@nextday.fi>
@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @agronholm for the PR, and @brandtbucher for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

@miss-islington

Copy link
Copy Markdown
Contributor

Sorry, @agronholm and @brandtbucher, I could not cleanly backport this to 3.8 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 67b769f5157c9dad1c7dd6b24e067b9fdab5b35d 3.8

@brandtbucher

Copy link
Copy Markdown
Member

🤦🏼 It looks like __required_keys__ and __optional_keys__ are new in 3.9, so no backport to 3.8 is needed.

RobertCraigie added a commit to RobertCraigie/prisma-client-py that referenced this pull request Nov 13, 2021
On Python 3.9.0 and Python 3.9.1, `typing.TypedDict` does not correctly hold the `__required_keys__` and `__optional_keys__` attributes, the fix (python/cpython#22736) for this issue was merged on 10/12/2020 and Python 3.9.1 was released on 8/12/2020, as such, the minimum Python version that does not require the use of `typing-extensions` is Python 3.9.2

However, writing our imports this way breaks mypy, reporting 1651 errors :)
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.

6 participants