Update ruff to 0.1.15 (#109303)

This commit is contained in:
Marc Mueller 2024-02-01 13:29:01 +01:00 committed by GitHub
parent 9bb6d756f1
commit d2dee9e327
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
21 changed files with 35 additions and 19 deletions

View File

@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.8
rev: v0.1.15
hooks:
- id: ruff
args:

View File

@ -51,6 +51,7 @@ class PassiveBluetoothEntityKey:
Example:
key: temperature
device_id: outdoor_sensor_1
"""
key: str

View File

@ -21,6 +21,7 @@ def get_gas_price(data: EasyEnergyData, hours: int) -> float | None:
Returns:
The gas market price value.
"""
if not data.gas_today:
return None

View File

@ -208,6 +208,7 @@ def get_gas_price(data: EasyEnergyData, hours: int) -> float | None:
Returns:
The gas market price value.
"""
if data.gas_today is None:
return None

View File

@ -21,6 +21,7 @@ def get_gas_price(data: EnergyZeroData, hours: int) -> float | None:
Returns:
The gas market price value.
"""
if not data.gas_today:
return None

View File

@ -140,6 +140,7 @@ def get_gas_price(data: EnergyZeroData, hours: int) -> float | None:
Returns:
The gas market price value.
"""
if data.gas_today is None:
return None

View File

@ -332,6 +332,7 @@ class NukiCoordinator(DataUpdateCoordinator[None]): # pylint: disable=hass-enfo
Returns:
A dict with the events to be fired. The event type is the key and the device ids are the value
"""
events: dict[str, set[str]] = defaultdict(set)

View File

@ -502,6 +502,7 @@ class SensorEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
Note:
suggested_unit_of_measurement is stored in the entity registry the first
time the entity is seen, and then never updated.
"""
if hasattr(self, "_attr_suggested_unit_of_measurement"):
return self._attr_suggested_unit_of_measurement

View File

@ -134,6 +134,7 @@ class HomeAssistantSnapcast:
----------
client : Snapclient
Snapcast client to be added to HA.
"""
if not self.hass_async_add_entities:
return

View File

@ -55,6 +55,7 @@ class OptionsValidationError(Exception):
field_key must also match one of the field names inside the Options class.
error_key: Name of the options.error key that corresponds to this error.
message: Message for the Exception class.
"""
super().__init__(message)
self.field_key = field_key

View File

@ -564,6 +564,7 @@ class ConfigurableFanValueMappingDataTemplate(
`configuration_value_to_fan_value_mapping` maps the values from
`configuration_option` to the value mapping object.
"""
def resolve_data(
@ -634,6 +635,7 @@ class FixedFanValueMappingDataTemplate(
)
),
),
"""
def get_fan_value_mapping(

View File

@ -364,6 +364,7 @@ def domain_key(config_key: Any) -> str:
'hue 1' returns 'hue'
'hue ' raises
'hue ' raises
"""
if not isinstance(config_key, str):
raise vol.Invalid("invalid domain", path=[config_key])

View File

@ -2295,6 +2295,7 @@ def iif(
{{ is_state("device_tracker.frenck", "home") | iif("yes", "no") }}
{{ iif(1==2, "yes", "no") }}
{{ (1 == 1) | iif("yes", "no") }}
"""
if value is None and if_none is not _SENTINEL:
return if_none

View File

@ -1,5 +1,5 @@
# Automatically generated from .pre-commit-config.yaml by gen_requirements_all.py, do not edit
codespell==2.2.2
ruff==0.1.8
ruff==0.1.15
yamllint==1.32.0

View File

@ -287,10 +287,10 @@ async def test_state(hass: HomeAssistant, media_player_entity, mock_blackbird) -
async def test_supported_features(media_player_entity) -> None:
"""Test supported features property."""
assert (
MediaPlayerEntityFeature.TURN_ON
media_player_entity.supported_features
== MediaPlayerEntityFeature.TURN_ON
| MediaPlayerEntityFeature.TURN_OFF
| MediaPlayerEntityFeature.SELECT_SOURCE
== media_player_entity.supported_features
)

View File

@ -2285,6 +2285,7 @@ async def test_cast_platform_play_media_local_media(
quick_play_mock.assert_called()
app_data = quick_play_mock.call_args[0][2]
# No authSig appended
assert app_data[
"media_id"
] == f"{network.get_url(hass)}/api/hls/bla/master_playlist.m3u8?token=bla"
assert (
app_data["media_id"]
== f"{network.get_url(hass)}/api/hls/bla/master_playlist.m3u8?token=bla"
)

View File

@ -172,7 +172,8 @@ async def test_supported_features(
# Features supported for main DVR
state = hass.states.get(MAIN_ENTITY_ID)
assert (
MediaPlayerEntityFeature.PAUSE
state.attributes.get("supported_features")
== MediaPlayerEntityFeature.PAUSE
| MediaPlayerEntityFeature.TURN_ON
| MediaPlayerEntityFeature.TURN_OFF
| MediaPlayerEntityFeature.PLAY_MEDIA
@ -180,19 +181,18 @@ async def test_supported_features(
| MediaPlayerEntityFeature.NEXT_TRACK
| MediaPlayerEntityFeature.PREVIOUS_TRACK
| MediaPlayerEntityFeature.PLAY
== state.attributes.get("supported_features")
)
# Feature supported for clients.
state = hass.states.get(CLIENT_ENTITY_ID)
assert (
MediaPlayerEntityFeature.PAUSE
state.attributes.get("supported_features")
== MediaPlayerEntityFeature.PAUSE
| MediaPlayerEntityFeature.PLAY_MEDIA
| MediaPlayerEntityFeature.STOP
| MediaPlayerEntityFeature.NEXT_TRACK
| MediaPlayerEntityFeature.PREVIOUS_TRACK
| MediaPlayerEntityFeature.PLAY
== state.attributes.get("supported_features")
)

View File

@ -360,13 +360,13 @@ async def test_supported_features(hass: HomeAssistant) -> None:
state = hass.states.get(ZONE_1_ID)
assert (
MediaPlayerEntityFeature.VOLUME_MUTE
state.attributes["supported_features"]
== MediaPlayerEntityFeature.VOLUME_MUTE
| MediaPlayerEntityFeature.VOLUME_SET
| MediaPlayerEntityFeature.VOLUME_STEP
| MediaPlayerEntityFeature.TURN_ON
| MediaPlayerEntityFeature.TURN_OFF
| MediaPlayerEntityFeature.SELECT_SOURCE
== state.attributes["supported_features"]
)

View File

@ -27,6 +27,7 @@ def fake_zones():
Returns:
list: List of fake zones
"""
return [
{"name": "front", "number": 1},
@ -44,6 +45,7 @@ def client(fake_zones):
Yields:
MagicMock: Client Mock
"""
with mock.patch.object(nx584_client, "Client") as _mock_client:
client = nx584_client.Client.return_value

View File

@ -189,7 +189,8 @@ async def test_supported_features(
# Features supported for Rokus
state = hass.states.get(MAIN_ENTITY_ID)
assert (
MediaPlayerEntityFeature.PREVIOUS_TRACK
state.attributes.get("supported_features")
== MediaPlayerEntityFeature.PREVIOUS_TRACK
| MediaPlayerEntityFeature.NEXT_TRACK
| MediaPlayerEntityFeature.VOLUME_STEP
| MediaPlayerEntityFeature.VOLUME_MUTE
@ -200,7 +201,6 @@ async def test_supported_features(
| MediaPlayerEntityFeature.TURN_ON
| MediaPlayerEntityFeature.TURN_OFF
| MediaPlayerEntityFeature.BROWSE_MEDIA
== state.attributes.get("supported_features")
)
@ -214,7 +214,8 @@ async def test_tv_supported_features(
state = hass.states.get(TV_ENTITY_ID)
assert state
assert (
MediaPlayerEntityFeature.PREVIOUS_TRACK
state.attributes.get("supported_features")
== MediaPlayerEntityFeature.PREVIOUS_TRACK
| MediaPlayerEntityFeature.NEXT_TRACK
| MediaPlayerEntityFeature.VOLUME_STEP
| MediaPlayerEntityFeature.VOLUME_MUTE
@ -225,7 +226,6 @@ async def test_tv_supported_features(
| MediaPlayerEntityFeature.TURN_ON
| MediaPlayerEntityFeature.TURN_OFF
| MediaPlayerEntityFeature.BROWSE_MEDIA
== state.attributes.get("supported_features")
)

View File

@ -260,13 +260,13 @@ async def test_supported_features(hass: HomeAssistant) -> None:
state = hass.states.get(ZONE_1_ID)
assert (
MediaPlayerEntityFeature.VOLUME_MUTE
state.attributes["supported_features"]
== MediaPlayerEntityFeature.VOLUME_MUTE
| MediaPlayerEntityFeature.VOLUME_SET
| MediaPlayerEntityFeature.VOLUME_STEP
| MediaPlayerEntityFeature.TURN_ON
| MediaPlayerEntityFeature.TURN_OFF
| MediaPlayerEntityFeature.SELECT_SOURCE
== state.attributes["supported_features"]
)