Why inspect.signature cannot show specific parameters of __init__ of classes which inherit Generic?

Viewed 16

I have such code:

from inspect import signature
from typing import  TypeVar, Generic
T = TypeVar('T', covariant=True)


class Plant():
    def __init__(self, a, b) -> None:
        super().__init__()
        self.a = a
        self.b = b


class Zomble(Generic[T]):
    def __init__(self, a, b) -> None:
        super().__init__()
        self.a = a
        self.b = b


cc = signature(Plant)
print(cc)
dd = signature(Zomble[int])
print(dd)

For cc, I get the output (a, b) -> None while dd get (*args, **kwargs) instead of the same of cc. What's the difference between the two classes? And is there any way to get the method parameters of classes inherit Generic?

0 Answers
Related