Update mypy to 0.981 (#79115)

This commit is contained in:
Marc Mueller 2022-09-26 22:10:06 +02:00 committed by GitHub
parent 1f6d19bb99
commit e8156adb13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 75 additions and 75 deletions

View file

@ -212,13 +212,13 @@ class EsphomeClimateEntity(EsphomeEntity[ClimateInfo, ClimateState], ClimateEnti
features |= ClimateEntityFeature.SWING_MODE
return features
@property # type: ignore[misc]
@property
@esphome_state_property
def hvac_mode(self) -> str | None:
"""Return current operation ie. heat, cool, idle."""
return _CLIMATE_MODES.from_esphome(self._state.mode)
@property # type: ignore[misc]
@property
@esphome_state_property
def hvac_action(self) -> str | None:
"""Return current action."""
@ -227,7 +227,7 @@ class EsphomeClimateEntity(EsphomeEntity[ClimateInfo, ClimateState], ClimateEnti
return None
return _CLIMATE_ACTIONS.from_esphome(self._state.action)
@property # type: ignore[misc]
@property
@esphome_state_property
def fan_mode(self) -> str | None:
"""Return current fan setting."""
@ -235,7 +235,7 @@ class EsphomeClimateEntity(EsphomeEntity[ClimateInfo, ClimateState], ClimateEnti
self._state.fan_mode
)
@property # type: ignore[misc]
@property
@esphome_state_property
def preset_mode(self) -> str | None:
"""Return current preset mode."""
@ -243,31 +243,31 @@ class EsphomeClimateEntity(EsphomeEntity[ClimateInfo, ClimateState], ClimateEnti
self._state.preset_compat(self._api_version)
)
@property # type: ignore[misc]
@property
@esphome_state_property
def swing_mode(self) -> str | None:
"""Return current swing mode."""
return _SWING_MODES.from_esphome(self._state.swing_mode)
@property # type: ignore[misc]
@property
@esphome_state_property
def current_temperature(self) -> float | None:
"""Return the current temperature."""
return self._state.current_temperature
@property # type: ignore[misc]
@property
@esphome_state_property
def target_temperature(self) -> float | None:
"""Return the temperature we try to reach."""
return self._state.target_temperature
@property # type: ignore[misc]
@property
@esphome_state_property
def target_temperature_low(self) -> float | None:
"""Return the lowbound target temperature we try to reach."""
return self._state.target_temperature_low
@property # type: ignore[misc]
@property
@esphome_state_property
def target_temperature_high(self) -> float | None:
"""Return the highbound target temperature we try to reach."""

View file

@ -65,26 +65,26 @@ class EsphomeCover(EsphomeEntity[CoverInfo, CoverState], CoverEntity):
"""Return true if we do optimistic updates."""
return self._static_info.assumed_state
@property # type: ignore[misc]
@property
@esphome_state_property
def is_closed(self) -> bool | None:
"""Return if the cover is closed or not."""
# Check closed state with api version due to a protocol change
return self._state.is_closed(self._api_version)
@property # type: ignore[misc]
@property
@esphome_state_property
def is_opening(self) -> bool:
"""Return if the cover is opening or not."""
return self._state.current_operation == CoverOperation.IS_OPENING
@property # type: ignore[misc]
@property
@esphome_state_property
def is_closing(self) -> bool:
"""Return if the cover is closing or not."""
return self._state.current_operation == CoverOperation.IS_CLOSING
@property # type: ignore[misc]
@property
@esphome_state_property
def current_cover_position(self) -> int | None:
"""Return current position of cover. 0 is closed, 100 is open."""
@ -92,7 +92,7 @@ class EsphomeCover(EsphomeEntity[CoverInfo, CoverState], CoverEntity):
return None
return round(self._state.position * 100.0)
@property # type: ignore[misc]
@property
@esphome_state_property
def current_cover_tilt_position(self) -> int | None:
"""Return current position of cover tilt. 0 is closed, 100 is open."""

View file

@ -112,13 +112,13 @@ class EsphomeFan(EsphomeEntity[FanInfo, FanState], FanEntity):
key=self._static_info.key, direction=_FAN_DIRECTIONS.from_hass(direction)
)
@property # type: ignore[misc]
@property
@esphome_state_property
def is_on(self) -> bool | None:
"""Return true if the entity is on."""
return self._state.state
@property # type: ignore[misc]
@property
@esphome_state_property
def percentage(self) -> int | None:
"""Return the current speed percentage."""
@ -141,7 +141,7 @@ class EsphomeFan(EsphomeEntity[FanInfo, FanState], FanEntity):
return len(ORDERED_NAMED_FAN_SPEEDS)
return self._static_info.supported_speed_levels
@property # type: ignore[misc]
@property
@esphome_state_property
def oscillating(self) -> bool | None:
"""Return the oscillation state."""
@ -149,7 +149,7 @@ class EsphomeFan(EsphomeEntity[FanInfo, FanState], FanEntity):
return None
return self._state.oscillating
@property # type: ignore[misc]
@property
@esphome_state_property
def current_direction(self) -> str | None:
"""Return the current fan direction."""

View file

@ -130,7 +130,7 @@ class EsphomeLight(EsphomeEntity[LightInfo, LightState], LightEntity):
"""Return whether the client supports the new color mode system natively."""
return self._api_version >= APIVersion(1, 6)
@property # type: ignore[misc]
@property
@esphome_state_property
def is_on(self) -> bool | None:
"""Return true if the light is on."""
@ -260,13 +260,13 @@ class EsphomeLight(EsphomeEntity[LightInfo, LightState], LightEntity):
data["transition_length"] = kwargs[ATTR_TRANSITION]
await self._client.light_command(**data)
@property # type: ignore[misc]
@property
@esphome_state_property
def brightness(self) -> int | None:
"""Return the brightness of this light between 0..255."""
return round(self._state.brightness * 255)
@property # type: ignore[misc]
@property
@esphome_state_property
def color_mode(self) -> str | None:
"""Return the color mode of the light."""
@ -277,7 +277,7 @@ class EsphomeLight(EsphomeEntity[LightInfo, LightState], LightEntity):
return _color_mode_to_ha(self._state.color_mode)
@property # type: ignore[misc]
@property
@esphome_state_property
def rgb_color(self) -> tuple[int, int, int] | None:
"""Return the rgb color value [int, int, int]."""
@ -294,7 +294,7 @@ class EsphomeLight(EsphomeEntity[LightInfo, LightState], LightEntity):
round(self._state.blue * self._state.color_brightness * 255),
)
@property # type: ignore[misc]
@property
@esphome_state_property
def rgbw_color(self) -> tuple[int, int, int, int] | None:
"""Return the rgbw color value [int, int, int, int]."""
@ -302,7 +302,7 @@ class EsphomeLight(EsphomeEntity[LightInfo, LightState], LightEntity):
rgb = cast("tuple[int, int, int]", self.rgb_color)
return (*rgb, white)
@property # type: ignore[misc]
@property
@esphome_state_property
def rgbww_color(self) -> tuple[int, int, int, int, int] | None:
"""Return the rgbww color value [int, int, int, int, int]."""
@ -330,13 +330,13 @@ class EsphomeLight(EsphomeEntity[LightInfo, LightState], LightEntity):
round(self._state.warm_white * 255),
)
@property # type: ignore[misc]
@property
@esphome_state_property
def color_temp(self) -> float | None: # type: ignore[override]
"""Return the CT color value in mireds."""
return self._state.color_temperature
@property # type: ignore[misc]
@property
@esphome_state_property
def effect(self) -> str | None:
"""Return the current effect."""

View file

@ -49,25 +49,25 @@ class EsphomeLock(EsphomeEntity[LockInfo, LockEntityState], LockEntity):
return self._static_info.code_format
return None
@property # type: ignore[misc]
@property
@esphome_state_property
def is_locked(self) -> bool | None:
"""Return true if the lock is locked."""
return self._state.state == LockState.LOCKED
@property # type: ignore[misc]
@property
@esphome_state_property
def is_locking(self) -> bool | None:
"""Return true if the lock is locking."""
return self._state.state == LockState.LOCKING
@property # type: ignore[misc]
@property
@esphome_state_property
def is_unlocking(self) -> bool | None:
"""Return true if the lock is unlocking."""
return self._state.state == LockState.UNLOCKING
@property # type: ignore[misc]
@property
@esphome_state_property
def is_jammed(self) -> bool | None:
"""Return true if the lock is jammed (incomplete locking)."""

View file

@ -64,19 +64,19 @@ class EsphomeMediaPlayer(
_attr_device_class = MediaPlayerDeviceClass.SPEAKER
@property # type: ignore[misc]
@property
@esphome_state_property
def state(self) -> MediaPlayerState | None:
"""Return current state."""
return _STATES.from_esphome(self._state.state)
@property # type: ignore[misc]
@property
@esphome_state_property
def is_volume_muted(self) -> bool:
"""Return true if volume is muted."""
return self._state.muted
@property # type: ignore[misc]
@property
@esphome_state_property
def volume_level(self) -> float | None:
"""Volume level of the media player (0..1)."""

View file

@ -74,7 +74,7 @@ class EsphomeNumber(EsphomeEntity[NumberInfo, NumberState], NumberEntity):
return NUMBER_MODES.from_esphome(self._static_info.mode)
return NumberMode.AUTO
@property # type: ignore[misc]
@property
@esphome_state_property
def native_value(self) -> float | None:
"""Return the state of the entity."""

View file

@ -36,7 +36,7 @@ class EsphomeSelect(EsphomeEntity[SelectInfo, SelectState], SelectEntity):
"""Return a set of selectable options."""
return self._static_info.options
@property # type: ignore[misc]
@property
@esphome_state_property
def current_option(self) -> str | None:
"""Return the state of the entity."""

View file

@ -76,7 +76,7 @@ class EsphomeSensor(EsphomeEntity[SensorInfo, SensorState], SensorEntity):
"""Return if this sensor should force a state update."""
return self._static_info.force_update
@property # type: ignore[misc]
@property
@esphome_state_property
def native_value(self) -> datetime | str | None:
"""Return the state of the entity."""
@ -121,7 +121,7 @@ class EsphomeSensor(EsphomeEntity[SensorInfo, SensorState], SensorEntity):
class EsphomeTextSensor(EsphomeEntity[TextSensorInfo, TextSensorState], SensorEntity):
"""A text sensor implementation for ESPHome."""
@property # type: ignore[misc]
@property
@esphome_state_property
def native_value(self) -> str | None:
"""Return the state of the entity."""

View file

@ -36,7 +36,7 @@ class EsphomeSwitch(EsphomeEntity[SwitchInfo, SwitchState], SwitchEntity):
"""Return true if we do optimistic updates."""
return self._static_info.assumed_state
@property # type: ignore[misc]
@property
@esphome_state_property
def is_on(self) -> bool | None:
"""Return true if the switch is on."""

View file

@ -295,7 +295,7 @@ class ControllerDevice(ClimateEntity):
return key
assert False, "Should be unreachable"
@property # type: ignore[misc]
@property
@_return_on_connection_error([])
def hvac_modes(self) -> list[HVACMode]:
"""Return the list of available operation modes."""
@ -303,13 +303,13 @@ class ControllerDevice(ClimateEntity):
return [HVACMode.OFF, HVACMode.FAN_ONLY]
return [HVACMode.OFF, *self._state_to_pizone]
@property # type: ignore[misc]
@property
@_return_on_connection_error(PRESET_NONE)
def preset_mode(self):
"""Eco mode is external air."""
return PRESET_ECO if self._controller.free_air else PRESET_NONE
@property # type: ignore[misc]
@property
@_return_on_connection_error([PRESET_NONE])
def preset_modes(self):
"""Available preset modes, normal or eco."""
@ -317,7 +317,7 @@ class ControllerDevice(ClimateEntity):
return [PRESET_NONE, PRESET_ECO]
return [PRESET_NONE]
@property # type: ignore[misc]
@property
@_return_on_connection_error()
def current_temperature(self) -> float | None:
"""Return the current temperature."""
@ -347,7 +347,7 @@ class ControllerDevice(ClimateEntity):
return None
return zone.target_temperature
@property # type: ignore[misc]
@property
@_return_on_connection_error()
def target_temperature(self) -> float | None:
"""Return the temperature we try to reach (either from control zone or master unit)."""
@ -375,13 +375,13 @@ class ControllerDevice(ClimateEntity):
"""Return the list of available fan modes."""
return list(self._fan_to_pizone)
@property # type: ignore[misc]
@property
@_return_on_connection_error(0.0)
def min_temp(self) -> float:
"""Return the minimum temperature."""
return self._controller.temp_min
@property # type: ignore[misc]
@property
@_return_on_connection_error(50.0)
def max_temp(self) -> float:
"""Return the maximum temperature."""
@ -516,7 +516,7 @@ class ZoneDevice(ClimateEntity):
"""Return the name of the entity."""
return self._name
@property # type: ignore[misc]
@property
@_return_on_connection_error(0)
def supported_features(self) -> int:
"""Return the list of supported features."""

View file

@ -106,31 +106,31 @@ class AirSensor(AirQualityEntity):
"""Return the name of the sensor."""
return self._name
@property # type: ignore[misc]
@property
@round_state
def air_quality_index(self):
"""Return the Air Quality Index (AQI)."""
return self._api.data.get("aqi")
@property # type: ignore[misc]
@property
@round_state
def nitrogen_dioxide(self):
"""Return the NO2 (nitrogen dioxide) level."""
return self._api.data.get("no2_concentration")
@property # type: ignore[misc]
@property
@round_state
def ozone(self):
"""Return the O3 (ozone) level."""
return self._api.data.get("o3_concentration")
@property # type: ignore[misc]
@property
@round_state
def particulate_matter_2_5(self):
"""Return the particulate matter 2.5 level."""
return self._api.data.get("pm25_concentration")
@property # type: ignore[misc]
@property
@round_state
def particulate_matter_10(self):
"""Return the particulate matter 10 level."""

View file

@ -249,7 +249,7 @@ class PlexMediaPlayer(MediaPlayerEntity):
else:
self._attr_state = MediaPlayerState.IDLE
@property # type: ignore[misc]
@property
@needs_session
def username(self):
"""Return the username of the client owner."""
@ -280,109 +280,109 @@ class PlexMediaPlayer(MediaPlayerEntity):
return "video"
@property # type: ignore[misc]
@property
@needs_session
def session_key(self):
"""Return current session key."""
return self.session.sessionKey
@property # type: ignore[misc]
@property
@needs_session
def media_library_title(self):
"""Return the library name of playing media."""
return self.session.media_library_title
@property # type: ignore[misc]
@property
@needs_session
def media_content_id(self):
"""Return the content ID of current playing media."""
return self.session.media_content_id
@property # type: ignore[misc]
@property
@needs_session
def media_content_type(self):
"""Return the content type of current playing media."""
return self.session.media_content_type
@property # type: ignore[misc]
@property
@needs_session
def media_content_rating(self):
"""Return the content rating of current playing media."""
return self.session.media_content_rating
@property # type: ignore[misc]
@property
@needs_session
def media_artist(self):
"""Return the artist of current playing media, music track only."""
return self.session.media_artist
@property # type: ignore[misc]
@property
@needs_session
def media_album_name(self):
"""Return the album name of current playing media, music track only."""
return self.session.media_album_name
@property # type: ignore[misc]
@property
@needs_session
def media_album_artist(self):
"""Return the album artist of current playing media, music only."""
return self.session.media_album_artist
@property # type: ignore[misc]
@property
@needs_session
def media_track(self):
"""Return the track number of current playing media, music only."""
return self.session.media_track
@property # type: ignore[misc]
@property
@needs_session
def media_duration(self):
"""Return the duration of current playing media in seconds."""
return self.session.media_duration
@property # type: ignore[misc]
@property
@needs_session
def media_position(self):
"""Return the duration of current playing media in seconds."""
return self.session.media_position
@property # type: ignore[misc]
@property
@needs_session
def media_position_updated_at(self):
"""When was the position of the current playing media valid."""
return self.session.media_position_updated_at
@property # type: ignore[misc]
@property
@needs_session
def media_image_url(self):
"""Return the image URL of current playing media."""
return self.session.media_image_url
@property # type: ignore[misc]
@property
@needs_session
def media_summary(self):
"""Return the summary of current playing media."""
return self.session.media_summary
@property # type: ignore[misc]
@property
@needs_session
def media_title(self):
"""Return the title of current playing media."""
return self.session.media_title
@property # type: ignore[misc]
@property
@needs_session
def media_season(self):
"""Return the season of current playing media (TV Show only)."""
return self.session.media_season
@property # type: ignore[misc]
@property
@needs_session
def media_series_title(self):
"""Return the title of the series of current playing media."""
return self.session.media_series_title
@property # type: ignore[misc]
@property
@needs_session
def media_episode(self):
"""Return the episode of current playing media (TV Show only)."""

View file

@ -150,7 +150,7 @@ class LazyState(State):
self.attr_cache = attr_cache
@property # type: ignore[override]
def attributes(self) -> dict[str, Any]: # type: ignore[override]
def attributes(self) -> dict[str, Any]:
"""State attributes."""
if self._attributes is None:
self._attributes = decode_attributes_from_row(self._row, self.attr_cache)
@ -162,7 +162,7 @@ class LazyState(State):
self._attributes = value
@property # type: ignore[override]
def context(self) -> Context: # type: ignore[override]
def context(self) -> Context:
"""State context."""
if self._context is None:
self._context = Context(id=None)
@ -174,7 +174,7 @@ class LazyState(State):
self._context = value
@property # type: ignore[override]
def last_changed(self) -> datetime: # type: ignore[override]
def last_changed(self) -> datetime:
"""Last changed datetime."""
if self._last_changed is None:
if (last_changed := self._row.last_changed) is not None:
@ -189,7 +189,7 @@ class LazyState(State):
self._last_changed = value
@property # type: ignore[override]
def last_updated(self) -> datetime: # type: ignore[override]
def last_updated(self) -> datetime:
"""Last updated datetime."""
if self._last_updated is None:
self._last_updated = process_timestamp(self._row.last_updated)

View file

@ -12,7 +12,7 @@ codecov==2.1.12
coverage==6.4.4
freezegun==1.2.1
mock-open==1.4.0
mypy==0.971
mypy==0.981
pre-commit==2.20.0
pylint==2.15.0
pipdeptree==2.3.1