chiark / gitweb /
documentation/python: fix annotation extracting for typing.Any on 3.11+.
authorVladimír Vondruš <mosra@centrum.cz>
Sat, 14 Sep 2024 22:34:43 +0000 (00:34 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Sat, 14 Sep 2024 23:48:41 +0000 (01:48 +0200)
documentation/python.py

index 7c54232247329fe985483067135f878692051e0b..432a318263699dc084ef2c4bc13376b284eb1082 100755 (executable)
@@ -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