Update mypy to 0.990 (#81783)
* Update mypy to 0.990 * Remove type ignore - overriding attr with property (13475) * Remove type ignores - hasattr (13544) * Adjust type ignore - assignment (13549) * New error code - type-abstract (13785) * Disable annotation-unchecked (13851)
This commit is contained in:
parent
2082026ff5
commit
0c8eeaa643
15 changed files with 26 additions and 34 deletions
|
@ -356,8 +356,7 @@ class AuthManager:
|
||||||
provider = self._async_get_auth_provider(credentials)
|
provider = self._async_get_auth_provider(credentials)
|
||||||
|
|
||||||
if provider is not None and hasattr(provider, "async_will_remove_credentials"):
|
if provider is not None and hasattr(provider, "async_will_remove_credentials"):
|
||||||
# https://github.com/python/mypy/issues/1424
|
await provider.async_will_remove_credentials(credentials)
|
||||||
await provider.async_will_remove_credentials(credentials) # type: ignore[attr-defined]
|
|
||||||
|
|
||||||
await self._store.async_remove_credentials(credentials)
|
await self._store.async_remove_credentials(credentials)
|
||||||
|
|
||||||
|
|
|
@ -166,7 +166,6 @@ async def _load_mfa_module(hass: HomeAssistant, module_name: str) -> types.Modul
|
||||||
|
|
||||||
processed = hass.data[DATA_REQS] = set()
|
processed = hass.data[DATA_REQS] = set()
|
||||||
|
|
||||||
# https://github.com/python/mypy/issues/1424
|
|
||||||
await requirements.async_process_requirements(
|
await requirements.async_process_requirements(
|
||||||
hass, module_path, module.REQUIREMENTS
|
hass, module_path, module.REQUIREMENTS
|
||||||
)
|
)
|
||||||
|
|
|
@ -250,9 +250,7 @@ class LoginFlow(data_entry_flow.FlowHandler):
|
||||||
auth_module, "async_initialize_login_mfa_step"
|
auth_module, "async_initialize_login_mfa_step"
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
await auth_module.async_initialize_login_mfa_step( # type: ignore[attr-defined]
|
await auth_module.async_initialize_login_mfa_step(self.user.id)
|
||||||
self.user.id
|
|
||||||
)
|
|
||||||
except HomeAssistantError:
|
except HomeAssistantError:
|
||||||
_LOGGER.exception("Error initializing MFA step")
|
_LOGGER.exception("Error initializing MFA step")
|
||||||
return self.async_abort(reason="unknown_error")
|
return self.async_abort(reason="unknown_error")
|
||||||
|
|
|
@ -531,7 +531,7 @@ class ClimateEntity(Entity):
|
||||||
async def async_turn_on(self) -> None:
|
async def async_turn_on(self) -> None:
|
||||||
"""Turn the entity on."""
|
"""Turn the entity on."""
|
||||||
if hasattr(self, "turn_on"):
|
if hasattr(self, "turn_on"):
|
||||||
await self.hass.async_add_executor_job(self.turn_on) # type: ignore[attr-defined]
|
await self.hass.async_add_executor_job(self.turn_on)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Fake turn on
|
# Fake turn on
|
||||||
|
@ -544,7 +544,7 @@ class ClimateEntity(Entity):
|
||||||
async def async_turn_off(self) -> None:
|
async def async_turn_off(self) -> None:
|
||||||
"""Turn the entity off."""
|
"""Turn the entity off."""
|
||||||
if hasattr(self, "turn_off"):
|
if hasattr(self, "turn_off"):
|
||||||
await self.hass.async_add_executor_job(self.turn_off) # type: ignore[attr-defined]
|
await self.hass.async_add_executor_job(self.turn_off)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Fake turn off
|
# Fake turn off
|
||||||
|
|
|
@ -500,7 +500,7 @@ class KNXModule:
|
||||||
transcoder := DPTBase.parse_transcoder(dpt)
|
transcoder := DPTBase.parse_transcoder(dpt)
|
||||||
):
|
):
|
||||||
self._address_filter_transcoder.update(
|
self._address_filter_transcoder.update(
|
||||||
{_filter: transcoder for _filter in _filters} # type: ignore[misc]
|
{_filter: transcoder for _filter in _filters} # type: ignore[type-abstract]
|
||||||
)
|
)
|
||||||
|
|
||||||
return self.xknx.telegram_queue.register_telegram_received_cb(
|
return self.xknx.telegram_queue.register_telegram_received_cb(
|
||||||
|
@ -532,7 +532,7 @@ class KNXModule:
|
||||||
transcoder := DPTBase.parse_transcoder(dpt)
|
transcoder := DPTBase.parse_transcoder(dpt)
|
||||||
):
|
):
|
||||||
self._group_address_transcoder.update(
|
self._group_address_transcoder.update(
|
||||||
{_address: transcoder for _address in group_addresses} # type: ignore[misc]
|
{_address: transcoder for _address in group_addresses} # type: ignore[type-abstract]
|
||||||
)
|
)
|
||||||
for group_address in group_addresses:
|
for group_address in group_addresses:
|
||||||
if group_address in self._knx_event_callback.group_addresses:
|
if group_address in self._knx_event_callback.group_addresses:
|
||||||
|
|
|
@ -79,8 +79,8 @@ def dpt_subclass_validator(dpt_base_class: type[DPTBase]) -> Callable[[Any], str
|
||||||
return dpt_value_validator
|
return dpt_value_validator
|
||||||
|
|
||||||
|
|
||||||
numeric_type_validator = dpt_subclass_validator(DPTNumeric) # type: ignore[misc]
|
numeric_type_validator = dpt_subclass_validator(DPTNumeric) # type: ignore[type-abstract]
|
||||||
sensor_type_validator = dpt_subclass_validator(DPTBase) # type: ignore[misc]
|
sensor_type_validator = dpt_subclass_validator(DPTBase) # type: ignore[type-abstract]
|
||||||
string_type_validator = dpt_subclass_validator(DPTString)
|
string_type_validator = dpt_subclass_validator(DPTString)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -920,9 +920,7 @@ class MediaPlayerEntity(Entity):
|
||||||
async def async_toggle(self) -> None:
|
async def async_toggle(self) -> None:
|
||||||
"""Toggle the power on the media player."""
|
"""Toggle the power on the media player."""
|
||||||
if hasattr(self, "toggle"):
|
if hasattr(self, "toggle"):
|
||||||
await self.hass.async_add_executor_job(
|
await self.hass.async_add_executor_job(self.toggle)
|
||||||
self.toggle # type: ignore[attr-defined]
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.state in {
|
if self.state in {
|
||||||
|
@ -940,9 +938,7 @@ class MediaPlayerEntity(Entity):
|
||||||
This method is a coroutine.
|
This method is a coroutine.
|
||||||
"""
|
"""
|
||||||
if hasattr(self, "volume_up"):
|
if hasattr(self, "volume_up"):
|
||||||
await self.hass.async_add_executor_job(
|
await self.hass.async_add_executor_job(self.volume_up)
|
||||||
self.volume_up # type: ignore[attr-defined]
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -958,9 +954,7 @@ class MediaPlayerEntity(Entity):
|
||||||
This method is a coroutine.
|
This method is a coroutine.
|
||||||
"""
|
"""
|
||||||
if hasattr(self, "volume_down"):
|
if hasattr(self, "volume_down"):
|
||||||
await self.hass.async_add_executor_job(
|
await self.hass.async_add_executor_job(self.volume_down)
|
||||||
self.volume_down # type: ignore[attr-defined]
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -973,9 +967,7 @@ class MediaPlayerEntity(Entity):
|
||||||
async def async_media_play_pause(self) -> None:
|
async def async_media_play_pause(self) -> None:
|
||||||
"""Play or pause the media player."""
|
"""Play or pause the media player."""
|
||||||
if hasattr(self, "media_play_pause"):
|
if hasattr(self, "media_play_pause"):
|
||||||
await self.hass.async_add_executor_job(
|
await self.hass.async_add_executor_job(self.media_play_pause)
|
||||||
self.media_play_pause # type: ignore[attr-defined]
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.state == MediaPlayerState.PLAYING:
|
if self.state == MediaPlayerState.PLAYING:
|
||||||
|
|
|
@ -282,7 +282,7 @@ class BaseNotificationService:
|
||||||
if hasattr(self, "targets"):
|
if hasattr(self, "targets"):
|
||||||
stale_targets = set(self.registered_targets)
|
stale_targets = set(self.registered_targets)
|
||||||
|
|
||||||
for name, target in self.targets.items(): # type: ignore[attr-defined]
|
for name, target in self.targets.items():
|
||||||
target_name = slugify(f"{self._target_service_name_prefix}_{name}")
|
target_name = slugify(f"{self._target_service_name_prefix}_{name}")
|
||||||
if target_name in stale_targets:
|
if target_name in stale_targets:
|
||||||
stale_targets.remove(target_name)
|
stale_targets.remove(target_name)
|
||||||
|
|
|
@ -160,7 +160,7 @@ class LazyState(State):
|
||||||
"""Set attributes."""
|
"""Set attributes."""
|
||||||
self._attributes = value
|
self._attributes = value
|
||||||
|
|
||||||
@property # type: ignore[override]
|
@property
|
||||||
def context(self) -> Context:
|
def context(self) -> Context:
|
||||||
"""State context."""
|
"""State context."""
|
||||||
if self._context is None:
|
if self._context is None:
|
||||||
|
@ -172,7 +172,7 @@ class LazyState(State):
|
||||||
"""Set context."""
|
"""Set context."""
|
||||||
self._context = value
|
self._context = value
|
||||||
|
|
||||||
@property # type: ignore[override]
|
@property
|
||||||
def last_changed(self) -> datetime:
|
def last_changed(self) -> datetime:
|
||||||
"""Last changed datetime."""
|
"""Last changed datetime."""
|
||||||
if self._last_changed is None:
|
if self._last_changed is None:
|
||||||
|
@ -187,7 +187,7 @@ class LazyState(State):
|
||||||
"""Set last changed datetime."""
|
"""Set last changed datetime."""
|
||||||
self._last_changed = value
|
self._last_changed = value
|
||||||
|
|
||||||
@property # type: ignore[override]
|
@property
|
||||||
def last_updated(self) -> datetime:
|
def last_updated(self) -> datetime:
|
||||||
"""Last updated datetime."""
|
"""Last updated datetime."""
|
||||||
if self._last_updated is None:
|
if self._last_updated is None:
|
||||||
|
|
|
@ -705,9 +705,9 @@ class Entity(ABC):
|
||||||
try:
|
try:
|
||||||
task: asyncio.Future[None]
|
task: asyncio.Future[None]
|
||||||
if hasattr(self, "async_update"):
|
if hasattr(self, "async_update"):
|
||||||
task = self.hass.async_create_task(self.async_update()) # type: ignore[attr-defined]
|
task = self.hass.async_create_task(self.async_update())
|
||||||
elif hasattr(self, "update"):
|
elif hasattr(self, "update"):
|
||||||
task = self.hass.async_add_executor_job(self.update) # type: ignore[attr-defined]
|
task = self.hass.async_add_executor_job(self.update)
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,9 @@ from .objects import Input, NodeListClass
|
||||||
try:
|
try:
|
||||||
from yaml import CSafeDumper as FastestAvailableSafeDumper
|
from yaml import CSafeDumper as FastestAvailableSafeDumper
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from yaml import SafeDumper as FastestAvailableSafeDumper # type: ignore[misc]
|
from yaml import ( # type: ignore[assignment]
|
||||||
|
SafeDumper as FastestAvailableSafeDumper,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def dump(_dict: dict) -> str:
|
def dump(_dict: dict) -> str:
|
||||||
|
|
|
@ -18,7 +18,7 @@ try:
|
||||||
HAS_C_LOADER = True
|
HAS_C_LOADER = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAS_C_LOADER = False
|
HAS_C_LOADER = False
|
||||||
from yaml import SafeLoader as FastestAvailableSafeLoader # type: ignore[misc]
|
from yaml import SafeLoader as FastestAvailableSafeLoader # type: ignore[assignment]
|
||||||
|
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
|
|
||||||
|
|
1
mypy.ini
1
mypy.ini
|
@ -14,6 +14,7 @@ warn_redundant_casts = true
|
||||||
warn_unused_configs = true
|
warn_unused_configs = true
|
||||||
warn_unused_ignores = true
|
warn_unused_ignores = true
|
||||||
enable_error_code = ignore-without-code
|
enable_error_code = ignore-without-code
|
||||||
|
disable_error_code = annotation-unchecked
|
||||||
strict_concatenate = false
|
strict_concatenate = false
|
||||||
check_untyped_defs = true
|
check_untyped_defs = true
|
||||||
disallow_incomplete_defs = true
|
disallow_incomplete_defs = true
|
||||||
|
|
|
@ -12,7 +12,7 @@ codecov==2.1.12
|
||||||
coverage==6.4.4
|
coverage==6.4.4
|
||||||
freezegun==1.2.2
|
freezegun==1.2.2
|
||||||
mock-open==1.4.0
|
mock-open==1.4.0
|
||||||
mypy==0.982
|
mypy==0.990
|
||||||
pre-commit==2.20.0
|
pre-commit==2.20.0
|
||||||
pylint==2.15.5
|
pylint==2.15.5
|
||||||
pipdeptree==2.3.1
|
pipdeptree==2.3.1
|
||||||
|
|
|
@ -46,7 +46,8 @@ GENERAL_SETTINGS: Final[dict[str, str]] = {
|
||||||
"warn_redundant_casts": "true",
|
"warn_redundant_casts": "true",
|
||||||
"warn_unused_configs": "true",
|
"warn_unused_configs": "true",
|
||||||
"warn_unused_ignores": "true",
|
"warn_unused_ignores": "true",
|
||||||
"enable_error_code": "ignore-without-code",
|
"enable_error_code": ", ".join(["ignore-without-code"]),
|
||||||
|
"disable_error_code": ", ".join(["annotation-unchecked"]),
|
||||||
# Strict_concatenate breaks passthrough ParamSpec typing
|
# Strict_concatenate breaks passthrough ParamSpec typing
|
||||||
"strict_concatenate": "false",
|
"strict_concatenate": "false",
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue