Skip to content

Commit

Permalink
Shrink the mypy whitelist for sphinx.util.display (#12570)
Browse files Browse the repository at this point in the history
Co-authored-by: Adam Turner <[email protected]>
  • Loading branch information
danieleades and AA-Turner authored Jul 15, 2024
1 parent 313627e commit d5df528
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ module = [
"sphinx.registry",
"sphinx.search",
"sphinx.util",
"sphinx.util.display",
"sphinx.util.docfields",
"sphinx.util.docutils",
"sphinx.util.i18n",
Expand Down
15 changes: 9 additions & 6 deletions sphinx/util/display.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -10,6 +9,13 @@
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__)

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


T = TypeVar('T')


def status_iterator(
iterable: Iterable[T],
summary: str,
Expand Down Expand Up @@ -88,9 +91,9 @@ def __exit__(

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)

Expand Down

0 comments on commit d5df528

Please sign in to comment.