mirror of
https://github.com/home-assistant/core.git
synced 2025-04-22 16:27:56 +00:00
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
@ -251,8 +251,10 @@ class NotifyAuthModule(MultiFactorAuthModule):
|
||||
_LOGGER.error("Cannot find user %s", user_id)
|
||||
return
|
||||
|
||||
await self.async_notify( # type: ignore
|
||||
code, notify_setting.notify_service, notify_setting.target
|
||||
await self.async_notify(
|
||||
code,
|
||||
notify_setting.notify_service, # type: ignore
|
||||
notify_setting.target,
|
||||
)
|
||||
|
||||
async def async_notify(
|
||||
|
@ -215,8 +215,9 @@ class TotpSetupFlow(SetupFlow):
|
||||
|
||||
else:
|
||||
hass = self._auth_module.hass
|
||||
self._ota_secret, self._url, self._image = await hass.async_add_executor_job( # type: ignore
|
||||
_generate_secret_and_qr_code, str(self._user.name)
|
||||
self._ota_secret, self._url, self._image = await hass.async_add_executor_job(
|
||||
_generate_secret_and_qr_code, # type: ignore
|
||||
str(self._user.name),
|
||||
)
|
||||
|
||||
return self.async_show_form(
|
||||
|
@ -42,8 +42,10 @@ class CachingStaticResource(StaticResource):
|
||||
if filepath.is_dir():
|
||||
return await super()._handle(request)
|
||||
if filepath.is_file():
|
||||
# type ignore: https://github.com/aio-libs/aiohttp/pull/3976
|
||||
return FileResponse( # type: ignore
|
||||
filepath, chunk_size=self._chunk_size, headers=CACHE_HEADERS
|
||||
return FileResponse(
|
||||
filepath,
|
||||
chunk_size=self._chunk_size,
|
||||
# type ignore: https://github.com/aio-libs/aiohttp/pull/3976
|
||||
headers=CACHE_HEADERS, # type: ignore
|
||||
)
|
||||
raise HTTPNotFound
|
||||
|
@ -144,8 +144,8 @@ def async_loop_exception_handler(_: Any, context: Dict) -> None:
|
||||
if exception:
|
||||
kwargs["exc_info"] = (type(exception), exception, exception.__traceback__)
|
||||
|
||||
_LOGGER.error( # type: ignore
|
||||
"Error doing job: %s", context["message"], **kwargs
|
||||
_LOGGER.error(
|
||||
"Error doing job: %s", context["message"], **kwargs # type: ignore
|
||||
)
|
||||
|
||||
|
||||
|
@ -598,8 +598,7 @@ def deprecated(
|
||||
else:
|
||||
# Unclear when it is None, but it happens, so let's guard.
|
||||
# https://github.com/home-assistant/home-assistant/issues/24982
|
||||
# type ignore/unreachable: https://github.com/python/typeshed/pull/3137
|
||||
module_name = __name__ # type: ignore
|
||||
module_name = __name__
|
||||
|
||||
if replacement_key and invalidation_version:
|
||||
warning = (
|
||||
|
@ -54,7 +54,7 @@ def get_deprecated(
|
||||
and a warning is issued to the user.
|
||||
"""
|
||||
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.warning(
|
||||
"'%s' is deprecated. Please rename '%s' to '%s' in your "
|
||||
|
@ -24,7 +24,7 @@ _LOGGER = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
# pylint: disable=invalid-name
|
||||
asyncio_run = asyncio.run
|
||||
asyncio_run = asyncio.run # type: ignore
|
||||
except AttributeError:
|
||||
_T = TypeVar("_T")
|
||||
|
||||
|
@ -6,7 +6,7 @@ detect_location_info and elevation are mocked by default during tests.
|
||||
import asyncio
|
||||
import collections
|
||||
import math
|
||||
from typing import Any, Optional, Tuple, Dict
|
||||
from typing import Any, Optional, Tuple, Dict, cast
|
||||
|
||||
import aiohttp
|
||||
|
||||
@ -159,7 +159,7 @@ def vincenty(
|
||||
if 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]]:
|
||||
|
@ -130,7 +130,7 @@ def catch_log_exception(
|
||||
"""Decorate a callback to catch and log exceptions."""
|
||||
|
||||
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
|
||||
frames = len(inspect.trace()) - 1
|
||||
exc_msg = traceback.format_exc(-frames)
|
||||
@ -178,7 +178,9 @@ def catch_log_coro_exception(
|
||||
try:
|
||||
return await target
|
||||
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
|
||||
frames = len(inspect.trace()) - 1
|
||||
exc_msg = traceback.format_exc(-frames)
|
||||
|
@ -9,7 +9,7 @@ codecov==2.0.15
|
||||
flake8-docstrings==1.3.1
|
||||
flake8==3.7.8
|
||||
mock-open==1.3.1
|
||||
mypy==0.720
|
||||
mypy==0.730
|
||||
pre-commit==1.18.3
|
||||
pydocstyle==4.0.1
|
||||
pylint==2.3.1
|
||||
|
@ -10,7 +10,7 @@ codecov==2.0.15
|
||||
flake8-docstrings==1.3.1
|
||||
flake8==3.7.8
|
||||
mock-open==1.3.1
|
||||
mypy==0.720
|
||||
mypy==0.730
|
||||
pre-commit==1.18.3
|
||||
pydocstyle==4.0.1
|
||||
pylint==2.3.1
|
||||
|
Loading…
x
Reference in New Issue
Block a user