[3.14] gh-145754: Update signature retrieval in unittest.mock to use forwardref annotation format (GH-145756) by miss-islington · Pull Request #146191 · python/cpython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Lib/test/test_unittest/testmock/testmock.py
3 changes: 2 additions & 1 deletion Lib/unittest/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import pkgutil
from inspect import iscoroutinefunction
import threading
from annotationlib import Format
from dataclasses import fields, is_dataclass
from types import CodeType, ModuleType, MethodType
from unittest.util import safe_repr
Expand Down Expand Up @@ -119,7 +120,7 @@ def _get_signature_object(func, as_instance, eat_self):
else:
sig_func = func
try:
return func, inspect.signature(sig_func)
return func, inspect.signature(sig_func, annotation_format=Format.FORWARDREF)
except ValueError:
# Certain callable types are not supported by inspect.signature()
return None
Expand Down
Loading