[issue43006] Changed behaviour of inspect.signature() in Python 3.10

2021-05-03 Thread Zac Hatfield-Dodds
Zac Hatfield-Dodds added the comment: I think that with PEP-563 reverted, this issue has been fixed. If we have a similar problem from e.g. PEP-649, I'll open another ticket then! -- resolution: -> fixed stage: -> resolved status: open -> closed

[issue43006] Changed behaviour of inspect.signature() in Python 3.10

2021-01-29 Thread jack1142
Change by jack1142 : -- nosy: +jack1142 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.o

[issue43006] Changed behaviour of inspect.signature() in Python 3.10

2021-01-23 Thread Guido van Rossum
Guido van Rossum added the comment: Note that this may be solved in a different way *if* PEP 649 is accepted. This was discussed extensively on python-dev last week. It would roll back the stringification of PEP 563 (unless `from __future__ import annotations` is used, which would be depreca

[issue43006] Changed behaviour of inspect.signature() in Python 3.10

2021-01-23 Thread Ken Jin
Ken Jin added the comment: For anyone interested, I went to do some digging on the 3 issues Zac listed: 1. Similar to the first message, this is caused by inspect.getfullarg/signature using get_type_hints in Py 3.10. get_type_hints internally converts None to NoneType. 2. I don't know what'

[issue43006] Changed behaviour of inspect.signature() in Python 3.10

2021-01-23 Thread Zac Hatfield-Dodds
Zac Hatfield-Dodds added the comment: And I promise this is the last one: import inspect import typing def f(): A = typing.TypeVar("A") def same_type_args(a: A, b: A): assert type(a) == type(b) print(inspect.signature(same_type_args))

[issue43006] Changed behaviour of inspect.signature() in Python 3.10

2021-01-23 Thread Zac Hatfield-Dodds
Zac Hatfield-Dodds added the comment: Aaaand it looks like another problem I'm having is also related: import inspect class T(typing.TypedDict): a: int print(inspect.signature(T)) was `(*args, **kwargs)` and now raises `ValueError: no signature found for builtin type `

[issue43006] Changed behaviour of inspect.signature() in Python 3.10

2021-01-23 Thread Zac Hatfield-Dodds
Zac Hatfield-Dodds added the comment: A closely related problem, also via https://github.com/HypothesisWorks/hypothesis/issues/2767 import inspect def f(x) -> None: pass annotations = inspect.getfullargspec(f).annotations assert annotations == {"return": None}, anno

[issue43006] Changed behaviour of inspect.signature() in Python 3.10

2021-01-23 Thread Ken Jin
Ken Jin added the comment: > 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. Spot on about PEP 563 becoming the default being the culpri

[issue43006] Changed behaviour of inspect.signature() in Python 3.10

2021-01-22 Thread Zac Hatfield-Dodds
New submission from Zac Hatfield-Dodds : 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 B