Shrink the mypy whitelist for `sphinx.util.display` (#12570)

Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
This commit is contained in:
danieleades 2024-07-15 05:34:43 +01:00 committed by GitHub
parent 313627e4f6
commit d5df528e8c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 7 deletions

View File

@ -264,7 +264,6 @@ module = [
"sphinx.registry",
"sphinx.search",
"sphinx.util",
"sphinx.util.display",
"sphinx.util.docfields",
"sphinx.util.docutils",
"sphinx.util.i18n",

View File

@ -1,7 +1,6 @@
from __future__ import annotations
import functools
from typing import Any, Callable, TypeVar
from sphinx.locale import __
from sphinx.util import logging
@ -10,6 +9,13 @@ from sphinx.util.console import bold, color_terminal
if False:
from collections.abc import Iterable, Iterator
from types import TracebackType
from typing import Any, Callable, TypeVar
from typing_extensions import ParamSpec
T = TypeVar('T')
P = ParamSpec('P')
R = TypeVar('R')
logger = logging.getLogger(__name__)
@ -22,9 +28,6 @@ def display_chunk(chunk: Any) -> str:
return str(chunk)
T = TypeVar('T')
def status_iterator(
iterable: Iterable[T],
summary: str,
@ -88,9 +91,9 @@ class progress_message:
return False
def __call__(self, f: Callable) -> Callable:
def __call__(self, f: Callable[P, R]) -> Callable[P, R]:
@functools.wraps(f)
def wrapper(*args: Any, **kwargs: Any) -> Any:
def wrapper(*args: P.args, **kwargs: P.kwargs) -> R: # type: ignore[return]
with self:
return f(*args, **kwargs)