mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
[lint] shrink mypy whitelist (#11898)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This commit is contained in:
parent
8aa5edd585
commit
adde256893
@ -194,7 +194,6 @@ module = [
|
||||
"sphinx.highlighting",
|
||||
"sphinx.jinja2glue",
|
||||
"sphinx.registry",
|
||||
"sphinx.roles",
|
||||
"sphinx.search",
|
||||
"sphinx.testing.fixtures",
|
||||
"sphinx.testing.path",
|
||||
@ -203,12 +202,9 @@ module = [
|
||||
"sphinx.util.display",
|
||||
"sphinx.util.docfields",
|
||||
"sphinx.util.docutils",
|
||||
"sphinx.util.fileutil",
|
||||
"sphinx.util.i18n",
|
||||
"sphinx.util.inspect",
|
||||
"sphinx.util.inventory",
|
||||
"sphinx.util.logging",
|
||||
"sphinx.util.nodes",
|
||||
"sphinx.util.parallel",
|
||||
"sphinx.util.template",
|
||||
]
|
||||
|
@ -389,7 +389,7 @@ class Manpage(ReferenceRole):
|
||||
# TODO: Change to use `SphinxRole` once SphinxRole is fixed to support options.
|
||||
def code_role(name: str, rawtext: str, text: str, lineno: int,
|
||||
inliner: docutils.parsers.rst.states.Inliner,
|
||||
options: dict | None = None, content: Sequence[str] = (),
|
||||
options: dict[str, Any] | None = None, content: Sequence[str] = (),
|
||||
) -> tuple[list[Node], list[system_message]]:
|
||||
if options is None:
|
||||
options = {}
|
||||
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
||||
|
||||
import os
|
||||
import posixpath
|
||||
from typing import TYPE_CHECKING, Callable
|
||||
from typing import TYPE_CHECKING, Any, Callable
|
||||
|
||||
from docutils.utils import relative_path
|
||||
|
||||
@ -16,7 +16,7 @@ if TYPE_CHECKING:
|
||||
|
||||
|
||||
def copy_asset_file(source: str | os.PathLike[str], destination: str | os.PathLike[str],
|
||||
context: dict | None = None,
|
||||
context: dict[str, Any] | None = None,
|
||||
renderer: BaseRenderer | None = None) -> None:
|
||||
"""Copy an asset file to destination.
|
||||
|
||||
@ -53,7 +53,7 @@ def copy_asset_file(source: str | os.PathLike[str], destination: str | os.PathLi
|
||||
|
||||
def copy_asset(source: str | os.PathLike[str], destination: str | os.PathLike[str],
|
||||
excluded: PathMatcher = lambda path: False,
|
||||
context: dict | None = None, renderer: BaseRenderer | None = None,
|
||||
context: dict[str, Any] | None = None, renderer: BaseRenderer | None = None,
|
||||
onerror: Callable[[str, Exception], None] | None = None) -> None:
|
||||
"""Copy asset files to destination recursively.
|
||||
|
||||
|
@ -53,7 +53,7 @@ def unwrap(obj: Any) -> Any:
|
||||
return obj
|
||||
|
||||
|
||||
def unwrap_all(obj: Any, *, stop: Callable | None = None) -> Any:
|
||||
def unwrap_all(obj: Any, *, stop: Callable[[Any], bool] | None = None) -> Any:
|
||||
"""
|
||||
Get an original object from wrapped object (unwrapping partials, wrapped
|
||||
functions, and other decorators).
|
||||
@ -352,7 +352,7 @@ def safe_getattr(obj: Any, name: str, *defargs: Any) -> Any:
|
||||
raise AttributeError(name) from exc
|
||||
|
||||
|
||||
def object_description(obj: Any, *, _seen: frozenset = frozenset()) -> str:
|
||||
def object_description(obj: Any, *, _seen: frozenset[int] = frozenset()) -> str:
|
||||
"""A repr() implementation that returns text safe to use in reST context.
|
||||
|
||||
Maintains a set of 'seen' object IDs to detect and avoid infinite recursion.
|
||||
@ -546,7 +546,8 @@ def _should_unwrap(subject: Callable) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def signature(subject: Callable, bound_method: bool = False, type_aliases: dict | None = None,
|
||||
def signature(
|
||||
subject: Callable, bound_method: bool = False, type_aliases: dict[str, str] | None = None,
|
||||
) -> inspect.Signature:
|
||||
"""Return a Signature object for the given *subject*.
|
||||
|
||||
@ -604,15 +605,19 @@ def signature(subject: Callable, bound_method: bool = False, type_aliases: dict
|
||||
__validate_parameters__=False)
|
||||
|
||||
|
||||
def evaluate_signature(sig: inspect.Signature, globalns: dict | None = None,
|
||||
localns: dict | None = None,
|
||||
def evaluate_signature(sig: inspect.Signature, globalns: dict[str, Any] | None = None,
|
||||
localns: dict[str, Any] | None = None,
|
||||
) -> inspect.Signature:
|
||||
"""Evaluate unresolved type annotations in a signature object."""
|
||||
def evaluate_forwardref(ref: ForwardRef, globalns: dict, localns: dict) -> Any:
|
||||
def evaluate_forwardref(
|
||||
ref: ForwardRef, globalns: dict[str, Any] | None, localns: dict[str, Any] | None,
|
||||
) -> Any:
|
||||
"""Evaluate a forward reference."""
|
||||
return ref._evaluate(globalns, localns, frozenset())
|
||||
|
||||
def evaluate(annotation: Any, globalns: dict, localns: dict) -> Any:
|
||||
def evaluate(
|
||||
annotation: Any, globalns: dict[str, Any], localns: dict[str, Any],
|
||||
) -> Any:
|
||||
"""Evaluate unresolved type annotation."""
|
||||
try:
|
||||
if isinstance(annotation, str):
|
||||
@ -799,7 +804,9 @@ def getdoc(
|
||||
* inherited docstring
|
||||
* inherited decorated methods
|
||||
"""
|
||||
def getdoc_internal(obj: Any, attrgetter: Callable = safe_getattr) -> str | None:
|
||||
def getdoc_internal(
|
||||
obj: Any, attrgetter: Callable[[Any, str, Any], Any] = safe_getattr,
|
||||
) -> str | None:
|
||||
doc = attrgetter(obj, '__doc__', None)
|
||||
if isinstance(doc, str):
|
||||
return doc
|
||||
|
@ -25,7 +25,7 @@ class InventoryFileReader:
|
||||
This reader supports mixture of texts and compressed texts.
|
||||
"""
|
||||
|
||||
def __init__(self, stream: IO) -> None:
|
||||
def __init__(self, stream: IO[bytes]) -> None:
|
||||
self.stream = stream
|
||||
self.buffer = b''
|
||||
self.eof = False
|
||||
@ -77,7 +77,12 @@ class InventoryFileReader:
|
||||
|
||||
class InventoryFile:
|
||||
@classmethod
|
||||
def load(cls: type[InventoryFile], stream: IO, uri: str, joinfunc: Callable) -> Inventory:
|
||||
def load(
|
||||
cls: type[InventoryFile],
|
||||
stream: IO[bytes],
|
||||
uri: str,
|
||||
joinfunc: Callable[[str, str], str],
|
||||
) -> Inventory:
|
||||
reader = InventoryFileReader(stream)
|
||||
line = reader.readline().rstrip()
|
||||
if line == '# Sphinx inventory version 1':
|
||||
@ -89,7 +94,10 @@ class InventoryFile:
|
||||
|
||||
@classmethod
|
||||
def load_v1(
|
||||
cls: type[InventoryFile], stream: InventoryFileReader, uri: str, join: Callable,
|
||||
cls: type[InventoryFile],
|
||||
stream: InventoryFileReader,
|
||||
uri: str,
|
||||
join: Callable[[str, str], str],
|
||||
) -> Inventory:
|
||||
invdata: Inventory = {}
|
||||
projname = stream.readline().rstrip()[11:]
|
||||
@ -109,7 +117,10 @@ class InventoryFile:
|
||||
|
||||
@classmethod
|
||||
def load_v2(
|
||||
cls: type[InventoryFile], stream: InventoryFileReader, uri: str, join: Callable,
|
||||
cls: type[InventoryFile],
|
||||
stream: InventoryFileReader,
|
||||
uri: str,
|
||||
join: Callable[[str, str], str],
|
||||
) -> Inventory:
|
||||
invdata: Inventory = {}
|
||||
projname = stream.readline().rstrip()[11:]
|
||||
|
@ -402,8 +402,13 @@ def process_index_entry(entry: str, targetid: str,
|
||||
return indexentries
|
||||
|
||||
|
||||
def inline_all_toctrees(builder: Builder, docnameset: set[str], docname: str,
|
||||
tree: nodes.document, colorfunc: Callable, traversed: list[str],
|
||||
def inline_all_toctrees(
|
||||
builder: Builder,
|
||||
docnameset: set[str],
|
||||
docname: str,
|
||||
tree: nodes.document,
|
||||
colorfunc: Callable[[str], str],
|
||||
traversed: list[str],
|
||||
) -> nodes.document:
|
||||
"""Inline all toctrees in the *tree*.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user