Skip to content

Duplicate Base Class for TypedDict #3673

@ilinum

Description

@ilinum

Consider the following code:

from mypy_extensions import TypedDict

class MovieBase(TypedDict):
    name: str
    year: int


class Movie(MovieBase, MovieBase):
    based_on: str

Notice that the Movie class inherits MovieBase twice.

mypy gives the following errors:

n.py:8: error: Cannot overwrite TypedDict field "name" while merging
n.py:8: error: Cannot overwrite TypedDict field "year" while merging

while there's no runtime error.

Note that if MovieBase was not a TypedDict, there would be a runtime TypeError: duplicate base class MovieBase

I think the right thing here would be to report duplicate base class.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions