Skip to content

Commit

Permalink
shrink 'any-generics' whitelist for the 'deprecation' module (sphinx-…
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleades authored and marxin committed Oct 2, 2022
1 parent 70974b0 commit c65b55e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ module = [
"sphinx.builders.linkcheck",
"sphinx.cmd.quickstart",
"sphinx.config",
"sphinx.deprecation",
"sphinx.domains.*",
"sphinx.environment.*",
"sphinx.events",
Expand Down
8 changes: 4 additions & 4 deletions sphinx/deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ def __getattr__(self, name: str) -> Any:
return self._objects[name]


class DeprecatedDict(dict):
class DeprecatedDict(Dict[str, Any]):
"""A deprecated dict which warns on each access."""

def __init__(self, data: Dict, message: str, warning: Type[Warning]) -> None:
def __init__(self, data: Dict[str, Any], message: str, warning: Type[Warning]) -> None:
self.message = message
self.warning = warning
super().__init__(data)
Expand All @@ -68,14 +68,14 @@ def setdefault(self, key: str, default: Any = None) -> Any:
warnings.warn(self.message, self.warning, stacklevel=2)
return super().setdefault(key, default)

def __getitem__(self, key: str) -> None:
def __getitem__(self, key: str) -> Any:
warnings.warn(self.message, self.warning, stacklevel=2)
return super().__getitem__(key)

def get(self, key: str, default: Any = None) -> Any:
warnings.warn(self.message, self.warning, stacklevel=2)
return super().get(key, default)

def update(self, other: Dict) -> None: # type: ignore
def update(self, other: Dict[str, Any]) -> None: # type: ignore
warnings.warn(self.message, self.warning, stacklevel=2)
super().update(other)

0 comments on commit c65b55e

Please sign in to comment.