Update typing 06 (#48039)

This commit is contained in:
Marc Mueller 2021-03-17 23:49:01 +01:00 committed by GitHub
parent 7c0734bdd5
commit 91df3fa904
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 241 additions and 211 deletions

View file

@ -1,6 +1,7 @@
"""Support for esphome sensors."""
from __future__ import annotations
import math
from typing import Optional
from aioesphomeapi import SensorInfo, SensorState, TextSensorInfo, TextSensorState
import voluptuous as vol
@ -49,7 +50,7 @@ class EsphomeSensor(EsphomeEntity):
return super()._static_info
@property
def _state(self) -> Optional[SensorState]:
def _state(self) -> SensorState | None:
return super()._state
@property
@ -65,7 +66,7 @@ class EsphomeSensor(EsphomeEntity):
return self._static_info.force_update
@esphome_state_property
def state(self) -> Optional[str]:
def state(self) -> str | None:
"""Return the state of the entity."""
if math.isnan(self._state.state):
return None
@ -96,7 +97,7 @@ class EsphomeTextSensor(EsphomeEntity):
return super()._static_info
@property
def _state(self) -> Optional[TextSensorState]:
def _state(self) -> TextSensorState | None:
return super()._state
@property
@ -105,7 +106,7 @@ class EsphomeTextSensor(EsphomeEntity):
return self._static_info.icon
@esphome_state_property
def state(self) -> Optional[str]:
def state(self) -> str | None:
"""Return the state of the entity."""
if self._state.missing_state:
return None