Skip to content

Commit d5df528

Browse files
Shrink the mypy whitelist for sphinx.util.display (#12570)
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
1 parent 313627e commit d5df528

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ module = [
264264
"sphinx.registry",
265265
"sphinx.search",
266266
"sphinx.util",
267-
"sphinx.util.display",
268267
"sphinx.util.docfields",
269268
"sphinx.util.docutils",
270269
"sphinx.util.i18n",

sphinx/util/display.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import annotations
22

33
import functools
4-
from typing import Any, Callable, TypeVar
54

65
from sphinx.locale import __
76
from sphinx.util import logging
@@ -10,6 +9,13 @@
109
if False:
1110
from collections.abc import Iterable, Iterator
1211
from types import TracebackType
12+
from typing import Any, Callable, TypeVar
13+
14+
from typing_extensions import ParamSpec
15+
16+
T = TypeVar('T')
17+
P = ParamSpec('P')
18+
R = TypeVar('R')
1319

1420
logger = logging.getLogger(__name__)
1521

@@ -22,9 +28,6 @@ def display_chunk(chunk: Any) -> str:
2228
return str(chunk)
2329

2430

25-
T = TypeVar('T')
26-
27-
2831
def status_iterator(
2932
iterable: Iterable[T],
3033
summary: str,
@@ -88,9 +91,9 @@ def __exit__(
8891

8992
return False
9093

91-
def __call__(self, f: Callable) -> Callable:
94+
def __call__(self, f: Callable[P, R]) -> Callable[P, R]:
9295
@functools.wraps(f)
93-
def wrapper(*args: Any, **kwargs: Any) -> Any:
96+
def wrapper(*args: P.args, **kwargs: P.kwargs) -> R: # type: ignore[return]
9497
with self:
9598
return f(*args, **kwargs)
9699

0 commit comments

Comments
 (0)