diff --git a/pyproject.toml b/pyproject.toml index 87fa5e7a4..3d8cce18c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -264,7 +264,6 @@ module = [ "sphinx.registry", "sphinx.search", "sphinx.util", - "sphinx.util.display", "sphinx.util.docfields", "sphinx.util.docutils", "sphinx.util.i18n", diff --git a/sphinx/util/display.py b/sphinx/util/display.py index b39a36729..f3ff8a5a2 100644 --- a/sphinx/util/display.py +++ b/sphinx/util/display.py @@ -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)