KEMBAR78
Do not allow `TypedDict` classes with extra keywords by sobolevn · Pull Request #16438 · python/mypy · GitHub
Skip to content

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Nov 9, 2023

I think that sometimes metaclass= can still be used in real code, when people write compatibility layers with other metaclasses. I think that I've seen this a couple of times, but I cannot remember where and why.

In this case, this error can be precisely silenced.

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@sobolevn
Copy link
Member Author

I realized that I want to reuse existing messages:

» mypy -c 'class A(a=1, b=2): ...'
<string>:1: error: Unexpected keyword argument "a" for "__init_subclass__" of "object"  [call-arg]
<string>:1: error: Unexpected keyword argument "b" for "__init_subclass__" of "object"  [call-arg]
Found 2 errors in 1 file (checked 1 source file)

@sobolevn sobolevn changed the title Do not allow TypedDict classes with metaclass= Do not allow TypedDict classes with extra keywords Nov 17, 2023
@github-actions
Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

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.

3 participants