mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
test: Adjust type annotataions in python 3.10
This commit is contained in:
parent
a3c8768afd
commit
1b9099f339
@ -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:
|
||||
|
@ -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):
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user