From: Vladimír Vondruš Date: Sat, 14 Sep 2024 22:34:43 +0000 (+0200) Subject: documentation/python: fix annotation extracting for typing.Any on 3.11+. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=1be12345e2f6331c4f527287ddc580b03f743a70;p=blog.git documentation/python: fix annotation extracting for typing.Any on 3.11+. --- diff --git a/documentation/python.py b/documentation/python.py index 7c542322..432a3182 100755 --- a/documentation/python.py +++ b/documentation/python.py @@ -1278,8 +1278,9 @@ def extract_annotation(state: State, referrer_path: List[str], annotation) -> Tu elif sys.version_info < (3, 7) and hasattr(annotation, '__name__'): name = 'typing.' + annotation.__name__ args = annotation.__args__ - # Any doesn't have __name__ in 3.6 - elif sys.version_info < (3, 7) and annotation is typing.Any: + # Any doesn't have __name__ in 3.6, and doesn't have anything in 3.11+ + # Not sure what commit caused that, probably https://github.com/python/cpython/pull/31841 + elif (sys.version_info < (3, 7) or sys.version_info >= (3, 11)) and annotation is typing.Any: name = 'typing.Any' args = None # Whoops, something we don't know yet. Warn and return a string