From 97c0cb2091e7bd79c63ff884749f16038ffc6939 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 15 Sep 2024 00:11:23 +0200 Subject: [PATCH] documentation/python: adapt builtin method filters to changes in 3.11+. --- documentation/python.py | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/documentation/python.py b/documentation/python.py index 122f5ef0..7c542322 100755 --- a/documentation/python.py +++ b/documentation/python.py @@ -495,10 +495,30 @@ def crawl_class(state: State, path: List[str], class_): # are added by typing.Generic on Py3.7+. Like above, can't # use isinstance(object, Generic) because "Class # typing.Generic cannot be used with class or instance - # checks" and there's nothing else to catch on, so this - # filters out all undocumented cases of these two - if sys.version_info >= (3, 7) and name in ['__init_subclass__', '__class_getitem__'] and not object.__doc__: - continue + # checks" + if sys.version_info >= (3, 7) and name == '__init_subclass__': + # Before 3.12 it's completely undocumented and there's + # nothing else to catch on, so this filters out all + # undocumented cases + if sys.version_info < (3, 12) and not object.__doc__: + continue + # https://github.com/python/cpython/blame/401fff7423ca3c8bf1d02e594edfd1412616a559/Objects/typevarobject.c#L2175 + if object.__doc__ == "Function to initialize subclasses.": + continue + if sys.version_info >= (3, 7) and name == '__class_getitem__': + # Before 3.11 it's completely undocumented and there's + # nothing else to catch on, so this filters out all + # undocumented cases + if sys.version_info < (3, 11) and not object.__doc__: + continue + # In 3.11 they OTOH get something very unique, + # especially the markdown-like formatting + # https://github.com/python/cpython/pull/31021 + # In 3.12 the extra spaces are removed + if sys.version_info >= (3, 12) and object.__doc__.startswith("Parameterizes a generic class.\n\nAt least, parameterizing a generic class is the *main* thing"): + continue + if sys.version_info >= (3, 11) and object.__doc__.startswith("Parameterizes a generic class.\n\n At least, parameterizing a generic class is the *main* thing"): + continue # ... or are auto-generated by attrs if state.config['ATTRS_COMPATIBILITY']: # All methods generated by attrs 20.1+ have a generic -- 2.30.2