I know this has been asked before and I feel like this shouldn’t be an issue, yet (to me) it is, so I need to ask.
Consider the following:
class Point2D:
def __init__(self, x: int, y: int):
self.x = x
self.y = y
class Point3D(Point2D):
def __init__(self, z: int, *args, **kwargs):
self.z = z
super().__init__(*args, **kwargs)
Clearly Point3D.__init__
is mostly a proxy for Point2D.__init__
.
My questions are:
-
how can I properly exert control over parameter order in
Point3D.__init__
, I want z to be the last parameter. -
how to type the signature of
Point3D.__init__
so that it mirrors the type hints inPoint2D.__init__
‘s signature?
I know I can use typing.Unpack
and typing.TypedDict
for typing *kwargs (and I think typing.NamedTuple
for *args), but one of the problems is that all *args could also be passed as **kwargs, so how to deal with that possibility?
One option of course would be to use typing.Unpack
with typing.TypedDict
and disallow *args all together.