Upgrade mypy to 0.730, address raised issues (#26959)
https://mypy-lang.blogspot.com/2019/09/mypy-730-released.html
This commit is contained in:
parent
77654da341
commit
fde128d66c
11 changed files with 25 additions and 19 deletions
|
@ -251,8 +251,10 @@ class NotifyAuthModule(MultiFactorAuthModule):
|
||||||
_LOGGER.error("Cannot find user %s", user_id)
|
_LOGGER.error("Cannot find user %s", user_id)
|
||||||
return
|
return
|
||||||
|
|
||||||
await self.async_notify( # type: ignore
|
await self.async_notify(
|
||||||
code, notify_setting.notify_service, notify_setting.target
|
code,
|
||||||
|
notify_setting.notify_service, # type: ignore
|
||||||
|
notify_setting.target,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_notify(
|
async def async_notify(
|
||||||
|
|
|
@ -215,8 +215,9 @@ class TotpSetupFlow(SetupFlow):
|
||||||
|
|
||||||
else:
|
else:
|
||||||
hass = self._auth_module.hass
|
hass = self._auth_module.hass
|
||||||
self._ota_secret, self._url, self._image = await hass.async_add_executor_job( # type: ignore
|
self._ota_secret, self._url, self._image = await hass.async_add_executor_job(
|
||||||
_generate_secret_and_qr_code, str(self._user.name)
|
_generate_secret_and_qr_code, # type: ignore
|
||||||
|
str(self._user.name),
|
||||||
)
|
)
|
||||||
|
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
|
|
|
@ -42,8 +42,10 @@ class CachingStaticResource(StaticResource):
|
||||||
if filepath.is_dir():
|
if filepath.is_dir():
|
||||||
return await super()._handle(request)
|
return await super()._handle(request)
|
||||||
if filepath.is_file():
|
if filepath.is_file():
|
||||||
# type ignore: https://github.com/aio-libs/aiohttp/pull/3976
|
return FileResponse(
|
||||||
return FileResponse( # type: ignore
|
filepath,
|
||||||
filepath, chunk_size=self._chunk_size, headers=CACHE_HEADERS
|
chunk_size=self._chunk_size,
|
||||||
|
# type ignore: https://github.com/aio-libs/aiohttp/pull/3976
|
||||||
|
headers=CACHE_HEADERS, # type: ignore
|
||||||
)
|
)
|
||||||
raise HTTPNotFound
|
raise HTTPNotFound
|
||||||
|
|
|
@ -144,8 +144,8 @@ def async_loop_exception_handler(_: Any, context: Dict) -> None:
|
||||||
if exception:
|
if exception:
|
||||||
kwargs["exc_info"] = (type(exception), exception, exception.__traceback__)
|
kwargs["exc_info"] = (type(exception), exception, exception.__traceback__)
|
||||||
|
|
||||||
_LOGGER.error( # type: ignore
|
_LOGGER.error(
|
||||||
"Error doing job: %s", context["message"], **kwargs
|
"Error doing job: %s", context["message"], **kwargs # type: ignore
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -598,8 +598,7 @@ def deprecated(
|
||||||
else:
|
else:
|
||||||
# Unclear when it is None, but it happens, so let's guard.
|
# Unclear when it is None, but it happens, so let's guard.
|
||||||
# https://github.com/home-assistant/home-assistant/issues/24982
|
# https://github.com/home-assistant/home-assistant/issues/24982
|
||||||
# type ignore/unreachable: https://github.com/python/typeshed/pull/3137
|
module_name = __name__
|
||||||
module_name = __name__ # type: ignore
|
|
||||||
|
|
||||||
if replacement_key and invalidation_version:
|
if replacement_key and invalidation_version:
|
||||||
warning = (
|
warning = (
|
||||||
|
|
|
@ -54,7 +54,7 @@ def get_deprecated(
|
||||||
and a warning is issued to the user.
|
and a warning is issued to the user.
|
||||||
"""
|
"""
|
||||||
if old_name in config:
|
if old_name in config:
|
||||||
module_name = inspect.getmodule(inspect.stack()[1][0]).__name__
|
module_name = inspect.getmodule(inspect.stack()[1][0]).__name__ # type: ignore
|
||||||
logger = logging.getLogger(module_name)
|
logger = logging.getLogger(module_name)
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"'%s' is deprecated. Please rename '%s' to '%s' in your "
|
"'%s' is deprecated. Please rename '%s' to '%s' in your "
|
||||||
|
|
|
@ -24,7 +24,7 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# pylint: disable=invalid-name
|
# pylint: disable=invalid-name
|
||||||
asyncio_run = asyncio.run
|
asyncio_run = asyncio.run # type: ignore
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
_T = TypeVar("_T")
|
_T = TypeVar("_T")
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ detect_location_info and elevation are mocked by default during tests.
|
||||||
import asyncio
|
import asyncio
|
||||||
import collections
|
import collections
|
||||||
import math
|
import math
|
||||||
from typing import Any, Optional, Tuple, Dict
|
from typing import Any, Optional, Tuple, Dict, cast
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ def vincenty(
|
||||||
if miles:
|
if miles:
|
||||||
s *= MILES_PER_KILOMETER # kilometers to miles
|
s *= MILES_PER_KILOMETER # kilometers to miles
|
||||||
|
|
||||||
return round(s, 6)
|
return round(cast(float, s), 6)
|
||||||
|
|
||||||
|
|
||||||
async def _get_ipapi(session: aiohttp.ClientSession) -> Optional[Dict[str, Any]]:
|
async def _get_ipapi(session: aiohttp.ClientSession) -> Optional[Dict[str, Any]]:
|
||||||
|
|
|
@ -130,7 +130,7 @@ def catch_log_exception(
|
||||||
"""Decorate a callback to catch and log exceptions."""
|
"""Decorate a callback to catch and log exceptions."""
|
||||||
|
|
||||||
def log_exception(*args: Any) -> None:
|
def log_exception(*args: Any) -> None:
|
||||||
module_name = inspect.getmodule(inspect.trace()[1][0]).__name__
|
module_name = inspect.getmodule(inspect.trace()[1][0]).__name__ # type: ignore
|
||||||
# Do not print the wrapper in the traceback
|
# Do not print the wrapper in the traceback
|
||||||
frames = len(inspect.trace()) - 1
|
frames = len(inspect.trace()) - 1
|
||||||
exc_msg = traceback.format_exc(-frames)
|
exc_msg = traceback.format_exc(-frames)
|
||||||
|
@ -178,7 +178,9 @@ def catch_log_coro_exception(
|
||||||
try:
|
try:
|
||||||
return await target
|
return await target
|
||||||
except Exception: # pylint: disable=broad-except
|
except Exception: # pylint: disable=broad-except
|
||||||
module_name = inspect.getmodule(inspect.trace()[1][0]).__name__
|
module_name = inspect.getmodule( # type: ignore
|
||||||
|
inspect.trace()[1][0]
|
||||||
|
).__name__
|
||||||
# Do not print the wrapper in the traceback
|
# Do not print the wrapper in the traceback
|
||||||
frames = len(inspect.trace()) - 1
|
frames = len(inspect.trace()) - 1
|
||||||
exc_msg = traceback.format_exc(-frames)
|
exc_msg = traceback.format_exc(-frames)
|
||||||
|
|
|
@ -9,7 +9,7 @@ codecov==2.0.15
|
||||||
flake8-docstrings==1.3.1
|
flake8-docstrings==1.3.1
|
||||||
flake8==3.7.8
|
flake8==3.7.8
|
||||||
mock-open==1.3.1
|
mock-open==1.3.1
|
||||||
mypy==0.720
|
mypy==0.730
|
||||||
pre-commit==1.18.3
|
pre-commit==1.18.3
|
||||||
pydocstyle==4.0.1
|
pydocstyle==4.0.1
|
||||||
pylint==2.3.1
|
pylint==2.3.1
|
||||||
|
|
|
@ -10,7 +10,7 @@ codecov==2.0.15
|
||||||
flake8-docstrings==1.3.1
|
flake8-docstrings==1.3.1
|
||||||
flake8==3.7.8
|
flake8==3.7.8
|
||||||
mock-open==1.3.1
|
mock-open==1.3.1
|
||||||
mypy==0.720
|
mypy==0.730
|
||||||
pre-commit==1.18.3
|
pre-commit==1.18.3
|
||||||
pydocstyle==4.0.1
|
pydocstyle==4.0.1
|
||||||
pylint==2.3.1
|
pylint==2.3.1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue