You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This will result in NameError: name 'Foo' is not defined because _get_signature_object in unittest.mock calls inspect.signature without explicitly passing annotation_format, so it defaults to Format.VALUE.
Since create_autospec really shouldn't care whether or not the annotations can be evaluated at runtime on the given object, I would suggest switching over to Format.FORWARDREF or Format.STRING, so autospeccing continues to work in Python 3.14+ for people that used to rely on from __future__ import annotations and now want to switch to PEP 649 semantics, without needing to change their code.
Bug report
Bug description:
This will result in
NameError: name 'Foo' is not definedbecause_get_signature_objectinunittest.mockcallsinspect.signaturewithout explicitly passingannotation_format, so it defaults toFormat.VALUE.Since
create_autospecreally shouldn't care whether or not the annotations can be evaluated at runtime on the given object, I would suggest switching over toFormat.FORWARDREForFormat.STRING, so autospeccing continues to work in Python 3.14+ for people that used to rely onfrom __future__ import annotationsand now want to switch to PEP 649 semantics, without needing to change their code.CPython versions tested on:
3.14
Operating systems tested on:
Linux
Linked PRs