From: Vladimír Vondruš Date: Mon, 25 Nov 2019 16:59:25 +0000 (+0100) Subject: documentation/python: attempt to reproduce a Py3.6-specific issue. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=298df1e5ba873bfbb67cdd17e723547f56c891df;p=blog.git documentation/python: attempt to reproduce a Py3.6-specific issue. --- diff --git a/documentation/test_python/inspect_annotations/inspect_annotations.html b/documentation/test_python/inspect_annotations/inspect_annotations.html index 70c0960a..50603d27 100644 --- a/documentation/test_python/inspect_annotations/inspect_annotations.html +++ b/documentation/test_python/inspect_annotations/inspect_annotations.html @@ -39,6 +39,8 @@

Classes

+
class AContainer
+
A generic class. No parent class info extracted yet.
class Foo
A class with properties
class FooSlots
diff --git a/documentation/test_python/inspect_annotations/inspect_annotations.py b/documentation/test_python/inspect_annotations/inspect_annotations.py index e4b65973..7ef97fc9 100644 --- a/documentation/test_python/inspect_annotations/inspect_annotations.py +++ b/documentation/test_python/inspect_annotations/inspect_annotations.py @@ -2,7 +2,7 @@ import sys -from typing import List, Tuple, Dict, Any, Union, Optional, Callable, TypeVar +from typing import List, Tuple, Dict, Any, Union, Optional, Callable, TypeVar, Generic class Foo: """A class with properties""" @@ -19,6 +19,12 @@ class FooSlots: annotated: List[str] +_T = TypeVar('Tp') + +# Triggers a corner case with _gorg on Py3.6 +class AContainer(Generic[_T]): + """A generic class. No parent class info extracted yet.""" + def annotation(param: List[int], another: bool, third: str = "hello") -> float: """An annotated function""" pass @@ -55,8 +61,6 @@ def annotation_list_noparam(a: List): if sys.version_info < (3, 7): annotation_list_noparam.__annotations__['a'] = List[TypeVar('T')] -_T = TypeVar('Tp') - def annotation_generic(a: List[_T]) -> _T: """Annotation with a generic type"""