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

typing.TypedDict: unnecessary hasattr check #109543

Closed
JelleZijlstra opened this issue Sep 18, 2023 · 1 comment
Closed

typing.TypedDict: unnecessary hasattr check #109543

JelleZijlstra opened this issue Sep 18, 2023 · 1 comment
Assignees

Comments

@JelleZijlstra
Copy link
Member

JelleZijlstra commented Sep 18, 2023

These lines:

https://github.com/python/cpython/blob/412f5e85d6b9f2e90c57c54539d06c7a025a472a/Lib/typing.py#L2889-2890

        if not hasattr(tp_dict, '__total__'):
            tp_dict.__total__ = total

go out of their way to account for the case there a TypedDict already has a __total__ attribute. But I don't think there is any way for the TypedDict to have that attribute at this point. For clarity, we should remove the check.

Linked PRs

@JelleZijlstra JelleZijlstra self-assigned this Sep 18, 2023
JelleZijlstra added a commit to JelleZijlstra/cpython that referenced this issue Sep 18, 2023
Also added a new test case covering the scenario I thought this
might be about.
JelleZijlstra added a commit that referenced this issue Sep 20, 2023
Also added a new test case covering the scenario I thought this
might be about.
@hauntsaninja
Copy link
Contributor

Looks like we can close this out!

csm10495 pushed a commit to csm10495/cpython that referenced this issue Sep 28, 2023
Also added a new test case covering the scenario I thought this
might be about.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants