Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Duplicate Base Class for TypedDict #3673

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions