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)
|
||||
|
||||
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) # type: ignore[attr-defined]
|
||||
await provider.async_will_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()
|
||||
|
||||
# https://github.com/python/mypy/issues/1424
|
||||
await requirements.async_process_requirements(
|
||||
hass, module_path, module.REQUIREMENTS
|
||||
)
|
||||
|
|
|
@ -250,9 +250,7 @@ class LoginFlow(data_entry_flow.FlowHandler):
|
|||
auth_module, "async_initialize_login_mfa_step"
|
||||
):
|
||||
try:
|
||||
await auth_module.async_initialize_login_mfa_step( # type: ignore[attr-defined]
|
||||
self.user.id
|
||||
)
|
||||
await auth_module.async_initialize_login_mfa_step(self.user.id)
|
||||
except HomeAssistantError:
|
||||
_LOGGER.exception("Error initializing MFA step")
|
||||
return self.async_abort(reason="unknown_error")
|
||||
|
|
|
@ -531,7 +531,7 @@ class ClimateEntity(Entity):
|
|||
async def async_turn_on(self) -> None:
|
||||
"""Turn the entity 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
|
||||
|
||||
# Fake turn on
|
||||
|
@ -544,7 +544,7 @@ class ClimateEntity(Entity):
|
|||
async def async_turn_off(self) -> None:
|
||||
"""Turn the entity 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
|
||||
|
||||
# Fake turn off
|
||||
|
|
|
@ -500,7 +500,7 @@ class KNXModule:
|
|||
transcoder := DPTBase.parse_transcoder(dpt)
|
||||
):
|
||||
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(
|
||||
|
@ -532,7 +532,7 @@ class KNXModule:
|
|||
transcoder := DPTBase.parse_transcoder(dpt)
|
||||
):
|
||||
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:
|
||||
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
|
||||
|
||||
|
||||
numeric_type_validator = dpt_subclass_validator(DPTNumeric) # type: ignore[misc]
|
||||
sensor_type_validator = dpt_subclass_validator(DPTBase) # type: ignore[misc]
|
||||
numeric_type_validator = dpt_subclass_validator(DPTNumeric) # type: ignore[type-abstract]
|
||||
sensor_type_validator = dpt_subclass_validator(DPTBase) # type: ignore[type-abstract]
|
||||
string_type_validator = dpt_subclass_validator(DPTString)
|
||||
|
||||
|
||||
|
|
|
@ -920,9 +920,7 @@ class MediaPlayerEntity(Entity):
|
|||
async def async_toggle(self) -> None:
|
||||
"""Toggle the power on the media player."""
|
||||
if hasattr(self, "toggle"):
|
||||
await self.hass.async_add_executor_job(
|
||||
self.toggle # type: ignore[attr-defined]
|
||||
)
|
||||
await self.hass.async_add_executor_job(self.toggle)
|
||||
return
|
||||
|
||||
if self.state in {
|
||||
|
@ -940,9 +938,7 @@ class MediaPlayerEntity(Entity):
|
|||
This method is a coroutine.
|
||||
"""
|
||||
if hasattr(self, "volume_up"):
|
||||
await self.hass.async_add_executor_job(
|
||||
self.volume_up # type: ignore[attr-defined]
|
||||
)
|
||||
await self.hass.async_add_executor_job(self.volume_up)
|
||||
return
|
||||
|
||||
if (
|
||||
|
@ -958,9 +954,7 @@ class MediaPlayerEntity(Entity):
|
|||
This method is a coroutine.
|
||||
"""
|
||||
if hasattr(self, "volume_down"):
|
||||
await self.hass.async_add_executor_job(
|
||||
self.volume_down # type: ignore[attr-defined]
|
||||
)
|
||||
await self.hass.async_add_executor_job(self.volume_down)
|
||||
return
|
||||
|
||||
if (
|
||||
|
@ -973,9 +967,7 @@ class MediaPlayerEntity(Entity):
|
|||
async def async_media_play_pause(self) -> None:
|
||||
"""Play or pause the media player."""
|
||||
if hasattr(self, "media_play_pause"):
|
||||
await self.hass.async_add_executor_job(
|
||||
self.media_play_pause # type: ignore[attr-defined]
|
||||
)
|
||||
await self.hass.async_add_executor_job(self.media_play_pause)
|
||||
return
|
||||
|
||||
if self.state == MediaPlayerState.PLAYING:
|
||||
|
|
|
@ -282,7 +282,7 @@ class BaseNotificationService:
|
|||
if hasattr(self, "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}")
|
||||
if target_name in stale_targets:
|
||||
stale_targets.remove(target_name)
|
||||
|
|
|
@ -160,7 +160,7 @@ class LazyState(State):
|
|||
"""Set attributes."""
|
||||
self._attributes = value
|
||||
|
||||
@property # type: ignore[override]
|
||||
@property
|
||||
def context(self) -> Context:
|
||||
"""State context."""
|
||||
if self._context is None:
|
||||
|
@ -172,7 +172,7 @@ class LazyState(State):
|
|||
"""Set context."""
|
||||
self._context = value
|
||||
|
||||
@property # type: ignore[override]
|
||||
@property
|
||||
def last_changed(self) -> datetime:
|
||||
"""Last changed datetime."""
|
||||
if self._last_changed is None:
|
||||
|
@ -187,7 +187,7 @@ class LazyState(State):
|
|||
"""Set last changed datetime."""
|
||||
self._last_changed = value
|
||||
|
||||
@property # type: ignore[override]
|
||||
@property
|
||||
def last_updated(self) -> datetime:
|
||||
"""Last updated datetime."""
|
||||
if self._last_updated is None:
|
||||
|
|
|
@ -705,9 +705,9 @@ class Entity(ABC):
|
|||
try:
|
||||
task: asyncio.Future[None]
|
||||
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"):
|
||||
task = self.hass.async_add_executor_job(self.update) # type: ignore[attr-defined]
|
||||
task = self.hass.async_add_executor_job(self.update)
|
||||
else:
|
||||
return
|
||||
|
||||
|
|
|
@ -12,7 +12,9 @@ from .objects import Input, NodeListClass
|
|||
try:
|
||||
from yaml import CSafeDumper as FastestAvailableSafeDumper
|
||||
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:
|
||||
|
|
|
@ -18,7 +18,7 @@ try:
|
|||
HAS_C_LOADER = True
|
||||
except ImportError:
|
||||
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
|
||||
|
||||
|
|
1
mypy.ini
1
mypy.ini
|
@ -14,6 +14,7 @@ warn_redundant_casts = true
|
|||
warn_unused_configs = true
|
||||
warn_unused_ignores = true
|
||||
enable_error_code = ignore-without-code
|
||||
disable_error_code = annotation-unchecked
|
||||
strict_concatenate = false
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
|
|
|
@ -12,7 +12,7 @@ codecov==2.1.12
|
|||
coverage==6.4.4
|
||||
freezegun==1.2.2
|
||||
mock-open==1.4.0
|
||||
mypy==0.982
|
||||
mypy==0.990
|
||||
pre-commit==2.20.0
|
||||
pylint==2.15.5
|
||||
pipdeptree==2.3.1
|
||||
|
|
|
@ -46,7 +46,8 @@ GENERAL_SETTINGS: Final[dict[str, str]] = {
|
|||
"warn_redundant_casts": "true",
|
||||
"warn_unused_configs": "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": "false",
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue