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

TypedDict using keywords causes "error: Too many arguments for TypedDict()" #11555

Closed
lillekemiker opened this issue Nov 14, 2021 · 3 comments
Closed
Labels
bug mypy got something wrong topic-typed-dict

Comments

@lillekemiker
Copy link

Bug Report

In the typing docs for TypedDict there is an example of defining a TypedDict using keywords mapped to types

Point2D = TypedDict('Point2D', x=int, y=int, label=str)

When running mypy on this exact example, I get the following error:

type_test.py:4: error: Too many arguments for TypedDict()

If using the alternative definition with a positional dictionary, no error.

Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': str})

Link to docs:
https://docs.python.org/3/library/typing.html#typing.TypedDict

To Reproduce

  1. Create a file with the above code example and necessary imports
  2. Run mypy on file
  3. Observe error message

Expected Behavior

No error

Actual Behavior

Error.

Your Environment

  • Mypy version used: 0.812 and 0.910 tested
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): ignore_missing_imports=true
  • Python version used: 3.9.2
  • Operating system and version: macOS 11.6
@lillekemiker lillekemiker added the bug mypy got something wrong label Nov 14, 2021
@sobolevn
Copy link
Member

sobolevn commented Nov 18, 2021

Related #11206

I can work on it after #11206 will be finished. There would be a lot of similar constructs.

@97littleleaf11
Copy link
Collaborator

I opened an issue about this. https://bugs.python.org/issue46066.
I think this syntax is confusing since we have the total keyword.

@97littleleaf11
Copy link
Collaborator

#2492 (comment):

This doesn't seem feasible now that we have the total= keyword argument to TypedDict. Also, TypedDict is officially supported in Python and we want to avoid mypy-specific extensions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-typed-dict
Projects
None yet
Development

No branches or pull requests

4 participants