Message370870
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. |
|
Date |
User |
Action |
Args |
2020-06-07 03:37:38 | ezyang | set | recipients:
+ ezyang |
2020-06-07 03:37:38 | ezyang | set | messageid: <1591501058.45.0.282415808867.issue40897@roundup.psfhosted.org> |
2020-06-07 03:37:38 | ezyang | link | issue40897 messages |
2020-06-07 03:37:38 | ezyang | create | |
|