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 The Compiler, eric.smith, gvanrossum, kj, levkivskyi
Date 2021-03-15.17:28:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1615829333.49.0.966713819377.issue43463@roundup.psfhosted.org>
In-reply-to
Content
@Florian,

IIUC inspect.signature auto-resolves string annotations to typing.ForwardRef internally from 3.10 onwards. It's mentioned in the what's new for PEP 563 https://docs.python.org/3.10/whatsnew/3.10.html#pep-563-postponed-evaluation-of-annotations-becomes-default

If it fails, it will just give the string. So the only place where inspect.signature might start giving you different output is if you previously defined a function like so:

def foo(a: 'MyType'): ...

And you expected inspect.signature.paramters to be ``[<Parameter "a: 'MyType'">]`` (the string). However if MyType is in globals()/locals(), you'll instead get ``[<Parameter "a: MyType">]`` in 3.10.

FWIW someone already reported that in Issue43355.
History
Date User Action Args
2021-03-15 17:28:53kjsetrecipients: + kj, gvanrossum, eric.smith, The Compiler, levkivskyi
2021-03-15 17:28:53kjsetmessageid: <1615829333.49.0.966713819377.issue43463@roundup.psfhosted.org>
2021-03-15 17:28:53kjlinkissue43463 messages
2021-03-15 17:28:53kjcreate