Message385524
Consider the following snippet, which passes on Python 3.9 and earlier:
import inspect
def f(x: int = None):
pass
print(inspect.signature(constructor))
assert inspect.signature(constructor).parameters["a"].annotation == int
But under Python 3.10 (alpha 4), the annotation is instead read as Optional[int]. This is correct for typing.get_type_hints(), but *not* for inspect.signature().
I therefore suspect that this is an accidental side-effect from support for PEP-563 deferred evaluation of annotations. |
|
Date |
User |
Action |
Args |
2021-01-23 06:24:23 | Zac Hatfield-Dodds | set | recipients:
+ Zac Hatfield-Dodds |
2021-01-23 06:24:23 | Zac Hatfield-Dodds | set | messageid: <1611383063.08.0.672499153283.issue43006@roundup.psfhosted.org> |
2021-01-23 06:24:22 | Zac Hatfield-Dodds | link | issue43006 messages |
2021-01-23 06:24:22 | Zac Hatfield-Dodds | create | |
|