is there an extension for VS Code that makes it so that, instead of just showing the first parents' arguments etc. in super() method tooltips, it shows the union of all parents' arguments?
class A:
def __init__(self, a_kwarg: int = 2, **kwargs):
...
class B:
def __init__(self, b_kwarg: float = 0.0, **kwargs):
...
class AB(A, B):
def __init__(self, **kwargs):
super().__init__( # <-- tooltip shows 'a_kwarg' only, not b_kwarg
The signature for
super().__init__is(self, a_kwarg, **kwargs), asAis first in the MRO. Why would an extension show anything but the correct signature?because the kwargs are passed to all ancestor classes in the MRO? otherwise there would be no way to specify the value for the 'b_kwarg' argument in B.__init__. the usefulness of an extension like this would be that one doesn't need to manually refer to B's script to check the naming of its different arguments when writing AB.__init__'s body.
i imagine there must be some reason this would not be strictly correct in all cases, but it seems like an obvious extension / capability to have since i frequently run into this issue of having to manually check that im spelling a kwarg correctly etc.
You seem to have some misunderstanding about how
superworks, kn the context of multiple inheritance. Arguments do not automatically get passed to other classes in the hierarchy.I recommend giving this article a read: https://rhettinger.wordpress.com/2011/05/26/super-considered-super/
What
A.__init__does with the passed**kwargsis hard for an extension to figure out. It might pass them to a parent, it might not. It might pass some; it might do so extremely dynamically in a way that’s hard to trace for a static analyzer. You are only directly passing to the next higher ancestor, whatever happens afterwards is up to it.