Skip to content

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

Closed
@lillekemiker

Description

@lillekemiker

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions