chiark / gitweb /
documentation/python: improve the Py3.6-specific _gorg workaround.
authorVladimír Vondruš <mosra@centrum.cz>
Mon, 11 May 2020 09:58:15 +0000 (11:58 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Mon, 11 May 2020 10:08:47 +0000 (12:08 +0200)
This should fix the assert reproduced by the previous commit, though the
__next_in_mro__ still needs to be ignored.

documentation/python.py

index 57ad47bb63c4c39a29dc5d9e0543a20c5d3dd747..d448bcea48b2fe7e02efa73960df2cbd09af7ec0 100755 (executable)
@@ -409,8 +409,11 @@ def crawl_class(state: State, path: List[str], class_):
             if name in ['__base__', '__class__']: continue # TODO
             # Classes derived from typing.Generic in 3.6 have a _gorg property
             # that causes a crawl cycle, firing an assert in crawl_class(). Not
-            # present from 3.7 onwards.
-            if sys.version_info < (3, 7) and class_.__base__ is typing.Generic and name == '_gorg': continue
+            # present from 3.7 onwards. Can't use isinstance(object, Generic)
+            # because "Class typing.Generic cannot be used with class or
+            # instance checks" (ugh), object.__base__ == Generic is also not
+            # enough because it fails for typing.Iterator.__base__.
+            if sys.version_info < (3, 7) and name == '_gorg' and type(object) == typing.GenericMeta: continue
             if is_underscored_and_undocumented(state, type_, subpath, object.__doc__): continue
 
             crawl_class(state, subpath, object)