test: Adjust type annotataions in python 3.10

This commit is contained in:
Takeshi KOMIYA 2020-10-24 16:52:07 +09:00
parent a3c8768afd
commit 1b9099f339
3 changed files with 6 additions and 3 deletions

View File

@ -470,7 +470,7 @@ def signature(subject: Callable, bound_method: bool = False, follow_wrapped: boo
raise
try:
# Resolve forwared reference annotations using ``get_type_hints()`` and type_aliases.
# Resolve annotations using ``get_type_hints()`` and type_aliases.
annotations = typing.get_type_hints(subject, None, type_aliases)
for i, param in enumerate(parameters):
if param.name in annotations:

View File

@ -258,7 +258,7 @@ def stringify(annotation: Any) -> str:
if isinstance(annotation, str):
if annotation.startswith("'") and annotation.endswith("'"):
# might be a double Forward-ref'ed type. Go unquoting.
return annotation[1:-2]
return annotation[1:-1]
else:
return annotation
elif isinstance(annotation, TypeVar):

View File

@ -177,7 +177,10 @@ def test_signature_annotations():
# Instance annotations
sig = inspect.signature(f11)
assert stringify_signature(sig) == '(x: CustomAnnotation, y: 123) -> None'
if sys.version_info < (3, 10):
assert stringify_signature(sig) == '(x: CustomAnnotation, y: 123) -> None'
else:
assert stringify_signature(sig) == '(x: CustomAnnotation(), y: 123) -> None'
# tuple with more than two items
sig = inspect.signature(f12)