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.
Consider the following code:
Notice that the
Movieclass inheritsMovieBasetwice.mypy gives the following errors:
while there's no runtime error.
Note that if
MovieBasewas not aTypedDict, there would be a runtime TypeError:duplicate base class MovieBaseI think the right thing here would be to report duplicate base class.