Update mypy to 1.0.0 (#87586)

pull/87438/head^2
Marc Mueller 2023-02-07 02:31:14 +01:00 committed by GitHub
parent ff6e597a63
commit 4fbb14ecc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 13 additions and 17 deletions

View File

@ -30,7 +30,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
_LOGGER.debug("Using station_id: %d", station_id) _LOGGER.debug("Using station_id: %d", station_id)
# We used to use int as config_entry unique_id, convert this to str. # We used to use int as config_entry unique_id, convert this to str.
if isinstance(entry.unique_id, int): # type: ignore[unreachable] if isinstance(entry.unique_id, int):
hass.config_entries.async_update_entry(entry, unique_id=str(station_id)) # type: ignore[unreachable] hass.config_entries.async_update_entry(entry, unique_id=str(station_id)) # type: ignore[unreachable]
# We used to use int in device_entry identifiers, convert this to str. # We used to use int in device_entry identifiers, convert this to str.

View File

@ -4,14 +4,14 @@ from __future__ import annotations
import asyncio import asyncio
from collections.abc import Callable from collections.abc import Callable
import logging import logging
from typing import Any, NamedTuple, Optional from typing import Any, NamedTuple
from homeassistant.core import CALLBACK_TYPE, HomeAssistant, callback from homeassistant.core import CALLBACK_TYPE, HomeAssistant, callback
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
NoParamCallback = Optional[Callable[[], Any]] NoParamCallback = Callable[[], Any] | None
ActivityCallback = Optional[Callable[[tuple], Any]] ActivityCallback = Callable[[tuple], Any] | None
class HarmonyCallback(NamedTuple): class HarmonyCallback(NamedTuple):

View File

@ -10,7 +10,7 @@ import logging
from operator import attrgetter from operator import attrgetter
import ssl import ssl
import time import time
from typing import TYPE_CHECKING, Any, Union, cast from typing import TYPE_CHECKING, Any, cast
import uuid import uuid
import attr import attr
@ -151,9 +151,9 @@ AsyncDeprecatedMessageCallbackType = Callable[
[str, ReceivePayloadType, int], Coroutine[Any, Any, None] [str, ReceivePayloadType, int], Coroutine[Any, Any, None]
] ]
DeprecatedMessageCallbackType = Callable[[str, ReceivePayloadType, int], None] DeprecatedMessageCallbackType = Callable[[str, ReceivePayloadType, int], None]
DeprecatedMessageCallbackTypes = Union[ DeprecatedMessageCallbackTypes = (
AsyncDeprecatedMessageCallbackType, DeprecatedMessageCallbackType AsyncDeprecatedMessageCallbackType | DeprecatedMessageCallbackType
] )
# Support for a deprecated callback type will be removed from HA core 2023.2.0 # Support for a deprecated callback type will be removed from HA core 2023.2.0

View File

@ -388,7 +388,7 @@ class SamsungTVWSBaseBridge(SamsungTVBridge, Generic[_RemoteT, _CommandT]):
"""Tells if the TV is on.""" """Tells if the TV is on."""
LOGGER.debug("Checking if TV %s is on using websocket", self.host) LOGGER.debug("Checking if TV %s is on using websocket", self.host)
if remote := await self._async_get_remote(): if remote := await self._async_get_remote():
return remote.is_alive() # type: ignore[no-any-return] return remote.is_alive()
return False return False
async def _async_send_commands(self, commands: list[_CommandT]) -> None: async def _async_send_commands(self, commands: list[_CommandT]) -> None:
@ -399,7 +399,7 @@ class SamsungTVWSBaseBridge(SamsungTVBridge, Generic[_RemoteT, _CommandT]):
for _ in range(retry_count + 1): for _ in range(retry_count + 1):
try: try:
if remote := await self._async_get_remote(): if remote := await self._async_get_remote():
await remote.send_commands(commands) await remote.send_commands(commands) # type: ignore[arg-type]
break break
except ( except (
BrokenPipeError, BrokenPipeError,
@ -416,7 +416,7 @@ class SamsungTVWSBaseBridge(SamsungTVBridge, Generic[_RemoteT, _CommandT]):
"""Create or return a remote control instance.""" """Create or return a remote control instance."""
if (remote := self._remote) and remote.is_alive(): if (remote := self._remote) and remote.is_alive():
# If we have one then try to use it # If we have one then try to use it
return remote # type: ignore[no-any-return] return remote
async with self._remote_lock: async with self._remote_lock:
# If we don't have one make sure we do it under the lock # If we don't have one make sure we do it under the lock

View File

@ -91,7 +91,7 @@ if TYPE_CHECKING:
from ..entity import ZhaEntity from ..entity import ZhaEntity
from .channels.base import ZigbeeChannel from .channels.base import ZigbeeChannel
_LogFilterType = Filter | Callable[[LogRecord], int] _LogFilterType = Filter | Callable[[LogRecord], bool]
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)

View File

@ -163,9 +163,6 @@ good-names = [
# Pylint CodeStyle plugin # Pylint CodeStyle plugin
# consider-using-namedtuple-or-dataclass - too opinionated # consider-using-namedtuple-or-dataclass - too opinionated
# consider-using-assignment-expr - decision to use := better left to devs # consider-using-assignment-expr - decision to use := better left to devs
# ---
# Temporary for the Python 3.10 update, remove with mypy v1.0
# consider-alternative-union-syntax
disable = [ disable = [
"format", "format",
"abstract-method", "abstract-method",
@ -190,7 +187,6 @@ disable = [
"consider-using-f-string", "consider-using-f-string",
"consider-using-namedtuple-or-dataclass", "consider-using-namedtuple-or-dataclass",
"consider-using-assignment-expr", "consider-using-assignment-expr",
"consider-alternative-union-syntax",
] ]
enable = [ enable = [
#"useless-suppression", # temporarily every now and then to clean them up #"useless-suppression", # temporarily every now and then to clean them up

View File

@ -12,7 +12,7 @@ codecov==2.1.12
coverage==7.1.0 coverage==7.1.0
freezegun==1.2.2 freezegun==1.2.2
mock-open==1.4.0 mock-open==1.4.0
mypy==0.991 mypy==1.0.0
pre-commit==3.0.0 pre-commit==3.0.0
pylint==2.16.0 pylint==2.16.0
pylint-per-file-ignores==1.1.0 pylint-per-file-ignores==1.1.0