From a797c7f88feb88841dff4e93e22b7af83db6f13f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 28 Sep 2024 02:15:01 +0200 Subject: [PATCH] documentation/python: expand annotation tests with string fallbacks. In both cases the actual annotation is left as a string. Those were so far tested only as part of inspect_type_links, but the behavior isn't limited to linking. --- .../inspect_annotations-py37+38.html | 10 +++++++--- .../inspect_annotations/inspect_annotations.html | 10 +++++++--- .../inspect_annotations/inspect_annotations.py | 7 +++++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/documentation/test_python/inspect_annotations/inspect_annotations-py37+38.html b/documentation/test_python/inspect_annotations/inspect_annotations-py37+38.html index c47f8b86..5e58b0b1 100644 --- a/documentation/test_python/inspect_annotations/inspect_annotations-py37+38.html +++ b/documentation/test_python/inspect_annotations/inspect_annotations-py37+38.html @@ -93,6 +93,10 @@ def annotation_generic(a: typing.List[Tp]) -> Tp
Annotation with a generic type
+
+ def annotation_invalid() -> Foo.Bar +
+
Annotation with an invalid annotation, which is kept as a string
def annotation_list_noparam(a: typing.List[T])
@@ -115,10 +119,10 @@ def annotation_union(a: typing.Union[float, int])
Annotation with the Union type
-
- def annotation_union_of_undefined(a: typing.Union[int, something.Undefined]) +
+ def annotation_union_of_forward_reference(a: typing.Union[int, something.Undefined])
-
Annotation with an union that has an undefined type inside, where we can't use isinstance either
+
Annotation with an union that has a forward reference inside, where we can't use isinstance either
def annotation_union_second_bracketed(a: typing.Union[float, typing.List[int]])
diff --git a/documentation/test_python/inspect_annotations/inspect_annotations.html b/documentation/test_python/inspect_annotations/inspect_annotations.html index b5b454c1..cc15e4b8 100644 --- a/documentation/test_python/inspect_annotations/inspect_annotations.html +++ b/documentation/test_python/inspect_annotations/inspect_annotations.html @@ -93,6 +93,10 @@ def annotation_generic(a: typing.List[Tp]) -> Tp
Annotation with a generic type
+
+ def annotation_invalid() -> Foo.Bar +
+
Annotation with an invalid annotation, which is kept as a string
def annotation_list_noparam(a: typing.List)
@@ -115,10 +119,10 @@ def annotation_union(a: typing.Union[float, int])
Annotation with the Union type
-
- def annotation_union_of_undefined(a: typing.Union[int, something.Undefined]) +
+ def annotation_union_of_forward_reference(a: typing.Union[int, something.Undefined])
-
Annotation with an union that has an undefined type inside, where we can't use isinstance either
+
Annotation with an union that has a forward reference inside, where we can't use isinstance either
def annotation_union_second_bracketed(a: typing.Union[float, typing.List[int]])
diff --git a/documentation/test_python/inspect_annotations/inspect_annotations.py b/documentation/test_python/inspect_annotations/inspect_annotations.py index a03d50b4..8a9c26a1 100644 --- a/documentation/test_python/inspect_annotations/inspect_annotations.py +++ b/documentation/test_python/inspect_annotations/inspect_annotations.py @@ -71,8 +71,11 @@ def annotation_optional(a: Optional[float]): def annotation_union_second_bracketed(a: Union[float, List[int]]): """Annotation with the Union type and second type bracketed, where we can't use isinstance""" -def annotation_union_of_undefined(a: Union[int, 'something.Undefined']): - """Annotation with an union that has an undefined type inside, where we can't use isinstance either""" +def annotation_union_of_forward_reference(a: Union[int, 'something.Undefined']): + """Annotation with an union that has a forward reference inside, where we can't use isinstance either""" + +def annotation_invalid() -> 'Foo.Bar': + """Annotation with an invalid annotation, which is kept as a string""" def annotation_list_noparam(a: List): """Annotation with the unparametrized List type. 3.7 and 3.8 adds an implicit TypeVar to it, 3.6, 3.9 and 3.10 not, so the output is different between the versions.""" -- 2.30.2