This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ezyang
Recipients ezyang
Date 2020-06-07.03:37:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1591501058.45.0.282415808867.issue40897@roundup.psfhosted.org>
In-reply-to
Content
Consider the following program:

```
import inspect
from typing import Generic, TypeVar

T = TypeVar('T')

class A(Generic[T]):
    def __init__(self) -> None:
        pass

print(inspect.signature(A))
```

I expect inspect.signature to return () as the signature of the constructor of this function. However, I get this:

```
$ python3 foo.py
(*args, **kwds)
```

Although it is true that one cannot generally rely on inspect.signature to always give the most accurate signature (because there may always be decorator or metaclass shenanigans getting in the way), in this particular case it seems especially undesirable because Python type annotations are supposed to be erased at runtime, and yet here inheriting from Generic (simply to add type annotations) causes a very clear change in runtime behavior.
History
Date User Action Args
2020-06-07 03:37:38ezyangsetrecipients: + ezyang
2020-06-07 03:37:38ezyangsetmessageid: <1591501058.45.0.282415808867.issue40897@roundup.psfhosted.org>
2020-06-07 03:37:38ezyanglinkissue40897 messages
2020-06-07 03:37:38ezyangcreate