From 95d64787470f084d532b11a591d9e835a9169cea Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Fri, 17 Dec 2021 02:01:33 +0900 Subject: [PATCH] Fix mypy violations (with mypy-0.920) --- setup.py | 2 +- sphinx/builders/gettext.py | 2 +- sphinx/util/__init__.py | 4 ++-- sphinx/util/inspect.py | 2 +- sphinx/util/logging.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 3dbc8746b6e..8245aacefac 100644 --- a/setup.py +++ b/setup.py @@ -44,7 +44,7 @@ 'lint': [ 'flake8>=3.5.0', 'isort', - 'mypy>=0.900', + 'mypy>=0.920', 'docutils-stubs', "types-typed-ast", "types-pkg_resources", diff --git a/sphinx/builders/gettext.py b/sphinx/builders/gettext.py index be178ca244d..58f9cc40dd5 100644 --- a/sphinx/builders/gettext.py +++ b/sphinx/builders/gettext.py @@ -180,7 +180,7 @@ def write_doc(self, docname: str, doctree: nodes.document) -> None: class LocalTimeZone(tzinfo): def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) # type: ignore + super().__init__(*args, **kwargs) self.tzdelta = tzdelta def utcoffset(self, dt: datetime) -> timedelta: diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py index 384925157f6..b7b33a82054 100644 --- a/sphinx/util/__init__.py +++ b/sphinx/util/__init__.py @@ -153,7 +153,7 @@ def md5(data=b'', **kwargs): """ try: - return hashlib.md5(data, **kwargs) # type: ignore + return hashlib.md5(data, **kwargs) except ValueError: return hashlib.md5(data, **kwargs, usedforsecurity=False) # type: ignore @@ -167,7 +167,7 @@ def sha1(data=b'', **kwargs): """ try: - return hashlib.sha1(data, **kwargs) # type: ignore + return hashlib.sha1(data, **kwargs) except ValueError: return hashlib.sha1(data, **kwargs, usedforsecurity=False) # type: ignore diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py index 24ea49ae04e..d590adff216 100644 --- a/sphinx/util/inspect.py +++ b/sphinx/util/inspect.py @@ -355,7 +355,7 @@ def is_singledispatch_function(obj: Any) -> bool: if (inspect.isfunction(obj) and hasattr(obj, 'dispatch') and hasattr(obj, 'register') and - obj.dispatch.__module__ == 'functools'): + obj.dispatch.__module__ == 'functools'): # type: ignore return True else: return False diff --git a/sphinx/util/logging.py b/sphinx/util/logging.py index bdf77dc077e..ae8fc25cfb5 100644 --- a/sphinx/util/logging.py +++ b/sphinx/util/logging.py @@ -118,7 +118,7 @@ class SphinxLoggerAdapter(logging.LoggerAdapter): """LoggerAdapter allowing ``type`` and ``subtype`` keywords.""" KEYWORDS = ['type', 'subtype', 'location', 'nonl', 'color', 'once'] - def log(self, level: Union[int, str], msg: str, *args: Any, **kwargs: Any) -> None: + def log(self, level: Union[int, str], msg: str, *args: Any, **kwargs: Any) -> None: # type: ignore # NOQA if isinstance(level, int): super().log(level, msg, *args, **kwargs) else: