mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Remove `sphinx.ext.autodoc
` from the no-any-generics whitelist
This commit is contained in:
parent
6128f2b406
commit
14db5ffba1
@ -234,8 +234,6 @@ module = [
|
|||||||
"sphinx.domains",
|
"sphinx.domains",
|
||||||
"sphinx.domains.c",
|
"sphinx.domains.c",
|
||||||
"sphinx.domains.cpp",
|
"sphinx.domains.cpp",
|
||||||
"sphinx.ext.autodoc",
|
|
||||||
"sphinx.ext.autodoc.importer",
|
|
||||||
"sphinx.util.docfields",
|
"sphinx.util.docfields",
|
||||||
"sphinx.util.docutils",
|
"sphinx.util.docutils",
|
||||||
"sphinx.util.inspect",
|
"sphinx.util.inspect",
|
||||||
|
@ -167,7 +167,7 @@ def bool_option(arg: Any) -> bool:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def merge_members_option(options: dict) -> None:
|
def merge_members_option(options: dict[str, Any]) -> None:
|
||||||
"""Merge :private-members: and :special-members: options to the
|
"""Merge :private-members: and :special-members: options to the
|
||||||
:members: option.
|
:members: option.
|
||||||
"""
|
"""
|
||||||
@ -1553,7 +1553,9 @@ class FunctionDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # typ
|
|||||||
|
|
||||||
return overload.replace(parameters=parameters)
|
return overload.replace(parameters=parameters)
|
||||||
|
|
||||||
def annotate_to_first_argument(self, func: Callable, typ: type) -> Callable | None:
|
def annotate_to_first_argument(
|
||||||
|
self, func: Callable[..., Any], typ: type
|
||||||
|
) -> Callable[..., Any] | None:
|
||||||
"""Annotate type hint to the first argument of function if needed."""
|
"""Annotate type hint to the first argument of function if needed."""
|
||||||
try:
|
try:
|
||||||
sig = inspect.signature(func, type_aliases=self.config.autodoc_type_aliases)
|
sig = inspect.signature(func, type_aliases=self.config.autodoc_type_aliases)
|
||||||
@ -2538,7 +2540,9 @@ class MethodDocumenter(DocstringSignatureMixin, ClassLevelDocumenter): # type:
|
|||||||
|
|
||||||
return overload.replace(parameters=parameters)
|
return overload.replace(parameters=parameters)
|
||||||
|
|
||||||
def annotate_to_first_argument(self, func: Callable, typ: type) -> Callable | None:
|
def annotate_to_first_argument(
|
||||||
|
self, func: Callable[..., Any], typ: type
|
||||||
|
) -> Callable[..., Any] | None:
|
||||||
"""Annotate type hint to the first argument of function if needed."""
|
"""Annotate type hint to the first argument of function if needed."""
|
||||||
try:
|
try:
|
||||||
sig = inspect.signature(func, type_aliases=self.config.autodoc_type_aliases)
|
sig = inspect.signature(func, type_aliases=self.config.autodoc_type_aliases)
|
||||||
@ -3104,7 +3108,7 @@ class PropertyDocumenter(DocstringStripSignatureMixin, ClassLevelDocumenter): #
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _get_property_getter(self) -> Callable | None:
|
def _get_property_getter(self) -> Callable[..., Any] | None:
|
||||||
if safe_getattr(self.object, 'fget', None): # property
|
if safe_getattr(self.object, 'fget', None): # property
|
||||||
return self.object.fget
|
return self.object.fget
|
||||||
if safe_getattr(self.object, 'func', None): # cached_property
|
if safe_getattr(self.object, 'func', None): # cached_property
|
||||||
|
@ -30,19 +30,23 @@ from sphinx.util.inspect import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from collections.abc import Callable, Iterator, Mapping
|
from collections.abc import Iterator, Mapping
|
||||||
from types import ModuleType
|
from types import ModuleType
|
||||||
from typing import Any
|
from typing import Any, Protocol
|
||||||
|
|
||||||
from sphinx.ext.autodoc import ObjectMember
|
from sphinx.ext.autodoc import ObjectMember
|
||||||
|
|
||||||
|
class _AttrGetter(Protocol):
|
||||||
|
def __call__(self, obj: Any, name: str, default: Any = ..., /) -> Any: ...
|
||||||
|
|
||||||
|
|
||||||
_NATIVE_SUFFIXES: frozenset[str] = frozenset({'.pyx', *EXTENSION_SUFFIXES})
|
_NATIVE_SUFFIXES: frozenset[str] = frozenset({'.pyx', *EXTENSION_SUFFIXES})
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def _filter_enum_dict(
|
def _filter_enum_dict(
|
||||||
enum_class: type[Enum],
|
enum_class: type[Enum],
|
||||||
attrgetter: Callable[[Any, str, Any], Any],
|
attrgetter: _AttrGetter,
|
||||||
enum_class_dict: Mapping[str, object],
|
enum_class_dict: Mapping[str, object],
|
||||||
) -> Iterator[tuple[str, type, Any]]:
|
) -> Iterator[tuple[str, type, Any]]:
|
||||||
"""Find the attributes to document of an enumeration class.
|
"""Find the attributes to document of an enumeration class.
|
||||||
@ -241,7 +245,7 @@ def import_object(
|
|||||||
modname: str,
|
modname: str,
|
||||||
objpath: list[str],
|
objpath: list[str],
|
||||||
objtype: str = '',
|
objtype: str = '',
|
||||||
attrgetter: Callable[[Any, str], Any] = safe_getattr,
|
attrgetter: _AttrGetter = safe_getattr,
|
||||||
) -> Any:
|
) -> Any:
|
||||||
if objpath:
|
if objpath:
|
||||||
logger.debug('[autodoc] from %s import %s', modname, '.'.join(objpath))
|
logger.debug('[autodoc] from %s import %s', modname, '.'.join(objpath))
|
||||||
@ -330,7 +334,7 @@ class Attribute(NamedTuple):
|
|||||||
def get_object_members(
|
def get_object_members(
|
||||||
subject: Any,
|
subject: Any,
|
||||||
objpath: list[str],
|
objpath: list[str],
|
||||||
attrgetter: Callable,
|
attrgetter: _AttrGetter,
|
||||||
analyzer: ModuleAnalyzer | None = None,
|
analyzer: ModuleAnalyzer | None = None,
|
||||||
) -> dict[str, Attribute]:
|
) -> dict[str, Attribute]:
|
||||||
"""Get members and attributes of target object."""
|
"""Get members and attributes of target object."""
|
||||||
@ -403,7 +407,7 @@ def get_object_members(
|
|||||||
|
|
||||||
|
|
||||||
def get_class_members(
|
def get_class_members(
|
||||||
subject: Any, objpath: Any, attrgetter: Callable, inherit_docstrings: bool = True
|
subject: Any, objpath: Any, attrgetter: _AttrGetter, inherit_docstrings: bool = True
|
||||||
) -> dict[str, ObjectMember]:
|
) -> dict[str, ObjectMember]:
|
||||||
"""Get members and attributes of target class."""
|
"""Get members and attributes of target class."""
|
||||||
from sphinx.ext.autodoc import INSTANCEATTR, ObjectMember
|
from sphinx.ext.autodoc import INSTANCEATTR, ObjectMember
|
||||||
|
Loading…
Reference in New Issue
Block a user