DSMR: Complete full strictly typed (#52162)

This commit is contained in:
Franck Nijhof 2021-06-24 20:27:25 +02:00 committed by GitHub
parent fba7118d44
commit a2be9a487f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 5 deletions

View File

@ -26,6 +26,7 @@ homeassistant.components.cover.*
homeassistant.components.device_automation.*
homeassistant.components.device_tracker.*
homeassistant.components.dnsip.*
homeassistant.components.dsmr.*
homeassistant.components.dunehd.*
homeassistant.components.elgato.*
homeassistant.components.fitbit.*

View File

@ -51,14 +51,16 @@ class DSMRConnection:
"""Equipment identifier."""
if self._equipment_identifier in self._telegram:
dsmr_object = self._telegram[self._equipment_identifier]
return getattr(dsmr_object, "value", None)
identifier: str | None = getattr(dsmr_object, "value", None)
return identifier
return None
def equipment_identifier_gas(self) -> str | None:
"""Equipment identifier gas."""
if obis_ref.EQUIPMENT_IDENTIFIER_GAS in self._telegram:
dsmr_object = self._telegram[obis_ref.EQUIPMENT_IDENTIFIER_GAS]
return getattr(dsmr_object, "value", None)
identifier: str | None = getattr(dsmr_object, "value", None)
return identifier
return None
async def validate_connect(self, hass: core.HomeAssistant) -> bool:
@ -142,7 +144,7 @@ class DSMRFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
def _abort_if_host_port_configured(
self,
port: str,
host: str = None,
host: str | None = None,
updates: dict[Any, Any] | None = None,
reload_on_update: bool = True,
) -> FlowResult | None:

View File

@ -89,7 +89,7 @@ async def async_setup_entry(
)
@Throttle(min_time_between_updates)
def update_entities_telegram(telegram: dict[str, DSMRObject]):
def update_entities_telegram(telegram: dict[str, DSMRObject]) -> None:
"""Update entities with latest telegram and trigger state update."""
# Make all device entities aware of new telegram
for entity in entities:
@ -222,7 +222,8 @@ class DSMREntity(SensorEntity):
# Get the attribute value if the object has it
dsmr_object = self.telegram[self._sensor.obis_reference]
return getattr(dsmr_object, attribute, None)
attr: str | None = getattr(dsmr_object, attribute)
return attr
@property
def state(self) -> StateType:

View File

@ -297,6 +297,17 @@ no_implicit_optional = true
warn_return_any = true
warn_unreachable = true
[mypy-homeassistant.components.dsmr.*]
check_untyped_defs = true
disallow_incomplete_defs = true
disallow_subclassing_any = true
disallow_untyped_calls = true
disallow_untyped_decorators = true
disallow_untyped_defs = true
no_implicit_optional = true
warn_return_any = true
warn_unreachable = true
[mypy-homeassistant.components.dunehd.*]
check_untyped_defs = true
disallow_incomplete_defs = true