Skip to content

Commit

Permalink
Update mypy to 1.0.0 (home-assistant#87586)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p authored Feb 7, 2023
1 parent ff6e597 commit 4fbb14e
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/gios/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
_LOGGER.debug("Using station_id: %d", station_id)

# 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]

# We used to use int in device_entry identifiers, convert this to str.
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/harmony/subscriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import asyncio
from collections.abc import Callable
import logging
from typing import Any, NamedTuple, Optional
from typing import Any, NamedTuple

from homeassistant.core import CALLBACK_TYPE, HomeAssistant, callback

_LOGGER = logging.getLogger(__name__)

NoParamCallback = Optional[Callable[[], Any]]
ActivityCallback = Optional[Callable[[tuple], Any]]
NoParamCallback = Callable[[], Any] | None
ActivityCallback = Callable[[tuple], Any] | None


class HarmonyCallback(NamedTuple):
Expand Down
8 changes: 4 additions & 4 deletions homeassistant/components/mqtt/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from operator import attrgetter
import ssl
import time
from typing import TYPE_CHECKING, Any, Union, cast
from typing import TYPE_CHECKING, Any, cast
import uuid

import attr
Expand Down Expand Up @@ -151,9 +151,9 @@ async def async_publish(
[str, ReceivePayloadType, int], Coroutine[Any, Any, None]
]
DeprecatedMessageCallbackType = Callable[[str, ReceivePayloadType, int], None]
DeprecatedMessageCallbackTypes = Union[
AsyncDeprecatedMessageCallbackType, DeprecatedMessageCallbackType
]
DeprecatedMessageCallbackTypes = (
AsyncDeprecatedMessageCallbackType | DeprecatedMessageCallbackType
)


# Support for a deprecated callback type will be removed from HA core 2023.2.0
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/samsungtv/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ async def async_is_on(self) -> bool:
"""Tells if the TV is on."""
LOGGER.debug("Checking if TV %s is on using websocket", self.host)
if remote := await self._async_get_remote():
return remote.is_alive() # type: ignore[no-any-return]
return remote.is_alive()
return False

async def _async_send_commands(self, commands: list[_CommandT]) -> None:
Expand All @@ -399,7 +399,7 @@ async def _async_send_commands(self, commands: list[_CommandT]) -> None:
for _ in range(retry_count + 1):
try:
if remote := await self._async_get_remote():
await remote.send_commands(commands)
await remote.send_commands(commands) # type: ignore[arg-type]
break
except (
BrokenPipeError,
Expand All @@ -416,7 +416,7 @@ async def _async_get_remote(self) -> _RemoteT | None:
"""Create or return a remote control instance."""
if (remote := self._remote) and remote.is_alive():
# If we have one then try to use it
return remote # type: ignore[no-any-return]
return remote

async with self._remote_lock:
# If we don't have one make sure we do it under the lock
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/zha/core/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
from ..entity import ZhaEntity
from .channels.base import ZigbeeChannel

_LogFilterType = Filter | Callable[[LogRecord], int]
_LogFilterType = Filter | Callable[[LogRecord], bool]

_LOGGER = logging.getLogger(__name__)

Expand Down
4 changes: 0 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,6 @@ good-names = [
# Pylint CodeStyle plugin
# consider-using-namedtuple-or-dataclass - too opinionated
# 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 = [
"format",
"abstract-method",
Expand All @@ -190,7 +187,6 @@ disable = [
"consider-using-f-string",
"consider-using-namedtuple-or-dataclass",
"consider-using-assignment-expr",
"consider-alternative-union-syntax",
]
enable = [
#"useless-suppression", # temporarily every now and then to clean them up
Expand Down
2 changes: 1 addition & 1 deletion requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ codecov==2.1.12
coverage==7.1.0
freezegun==1.2.2
mock-open==1.4.0
mypy==0.991
mypy==1.0.0
pre-commit==3.0.0
pylint==2.16.0
pylint-per-file-ignores==1.1.0
Expand Down

0 comments on commit 4fbb14e

Please sign in to comment.