Update mypy to 1.6.0 (#101780)
This commit is contained in:
parent
f116e83b62
commit
0b2b486754
18 changed files with 32 additions and 28 deletions
|
@ -50,7 +50,7 @@ class MultiFactorAuthModule:
|
||||||
|
|
||||||
Default is same as type
|
Default is same as type
|
||||||
"""
|
"""
|
||||||
return self.config.get(CONF_ID, self.type)
|
return self.config.get(CONF_ID, self.type) # type: ignore[no-any-return]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def type(self) -> str:
|
def type(self) -> str:
|
||||||
|
@ -60,7 +60,7 @@ class MultiFactorAuthModule:
|
||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
"""Return the name of the auth module."""
|
"""Return the name of the auth module."""
|
||||||
return self.config.get(CONF_NAME, self.DEFAULT_TITLE)
|
return self.config.get(CONF_NAME, self.DEFAULT_TITLE) # type: ignore[no-any-return]
|
||||||
|
|
||||||
# Implement by extending class
|
# Implement by extending class
|
||||||
|
|
||||||
|
|
|
@ -109,4 +109,4 @@ def test_all(policy: CategoryType, key: str) -> bool:
|
||||||
if not isinstance(all_policy, dict):
|
if not isinstance(all_policy, dict):
|
||||||
return bool(all_policy)
|
return bool(all_policy)
|
||||||
|
|
||||||
return all_policy.get(key, False)
|
return all_policy.get(key, False) # type: ignore[no-any-return]
|
||||||
|
|
|
@ -67,7 +67,7 @@ class AuthProvider:
|
||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
"""Return the name of the auth provider."""
|
"""Return the name of the auth provider."""
|
||||||
return self.config.get(CONF_NAME, self.DEFAULT_TITLE)
|
return self.config.get(CONF_NAME, self.DEFAULT_TITLE) # type: ignore[no-any-return]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def support_mfa(self) -> bool:
|
def support_mfa(self) -> bool:
|
||||||
|
|
|
@ -78,4 +78,4 @@ class cached_property(Generic[_T]):
|
||||||
raise TypeError(msg) from None
|
raise TypeError(msg) from None
|
||||||
return val
|
return val
|
||||||
|
|
||||||
__class_getitem__ = classmethod(GenericAlias)
|
__class_getitem__ = classmethod(GenericAlias) # type: ignore[var-annotated]
|
||||||
|
|
|
@ -70,7 +70,7 @@ class BondDevice:
|
||||||
@property
|
@property
|
||||||
def trust_state(self) -> bool:
|
def trust_state(self) -> bool:
|
||||||
"""Check if Trust State is turned on."""
|
"""Check if Trust State is turned on."""
|
||||||
return self.props.get("trust_state", False)
|
return self.props.get("trust_state", False) # type: ignore[no-any-return]
|
||||||
|
|
||||||
def has_action(self, action: str) -> bool:
|
def has_action(self, action: str) -> bool:
|
||||||
"""Check to see if the device supports an actions."""
|
"""Check to see if the device supports an actions."""
|
||||||
|
@ -203,7 +203,7 @@ class BondHub:
|
||||||
@property
|
@property
|
||||||
def make(self) -> str:
|
def make(self) -> str:
|
||||||
"""Return this hub make."""
|
"""Return this hub make."""
|
||||||
return self._version.get("make", BRIDGE_MAKE)
|
return self._version.get("make", BRIDGE_MAKE) # type: ignore[no-any-return]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
|
|
|
@ -197,7 +197,7 @@ class CloudPreferences:
|
||||||
@property
|
@property
|
||||||
def alexa_report_state(self) -> bool:
|
def alexa_report_state(self) -> bool:
|
||||||
"""Return if Alexa report state is enabled."""
|
"""Return if Alexa report state is enabled."""
|
||||||
return self._prefs.get(PREF_ALEXA_REPORT_STATE, DEFAULT_ALEXA_REPORT_STATE)
|
return self._prefs.get(PREF_ALEXA_REPORT_STATE, DEFAULT_ALEXA_REPORT_STATE) # type: ignore[no-any-return]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def alexa_default_expose(self) -> list[str] | None:
|
def alexa_default_expose(self) -> list[str] | None:
|
||||||
|
@ -210,7 +210,7 @@ class CloudPreferences:
|
||||||
@property
|
@property
|
||||||
def alexa_entity_configs(self) -> dict[str, Any]:
|
def alexa_entity_configs(self) -> dict[str, Any]:
|
||||||
"""Return Alexa Entity configurations."""
|
"""Return Alexa Entity configurations."""
|
||||||
return self._prefs.get(PREF_ALEXA_ENTITY_CONFIGS, {})
|
return self._prefs.get(PREF_ALEXA_ENTITY_CONFIGS, {}) # type: ignore[no-any-return]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def alexa_settings_version(self) -> int:
|
def alexa_settings_version(self) -> int:
|
||||||
|
@ -227,7 +227,7 @@ class CloudPreferences:
|
||||||
@property
|
@property
|
||||||
def google_report_state(self) -> bool:
|
def google_report_state(self) -> bool:
|
||||||
"""Return if Google report state is enabled."""
|
"""Return if Google report state is enabled."""
|
||||||
return self._prefs.get(PREF_GOOGLE_REPORT_STATE, DEFAULT_GOOGLE_REPORT_STATE)
|
return self._prefs.get(PREF_GOOGLE_REPORT_STATE, DEFAULT_GOOGLE_REPORT_STATE) # type: ignore[no-any-return]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def google_secure_devices_pin(self) -> str | None:
|
def google_secure_devices_pin(self) -> str | None:
|
||||||
|
@ -237,7 +237,7 @@ class CloudPreferences:
|
||||||
@property
|
@property
|
||||||
def google_entity_configs(self) -> dict[str, dict[str, Any]]:
|
def google_entity_configs(self) -> dict[str, dict[str, Any]]:
|
||||||
"""Return Google Entity configurations."""
|
"""Return Google Entity configurations."""
|
||||||
return self._prefs.get(PREF_GOOGLE_ENTITY_CONFIGS, {})
|
return self._prefs.get(PREF_GOOGLE_ENTITY_CONFIGS, {}) # type: ignore[no-any-return]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def google_settings_version(self) -> int:
|
def google_settings_version(self) -> int:
|
||||||
|
@ -262,12 +262,12 @@ class CloudPreferences:
|
||||||
@property
|
@property
|
||||||
def cloudhooks(self) -> dict[str, Any]:
|
def cloudhooks(self) -> dict[str, Any]:
|
||||||
"""Return the published cloud webhooks."""
|
"""Return the published cloud webhooks."""
|
||||||
return self._prefs.get(PREF_CLOUDHOOKS, {})
|
return self._prefs.get(PREF_CLOUDHOOKS, {}) # type: ignore[no-any-return]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def tts_default_voice(self) -> tuple[str, str]:
|
def tts_default_voice(self) -> tuple[str, str]:
|
||||||
"""Return the default TTS voice."""
|
"""Return the default TTS voice."""
|
||||||
return self._prefs.get(PREF_TTS_DEFAULT_VOICE, DEFAULT_TTS_DEFAULT_VOICE)
|
return self._prefs.get(PREF_TTS_DEFAULT_VOICE, DEFAULT_TTS_DEFAULT_VOICE) # type: ignore[no-any-return]
|
||||||
|
|
||||||
async def get_cloud_user(self) -> str:
|
async def get_cloud_user(self) -> str:
|
||||||
"""Return ID of Home Assistant Cloud system user."""
|
"""Return ID of Home Assistant Cloud system user."""
|
||||||
|
|
|
@ -11,7 +11,7 @@ from .models import DoorBirdData
|
||||||
|
|
||||||
def get_mac_address_from_door_station_info(door_station_info: dict[str, Any]) -> str:
|
def get_mac_address_from_door_station_info(door_station_info: dict[str, Any]) -> str:
|
||||||
"""Get the mac address depending on the device type."""
|
"""Get the mac address depending on the device type."""
|
||||||
return door_station_info.get("PRIMARY_MAC_ADDR", door_station_info["WIFI_MAC_ADDR"])
|
return door_station_info.get("PRIMARY_MAC_ADDR", door_station_info["WIFI_MAC_ADDR"]) # type: ignore[no-any-return]
|
||||||
|
|
||||||
|
|
||||||
def get_door_station_by_token(
|
def get_door_station_by_token(
|
||||||
|
|
|
@ -204,7 +204,7 @@ class Config:
|
||||||
):
|
):
|
||||||
return self.entities[state.entity_id][CONF_ENTITY_NAME]
|
return self.entities[state.entity_id][CONF_ENTITY_NAME]
|
||||||
|
|
||||||
return state.attributes.get(ATTR_EMULATED_HUE_NAME, state.name)
|
return state.attributes.get(ATTR_EMULATED_HUE_NAME, state.name) # type: ignore[no-any-return]
|
||||||
|
|
||||||
@cache # pylint: disable=method-cache-max-size-none
|
@cache # pylint: disable=method-cache-max-size-none
|
||||||
def get_exposed_states(self) -> list[State]:
|
def get_exposed_states(self) -> list[State]:
|
||||||
|
|
|
@ -186,7 +186,7 @@ class ISYSensorEntity(ISYNodeEntity, SensorEntity):
|
||||||
|
|
||||||
# Check if this is a known index pair UOM
|
# Check if this is a known index pair UOM
|
||||||
if isinstance(uom, dict):
|
if isinstance(uom, dict):
|
||||||
return uom.get(value, value)
|
return uom.get(value, value) # type: ignore[no-any-return]
|
||||||
|
|
||||||
if uom in (UOM_INDEX, UOM_ON_OFF):
|
if uom in (UOM_INDEX, UOM_ON_OFF):
|
||||||
return cast(str, self.target.formatted)
|
return cast(str, self.target.formatted)
|
||||||
|
|
|
@ -87,7 +87,7 @@ class MediaExtractor:
|
||||||
|
|
||||||
def get_entities(self) -> list[str]:
|
def get_entities(self) -> list[str]:
|
||||||
"""Return list of entities."""
|
"""Return list of entities."""
|
||||||
return self.call_data.get(ATTR_ENTITY_ID, [])
|
return self.call_data.get(ATTR_ENTITY_ID, []) # type: ignore[no-any-return]
|
||||||
|
|
||||||
def extract_and_send(self) -> None:
|
def extract_and_send(self) -> None:
|
||||||
"""Extract exact stream format for each entity_id and play it."""
|
"""Extract exact stream format for each entity_id and play it."""
|
||||||
|
|
|
@ -144,7 +144,7 @@ class MySensorsHVAC(mysensors.device.MySensorsChildEntity, ClimateEntity):
|
||||||
@property
|
@property
|
||||||
def hvac_mode(self) -> HVACMode:
|
def hvac_mode(self) -> HVACMode:
|
||||||
"""Return current operation ie. heat, cool, idle."""
|
"""Return current operation ie. heat, cool, idle."""
|
||||||
return self._values.get(self.value_type, HVACMode.HEAT)
|
return self._values.get(self.value_type, HVACMode.HEAT) # type: ignore[no-any-return]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def fan_mode(self) -> str | None:
|
def fan_mode(self) -> str | None:
|
||||||
|
|
|
@ -211,7 +211,7 @@ class UpCloudServerEntity(CoordinatorEntity[UpCloudDataUpdateCoordinator]):
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
"""Return true if the server is on."""
|
"""Return true if the server is on."""
|
||||||
try:
|
try:
|
||||||
return STATE_MAP.get(self._server.state, self._server.state) == STATE_ON
|
return STATE_MAP.get(self._server.state, self._server.state) == STATE_ON # type: ignore[no-any-return]
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -468,12 +468,12 @@ class FlowHandler:
|
||||||
@property
|
@property
|
||||||
def source(self) -> str | None:
|
def source(self) -> str | None:
|
||||||
"""Source that initialized the flow."""
|
"""Source that initialized the flow."""
|
||||||
return self.context.get("source", None)
|
return self.context.get("source", None) # type: ignore[no-any-return]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def show_advanced_options(self) -> bool:
|
def show_advanced_options(self) -> bool:
|
||||||
"""If we should show advanced options."""
|
"""If we should show advanced options."""
|
||||||
return self.context.get("show_advanced_options", False)
|
return self.context.get("show_advanced_options", False) # type: ignore[no-any-return]
|
||||||
|
|
||||||
def add_suggested_values_to_schema(
|
def add_suggested_values_to_schema(
|
||||||
self, data_schema: vol.Schema, suggested_values: Mapping[str, Any] | None
|
self, data_schema: vol.Schema, suggested_values: Mapping[str, Any] | None
|
||||||
|
|
|
@ -161,7 +161,7 @@ def get_supported_features(hass: HomeAssistant, entity_id: str) -> int:
|
||||||
First try the statemachine, then entity registry.
|
First try the statemachine, then entity registry.
|
||||||
"""
|
"""
|
||||||
if state := hass.states.get(entity_id):
|
if state := hass.states.get(entity_id):
|
||||||
return state.attributes.get(ATTR_SUPPORTED_FEATURES, 0)
|
return state.attributes.get(ATTR_SUPPORTED_FEATURES, 0) # type: ignore[no-any-return]
|
||||||
|
|
||||||
entity_registry = er.async_get(hass)
|
entity_registry = er.async_get(hass)
|
||||||
if not (entry := entity_registry.async_get(entity_id)):
|
if not (entry := entity_registry.async_get(entity_id)):
|
||||||
|
|
|
@ -2513,7 +2513,7 @@ class TemplateEnvironment(ImmutableSandboxedEnvironment):
|
||||||
self.globals["expand"] = hassfunction(expand)
|
self.globals["expand"] = hassfunction(expand)
|
||||||
self.filters["expand"] = self.globals["expand"]
|
self.filters["expand"] = self.globals["expand"]
|
||||||
self.globals["closest"] = hassfunction(closest)
|
self.globals["closest"] = hassfunction(closest)
|
||||||
self.filters["closest"] = hassfunction(closest_filter)
|
self.filters["closest"] = hassfunction(closest_filter) # type: ignore[arg-type]
|
||||||
self.globals["distance"] = hassfunction(distance)
|
self.globals["distance"] = hassfunction(distance)
|
||||||
self.globals["is_hidden_entity"] = hassfunction(is_hidden_entity)
|
self.globals["is_hidden_entity"] = hassfunction(is_hidden_entity)
|
||||||
self.tests["is_hidden_entity"] = hassfunction(
|
self.tests["is_hidden_entity"] = hassfunction(
|
||||||
|
|
3
mypy.ini
3
mypy.ini
|
@ -7,7 +7,6 @@ python_version = 3.11
|
||||||
plugins = pydantic.mypy
|
plugins = pydantic.mypy
|
||||||
show_error_codes = true
|
show_error_codes = true
|
||||||
follow_imports = silent
|
follow_imports = silent
|
||||||
ignore_missing_imports = true
|
|
||||||
local_partial_types = true
|
local_partial_types = true
|
||||||
strict_equality = true
|
strict_equality = true
|
||||||
no_implicit_optional = true
|
no_implicit_optional = true
|
||||||
|
@ -16,7 +15,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, redundant-self, truthy-iterable
|
enable_error_code = ignore-without-code, redundant-self, truthy-iterable
|
||||||
disable_error_code = annotation-unchecked
|
disable_error_code = annotation-unchecked, import-not-found, import-untyped
|
||||||
extra_checks = false
|
extra_checks = false
|
||||||
check_untyped_defs = true
|
check_untyped_defs = true
|
||||||
disallow_incomplete_defs = true
|
disallow_incomplete_defs = true
|
||||||
|
|
|
@ -11,7 +11,7 @@ astroid==3.0.0
|
||||||
coverage==7.3.2
|
coverage==7.3.2
|
||||||
freezegun==1.2.2
|
freezegun==1.2.2
|
||||||
mock-open==1.4.0
|
mock-open==1.4.0
|
||||||
mypy==1.5.1
|
mypy==1.6.0
|
||||||
pre-commit==3.4.0
|
pre-commit==3.4.0
|
||||||
pydantic==1.10.12
|
pydantic==1.10.12
|
||||||
pylint==3.0.1
|
pylint==3.0.1
|
||||||
|
|
|
@ -35,7 +35,6 @@ GENERAL_SETTINGS: Final[dict[str, str]] = {
|
||||||
"show_error_codes": "true",
|
"show_error_codes": "true",
|
||||||
"follow_imports": "silent",
|
"follow_imports": "silent",
|
||||||
# Enable some checks globally.
|
# Enable some checks globally.
|
||||||
"ignore_missing_imports": "true",
|
|
||||||
"local_partial_types": "true",
|
"local_partial_types": "true",
|
||||||
"strict_equality": "true",
|
"strict_equality": "true",
|
||||||
"no_implicit_optional": "true",
|
"no_implicit_optional": "true",
|
||||||
|
@ -50,7 +49,13 @@ GENERAL_SETTINGS: Final[dict[str, str]] = {
|
||||||
"truthy-iterable",
|
"truthy-iterable",
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
"disable_error_code": ", ".join(["annotation-unchecked"]),
|
"disable_error_code": ", ".join(
|
||||||
|
[
|
||||||
|
"annotation-unchecked",
|
||||||
|
"import-not-found",
|
||||||
|
"import-untyped",
|
||||||
|
]
|
||||||
|
),
|
||||||
# Impractical in real code
|
# Impractical in real code
|
||||||
# E.g. this breaks passthrough ParamSpec typing with Concatenate
|
# E.g. this breaks passthrough ParamSpec typing with Concatenate
|
||||||
"extra_checks": "false",
|
"extra_checks": "false",
|
||||||
|
|
Loading…
Add table
Reference in a new issue