mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Respond to feedback
This commit is contained in:
@@ -312,7 +312,8 @@ def stringify(annotation: Any) -> str:
|
||||
hasattr(annotation, '__qualname__')):
|
||||
if hasattr(annotation, '__args__'): # PEP 585 generic
|
||||
return repr(annotation)
|
||||
return annotation.__qualname__
|
||||
else:
|
||||
return annotation.__qualname__
|
||||
elif annotation is Ellipsis:
|
||||
return '...'
|
||||
|
||||
|
||||
@@ -175,6 +175,18 @@ def test_stringify_type_hints_containers():
|
||||
assert stringify(Generator[None, None, None]) == "Generator[None, None, None]"
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.version_info < (3, 9), reason='python 3.9+ is required.')
|
||||
def test_stringify_type_hints_pep_585():
|
||||
assert stringify(list[int]) == "list[int]"
|
||||
assert stringify(list[str]) == "list[str]"
|
||||
assert stringify(dict[str, float]) == "dict[str, float]"
|
||||
assert stringify(tuple[str, str, str]) == "tuple[str, str, str]"
|
||||
assert stringify(tuple[str, ...]) == "tuple[str, ...]"
|
||||
assert stringify(tuple[()]) == "tuple[()]"
|
||||
assert stringify(list[dict[str, tuple]]) == "list[dict[str, tuple]]"
|
||||
assert stringify(type[int]) == "type[int]"
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.version_info < (3, 9), reason='python 3.9+ is required.')
|
||||
def test_stringify_Annotated():
|
||||
from typing import Annotated # type: ignore
|
||||
|
||||
Reference in New Issue
Block a user