mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Update mypy to 1.1.1 (#89268)
* Update mypy to 1.1.1 * Update pydantic to 1.10.6
This commit is contained in:
parent
bfae8992a9
commit
386533a16f
@ -8,7 +8,7 @@ from .util.async_ import protect_loop
|
|||||||
def enable() -> None:
|
def enable() -> None:
|
||||||
"""Enable the detection of blocking calls in the event loop."""
|
"""Enable the detection of blocking calls in the event loop."""
|
||||||
# Prevent urllib3 and requests doing I/O in 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
|
HTTPConnection.putrequest
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -460,7 +460,7 @@ class HomeAssistantHTTP:
|
|||||||
# This will now raise a RunTimeError.
|
# This will now raise a RunTimeError.
|
||||||
# To work around this we now prevent the router from getting frozen
|
# To work around this we now prevent the router from getting frozen
|
||||||
# pylint: disable-next=protected-access
|
# 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)
|
self.runner = web.AppRunner(self.app)
|
||||||
await self.runner.setup()
|
await self.runner.setup()
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
"""Models used for the Matter integration."""
|
"""Models used for the Matter integration."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from dataclasses import asdict, dataclass
|
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 import Objects as clusters
|
||||||
from chip.clusters.Objects import ClusterAttributeDescriptor
|
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.const import Platform
|
||||||
from homeassistant.helpers.entity import EntityDescription
|
from homeassistant.helpers.entity import EntityDescription
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from _typeshed import DataclassInstance
|
||||||
|
|
||||||
|
|
||||||
class DataclassMustHaveAtLeastOne:
|
class DataclassMustHaveAtLeastOne:
|
||||||
"""A dataclass that must have at least one input parameter that is not None."""
|
"""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."""
|
"""Post dataclass initialization."""
|
||||||
if all(val is None for val in asdict(self).values()):
|
if all(val is None for val in asdict(self).values()):
|
||||||
raise ValueError("At least one input parameter must not be None")
|
raise ValueError("At least one input parameter must not be None")
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from dataclasses import asdict
|
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.components.diagnostics import async_redact_data
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@ -18,6 +18,9 @@ from .const import (
|
|||||||
SERVICE_WATERMETER,
|
SERVICE_WATERMETER,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from _typeshed import DataclassInstance
|
||||||
|
|
||||||
TO_REDACT = {
|
TO_REDACT = {
|
||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
}
|
}
|
||||||
@ -42,6 +45,8 @@ async def async_get_config_entry_diagnostics(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if coordinator.has_water_meter:
|
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
|
return data
|
||||||
|
@ -31,4 +31,4 @@ def install_multiple_zeroconf_catcher(hass_zc: HaZeroconf) -> None:
|
|||||||
return
|
return
|
||||||
|
|
||||||
zeroconf.Zeroconf.__new__ = new_zeroconf_new # type: ignore[assignment]
|
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]
|
||||||
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from collections.abc import Generator
|
from collections.abc import Generator
|
||||||
from dataclasses import asdict, dataclass, field
|
from dataclasses import asdict, dataclass, field
|
||||||
from typing import Any
|
from typing import TYPE_CHECKING, Any
|
||||||
|
|
||||||
from awesomeversion import AwesomeVersion
|
from awesomeversion import AwesomeVersion
|
||||||
from zwave_js_server.const import (
|
from zwave_js_server.const import (
|
||||||
@ -60,6 +60,9 @@ from .discovery_data_template import (
|
|||||||
)
|
)
|
||||||
from .helpers import ZwaveValueID
|
from .helpers import ZwaveValueID
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from _typeshed import DataclassInstance
|
||||||
|
|
||||||
|
|
||||||
class ValueType(StrEnum):
|
class ValueType(StrEnum):
|
||||||
"""Enum with all value types."""
|
"""Enum with all value types."""
|
||||||
@ -73,7 +76,7 @@ class ValueType(StrEnum):
|
|||||||
class DataclassMustHaveAtLeastOne:
|
class DataclassMustHaveAtLeastOne:
|
||||||
"""A dataclass that must have at least one input parameter that is not None."""
|
"""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."""
|
"""Post dataclass initialization."""
|
||||||
if all(val is None for val in asdict(self).values()):
|
if all(val is None for val in asdict(self).values()):
|
||||||
raise ValueError("At least one input parameter must not be None")
|
raise ValueError("At least one input parameter must not be None")
|
||||||
|
@ -129,7 +129,7 @@ def _async_create_clientsession(
|
|||||||
{USER_AGENT: SERVER_SOFTWARE},
|
{USER_AGENT: SERVER_SOFTWARE},
|
||||||
)
|
)
|
||||||
|
|
||||||
clientsession.close = warn_use( # type: ignore[assignment]
|
clientsession.close = warn_use( # type: ignore[method-assign]
|
||||||
clientsession.close,
|
clientsession.close,
|
||||||
WARN_CLOSE_MSG,
|
WARN_CLOSE_MSG,
|
||||||
)
|
)
|
||||||
|
@ -72,7 +72,7 @@ def create_async_httpx_client(
|
|||||||
|
|
||||||
original_aclose = client.aclose
|
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"
|
client.aclose, "closes the Home Assistant httpx client"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ class SchemaConfigFlowHandler(config_entries.ConfigFlow, ABC):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Create an async_get_options_flow method
|
# 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
|
# Create flow step methods for each step defined in the flow schema
|
||||||
for step in cls.config_flow:
|
for step in cls.config_flow:
|
||||||
|
@ -110,7 +110,7 @@ class HassEventLoopPolicy(asyncio.DefaultEventLoopPolicy):
|
|||||||
thread_name_prefix="SyncWorker", max_workers=MAX_EXECUTOR_WORKERS
|
thread_name_prefix="SyncWorker", max_workers=MAX_EXECUTOR_WORKERS
|
||||||
)
|
)
|
||||||
loop.set_default_executor(executor)
|
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"
|
loop.set_default_executor, "sets default executor on the event loop"
|
||||||
)
|
)
|
||||||
return loop
|
return loop
|
||||||
|
@ -12,9 +12,9 @@ codecov==2.1.12
|
|||||||
coverage==7.2.1
|
coverage==7.2.1
|
||||||
freezegun==1.2.2
|
freezegun==1.2.2
|
||||||
mock-open==1.4.0
|
mock-open==1.4.0
|
||||||
mypy==1.0.1
|
mypy==1.1.1
|
||||||
pre-commit==3.1.0
|
pre-commit==3.1.0
|
||||||
pydantic==1.10.5
|
pydantic==1.10.6
|
||||||
pylint==2.17.0
|
pylint==2.17.0
|
||||||
pylint-per-file-ignores==1.1.0
|
pylint-per-file-ignores==1.1.0
|
||||||
pipdeptree==2.5.0
|
pipdeptree==2.5.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user