Update mypy to 1.1.1 (#89268)

* Update mypy to 1.1.1
* Update pydantic to 1.10.6
This commit is contained in:
Marc Mueller 2023-03-08 22:57:54 +01:00 committed by GitHub
parent bfae8992a9
commit 386533a16f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 27 additions and 15 deletions

View file

@ -8,7 +8,7 @@ from .util.async_ import protect_loop
def enable() -> None:
"""Enable the detection of blocking calls in the event loop."""
# Prevent urllib3 and requests doing I/O in event loop
HTTPConnection.putrequest = protect_loop( # type: ignore[assignment]
HTTPConnection.putrequest = protect_loop( # type: ignore[method-assign]
HTTPConnection.putrequest
)

View file

@ -460,7 +460,7 @@ class HomeAssistantHTTP:
# This will now raise a RunTimeError.
# To work around this we now prevent the router from getting frozen
# pylint: disable-next=protected-access
self.app._router.freeze = lambda: None # type: ignore[assignment]
self.app._router.freeze = lambda: None # type: ignore[method-assign]
self.runner = web.AppRunner(self.app)
await self.runner.setup()

View file

@ -1,8 +1,9 @@
"""Models used for the Matter integration."""
from __future__ import annotations
from collections.abc import Callable
from dataclasses import asdict, dataclass
from typing import Any
from typing import TYPE_CHECKING, Any
from chip.clusters import Objects as clusters
from chip.clusters.Objects import ClusterAttributeDescriptor
@ -12,11 +13,14 @@ from matter_server.client.models.node import MatterEndpoint
from homeassistant.const import Platform
from homeassistant.helpers.entity import EntityDescription
if TYPE_CHECKING:
from _typeshed import DataclassInstance
class DataclassMustHaveAtLeastOne:
"""A dataclass that must have at least one input parameter that is not None."""
def __post_init__(self) -> None:
def __post_init__(self: DataclassInstance) -> None:
"""Post dataclass initialization."""
if all(val is None for val in asdict(self).values()):
raise ValueError("At least one input parameter must not be None")

View file

@ -2,7 +2,7 @@
from __future__ import annotations
from dataclasses import asdict
from typing import Any
from typing import TYPE_CHECKING, Any, cast
from homeassistant.components.diagnostics import async_redact_data
from homeassistant.config_entries import ConfigEntry
@ -18,6 +18,9 @@ from .const import (
SERVICE_WATERMETER,
)
if TYPE_CHECKING:
from _typeshed import DataclassInstance
TO_REDACT = {
CONF_HOST,
}
@ -42,6 +45,8 @@ async def async_get_config_entry_diagnostics(
}
if coordinator.has_water_meter:
data["data"]["watermeter"] = asdict(coordinator.data[SERVICE_WATERMETER])
data["data"]["watermeter"] = asdict(
cast("DataclassInstance", coordinator.data[SERVICE_WATERMETER])
)
return data

View file

@ -31,4 +31,4 @@ def install_multiple_zeroconf_catcher(hass_zc: HaZeroconf) -> None:
return
zeroconf.Zeroconf.__new__ = new_zeroconf_new # type: ignore[assignment]
zeroconf.Zeroconf.__init__ = new_zeroconf_init # type: ignore[assignment]
zeroconf.Zeroconf.__init__ = new_zeroconf_init # type: ignore[method-assign]

View file

@ -3,7 +3,7 @@ from __future__ import annotations
from collections.abc import Generator
from dataclasses import asdict, dataclass, field
from typing import Any
from typing import TYPE_CHECKING, Any
from awesomeversion import AwesomeVersion
from zwave_js_server.const import (
@ -60,6 +60,9 @@ from .discovery_data_template import (
)
from .helpers import ZwaveValueID
if TYPE_CHECKING:
from _typeshed import DataclassInstance
class ValueType(StrEnum):
"""Enum with all value types."""
@ -73,7 +76,7 @@ class ValueType(StrEnum):
class DataclassMustHaveAtLeastOne:
"""A dataclass that must have at least one input parameter that is not None."""
def __post_init__(self) -> None:
def __post_init__(self: DataclassInstance) -> None:
"""Post dataclass initialization."""
if all(val is None for val in asdict(self).values()):
raise ValueError("At least one input parameter must not be None")

View file

@ -129,7 +129,7 @@ def _async_create_clientsession(
{USER_AGENT: SERVER_SOFTWARE},
)
clientsession.close = warn_use( # type: ignore[assignment]
clientsession.close = warn_use( # type: ignore[method-assign]
clientsession.close,
WARN_CLOSE_MSG,
)

View file

@ -72,7 +72,7 @@ def create_async_httpx_client(
original_aclose = client.aclose
client.aclose = warn_use( # type: ignore[assignment]
client.aclose = warn_use( # type: ignore[method-assign]
client.aclose, "closes the Home Assistant httpx client"
)

View file

@ -275,7 +275,7 @@ class SchemaConfigFlowHandler(config_entries.ConfigFlow, ABC):
)
# Create an async_get_options_flow method
cls.async_get_options_flow = _async_get_options_flow # type: ignore[assignment]
cls.async_get_options_flow = _async_get_options_flow # type: ignore[method-assign]
# Create flow step methods for each step defined in the flow schema
for step in cls.config_flow:

View file

@ -110,7 +110,7 @@ class HassEventLoopPolicy(asyncio.DefaultEventLoopPolicy):
thread_name_prefix="SyncWorker", max_workers=MAX_EXECUTOR_WORKERS
)
loop.set_default_executor(executor)
loop.set_default_executor = warn_use( # type: ignore[assignment]
loop.set_default_executor = warn_use( # type: ignore[method-assign]
loop.set_default_executor, "sets default executor on the event loop"
)
return loop

View file

@ -12,9 +12,9 @@ codecov==2.1.12
coverage==7.2.1
freezegun==1.2.2
mock-open==1.4.0
mypy==1.0.1
mypy==1.1.1
pre-commit==3.1.0
pydantic==1.10.5
pydantic==1.10.6
pylint==2.17.0
pylint-per-file-ignores==1.1.0
pipdeptree==2.5.0