# 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