You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I appreciate there are some complexities around handling inheritance from dynamic sources, so it's possible that this is a duplicate of one of those (#4284 seems most likely related), though I think this is a slightly different case.
I would like the following to pass type checking, yet I get an "Invalid base class" error even after adding an explicit type annotation.
Because in this case the tuple is of a fixed size (and the members of the tuple are all valid types) it feels like it should be possible to determine that it's valid to inherit from an expansion of that tuple.
# foo.pyfromtypingimportTuple, TypeclassA: passclassB: passPlainBases= (A, B)
reveal_type(PlainBases)
# ^ Revealed type is 'Tuple[def () -> foo.A, def () -> foo.B]'classPlainC(*PlainBases):
# ^ Invalid base classpassAnotatedBases= (A, B) # type: Tuple[Type[A], Type[B]]reveal_type(AnotatedBases)
# ^ Revealed type is 'Tuple[Type[foo.A], Type[foo.B]]'classAnotatedC(*AnotatedBases):
# ^ Invalid base classpass
I'm using Python 3.5 and mypy 0.620. Having just updated to 0.641 I see that there are now also errors that "Can use starred expression only as assignment target" in the above, which goes some way to explaining why this is currently unsupported, though leads to another one (apologies if this is documented somewhere):
Why is it that mypy is unable to expand the types of this starred expression?
Is this a result of the issue relating to multiple passes which is mentioned in #4284 (comment) or something else?
Is this something which is possible/likely to be supported?
The text was updated successfully, but these errors were encountered:
Currently we already have three other issues about dynamic base classes, but I am not sure which should be closed because all them have some discussion and some examples.
As another random idea we can potentially support this is the base class tuple is declared as Final.
I appreciate there are some complexities around handling inheritance from dynamic sources, so it's possible that this is a duplicate of one of those (#4284 seems most likely related), though I think this is a slightly different case.
I would like the following to pass type checking, yet I get an "Invalid base class" error even after adding an explicit type annotation.
Because in this case the tuple is of a fixed size (and the members of the tuple are all valid types) it feels like it should be possible to determine that it's valid to inherit from an expansion of that tuple.
I'm using Python 3.5 and
mypy
0.620. Having just updated to 0.641 I see that there are now also errors that "Can use starred expression only as assignment target" in the above, which goes some way to explaining why this is currently unsupported, though leads to another one (apologies if this is documented somewhere):Why is it that
mypy
is unable to expand the types of this starred expression?Is this a result of the issue relating to multiple passes which is mentioned in #4284 (comment) or something else?
Is this something which is possible/likely to be supported?
The text was updated successfully, but these errors were encountered: