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 kj
Recipients BTaskaya, Zac Hatfield-Dodds, gvanrossum, kj
Date 2021-01-23.09:56:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1611395767.42.0.0631957479213.issue43006@roundup.psfhosted.org>
In-reply-to
Content
> 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 culprit!

The what's new for Python 3.10 states that inspect.signature will try to resolve types https://docs.python.org/3.10/whatsnew/3.10.html#pep-563-postponed-evaluation-of-annotations-becomes-default.

For annotations, inspect.signature internally calls get_type_hints: https://github.com/python/cpython/blob/master/Lib/inspect.py#L2194

A simple solution I can think of is to add a flag to get_type_hints to disable converting to Optional[int] for inspect.signature.

I nosied some people involved in issue38605 so that they can give their opinions on this.
History
Date User Action Args
2021-01-23 09:56:07kjsetrecipients: + kj, gvanrossum, Zac Hatfield-Dodds, BTaskaya
2021-01-23 09:56:07kjsetmessageid: <1611395767.42.0.0631957479213.issue43006@roundup.psfhosted.org>
2021-01-23 09:56:07kjlinkissue43006 messages
2021-01-23 09:56:07kjcreate