Update ruff to v0.0.280 (#97102)
This commit is contained in:
parent
bdd253328d
commit
86708b5590
20 changed files with 25 additions and 60 deletions
|
@ -1,6 +1,6 @@
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: v0.0.277
|
rev: v0.0.280
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff
|
- id: ruff
|
||||||
args:
|
args:
|
||||||
|
|
|
@ -111,7 +111,7 @@ async def websocket_run(
|
||||||
|
|
||||||
if start_stage == PipelineStage.STT:
|
if start_stage == PipelineStage.STT:
|
||||||
# Audio pipeline that will receive audio as binary websocket messages
|
# Audio pipeline that will receive audio as binary websocket messages
|
||||||
audio_queue: "asyncio.Queue[bytes]" = asyncio.Queue()
|
audio_queue: asyncio.Queue[bytes] = asyncio.Queue()
|
||||||
incoming_sample_rate = msg["input"]["sample_rate"]
|
incoming_sample_rate = msg["input"]["sample_rate"]
|
||||||
|
|
||||||
async def stt_stream() -> AsyncGenerator[bytes, None]:
|
async def stt_stream() -> AsyncGenerator[bytes, None]:
|
||||||
|
|
|
@ -694,7 +694,7 @@ class BluesoundPlayer(MediaPlayerEntity):
|
||||||
for source in [
|
for source in [
|
||||||
x
|
x
|
||||||
for x in self._services_items
|
for x in self._services_items
|
||||||
if x["type"] == "LocalMusic" or x["type"] == "RadioService"
|
if x["type"] in ("LocalMusic", "RadioService")
|
||||||
]:
|
]:
|
||||||
sources.append(source["title"])
|
sources.append(source["title"])
|
||||||
|
|
||||||
|
|
|
@ -455,7 +455,7 @@ def extract_offset(summary: str, offset_prefix: str) -> tuple[str, datetime.time
|
||||||
if search and search.group(1):
|
if search and search.group(1):
|
||||||
time = search.group(1)
|
time = search.group(1)
|
||||||
if ":" not in time:
|
if ":" not in time:
|
||||||
if time[0] == "+" or time[0] == "-":
|
if time[0] in ("+", "-"):
|
||||||
time = f"{time[0]}0:{time[1:]}"
|
time = f"{time[0]}0:{time[1:]}"
|
||||||
else:
|
else:
|
||||||
time = f"0:{time}"
|
time = f"0:{time}"
|
||||||
|
|
|
@ -47,7 +47,7 @@ class FliprBinarySensor(FliprEntity, BinarySensorEntity):
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
"""Return true if the binary sensor is on in case of a Problem is detected."""
|
"""Return true if the binary sensor is on in case of a Problem is detected."""
|
||||||
return (
|
return self.coordinator.data[self.entity_description.key] in (
|
||||||
self.coordinator.data[self.entity_description.key] == "TooLow"
|
"TooLow",
|
||||||
or self.coordinator.data[self.entity_description.key] == "TooHigh"
|
"TooHigh",
|
||||||
)
|
)
|
||||||
|
|
|
@ -26,7 +26,7 @@ async def async_setup_entry(
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
Device(hass, api_key, device, coordinator)
|
Device(hass, api_key, device, coordinator)
|
||||||
for device in coordinator.data
|
for device in coordinator.data
|
||||||
if device["type"] == "switch" or device["type"] == "outlet"
|
if device["type"] in ("switch", "outlet")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -161,10 +161,10 @@ class HomematicipGenericEntity(Entity):
|
||||||
if device_id in device_registry.devices:
|
if device_id in device_registry.devices:
|
||||||
# This will also remove associated entities from entity registry.
|
# This will also remove associated entities from entity registry.
|
||||||
device_registry.async_remove_device(device_id)
|
device_registry.async_remove_device(device_id)
|
||||||
else:
|
else: # noqa: PLR5501
|
||||||
# Remove from entity registry.
|
# Remove from entity registry.
|
||||||
# Only relevant for entities that do not belong to a device.
|
# Only relevant for entities that do not belong to a device.
|
||||||
if entity_id := self.registry_entry.entity_id: # noqa: PLR5501
|
if entity_id := self.registry_entry.entity_id:
|
||||||
entity_registry = er.async_get(self.hass)
|
entity_registry = er.async_get(self.hass)
|
||||||
if entity_id in entity_registry.entities:
|
if entity_id in entity_registry.entities:
|
||||||
entity_registry.async_remove(entity_id)
|
entity_registry.async_remove(entity_id)
|
||||||
|
|
|
@ -169,10 +169,7 @@ def async_generate_motioneye_webhook(
|
||||||
) -> str | None:
|
) -> str | None:
|
||||||
"""Generate the full local URL for a webhook_id."""
|
"""Generate the full local URL for a webhook_id."""
|
||||||
try:
|
try:
|
||||||
return "{}{}".format(
|
return f"{get_url(hass, allow_cloud=False)}{async_generate_path(webhook_id)}"
|
||||||
get_url(hass, allow_cloud=False),
|
|
||||||
async_generate_path(webhook_id),
|
|
||||||
)
|
|
||||||
except NoURLAvailableError:
|
except NoURLAvailableError:
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
"Unable to get Home Assistant URL. Have you set the internal and/or "
|
"Unable to get Home Assistant URL. Have you set the internal and/or "
|
||||||
|
|
|
@ -200,9 +200,7 @@ class NetatmoCamera(NetatmoBase, Camera):
|
||||||
await self._camera.async_update_camera_urls()
|
await self._camera.async_update_camera_urls()
|
||||||
|
|
||||||
if self._camera.local_url:
|
if self._camera.local_url:
|
||||||
return "{}/live/files/{}/index.m3u8".format(
|
return f"{self._camera.local_url}/live/files/{self._quality}/index.m3u8"
|
||||||
self._camera.local_url, self._quality
|
|
||||||
)
|
|
||||||
return f"{self._camera.vpn_url}/live/files/{self._quality}/index.m3u8"
|
return f"{self._camera.vpn_url}/live/files/{self._quality}/index.m3u8"
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
|
|
@ -143,9 +143,9 @@ def process_plex_payload(
|
||||||
content = plex_url.path
|
content = plex_url.path
|
||||||
server_id = plex_url.host
|
server_id = plex_url.host
|
||||||
plex_server = get_plex_server(hass, plex_server_id=server_id)
|
plex_server = get_plex_server(hass, plex_server_id=server_id)
|
||||||
else:
|
else: # noqa: PLR5501
|
||||||
# Handle legacy payloads without server_id in URL host position
|
# Handle legacy payloads without server_id in URL host position
|
||||||
if plex_url.host == "search": # noqa: PLR5501
|
if plex_url.host == "search":
|
||||||
content = {}
|
content = {}
|
||||||
else:
|
else:
|
||||||
content = int(plex_url.host) # type: ignore[arg-type]
|
content = int(plex_url.host) # type: ignore[arg-type]
|
||||||
|
|
|
@ -109,10 +109,7 @@ class RachioControllerOnlineBinarySensor(RachioControllerBinarySensor):
|
||||||
@callback
|
@callback
|
||||||
def _async_handle_update(self, *args, **kwargs) -> None:
|
def _async_handle_update(self, *args, **kwargs) -> None:
|
||||||
"""Handle an update to the state of this sensor."""
|
"""Handle an update to the state of this sensor."""
|
||||||
if (
|
if args[0][0][KEY_SUBTYPE] in (SUBTYPE_ONLINE, SUBTYPE_COLD_REBOOT):
|
||||||
args[0][0][KEY_SUBTYPE] == SUBTYPE_ONLINE
|
|
||||||
or args[0][0][KEY_SUBTYPE] == SUBTYPE_COLD_REBOOT
|
|
||||||
):
|
|
||||||
self._state = True
|
self._state = True
|
||||||
elif args[0][0][KEY_SUBTYPE] == SUBTYPE_OFFLINE:
|
elif args[0][0][KEY_SUBTYPE] == SUBTYPE_OFFLINE:
|
||||||
self._state = False
|
self._state = False
|
||||||
|
|
|
@ -423,13 +423,7 @@ def _add_columns(
|
||||||
with session_scope(session=session_maker()) as session:
|
with session_scope(session=session_maker()) as session:
|
||||||
try:
|
try:
|
||||||
connection = session.connection()
|
connection = session.connection()
|
||||||
connection.execute(
|
connection.execute(text(f"ALTER TABLE {table_name} {column_def}"))
|
||||||
text(
|
|
||||||
"ALTER TABLE {table} {column_def}".format(
|
|
||||||
table=table_name, column_def=column_def
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
except (InternalError, OperationalError, ProgrammingError) as err:
|
except (InternalError, OperationalError, ProgrammingError) as err:
|
||||||
raise_if_exception_missing_str(err, ["already exists", "duplicate"])
|
raise_if_exception_missing_str(err, ["already exists", "duplicate"])
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
|
@ -498,13 +492,7 @@ def _modify_columns(
|
||||||
with session_scope(session=session_maker()) as session:
|
with session_scope(session=session_maker()) as session:
|
||||||
try:
|
try:
|
||||||
connection = session.connection()
|
connection = session.connection()
|
||||||
connection.execute(
|
connection.execute(text(f"ALTER TABLE {table_name} {column_def}"))
|
||||||
text(
|
|
||||||
"ALTER TABLE {table} {column_def}".format(
|
|
||||||
table=table_name, column_def=column_def
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
except (InternalError, OperationalError):
|
except (InternalError, OperationalError):
|
||||||
_LOGGER.exception(
|
_LOGGER.exception(
|
||||||
"Could not modify column %s in table %s", column_def, table_name
|
"Could not modify column %s in table %s", column_def, table_name
|
||||||
|
|
|
@ -111,9 +111,7 @@ class ThermoworksSmokeSensor(SensorEntity):
|
||||||
self.type = sensor_type
|
self.type = sensor_type
|
||||||
self.serial = serial
|
self.serial = serial
|
||||||
self.mgr = mgr
|
self.mgr = mgr
|
||||||
self._attr_name = "{name} {sensor}".format(
|
self._attr_name = f"{mgr.name(serial)} {SENSOR_TYPES[sensor_type]}"
|
||||||
name=mgr.name(serial), sensor=SENSOR_TYPES[sensor_type]
|
|
||||||
)
|
|
||||||
self._attr_native_unit_of_measurement = UnitOfTemperature.FAHRENHEIT
|
self._attr_native_unit_of_measurement = UnitOfTemperature.FAHRENHEIT
|
||||||
self._attr_unique_id = f"{serial}-{sensor_type}"
|
self._attr_unique_id = f"{serial}-{sensor_type}"
|
||||||
self._attr_device_class = SensorDeviceClass.TEMPERATURE
|
self._attr_device_class = SensorDeviceClass.TEMPERATURE
|
||||||
|
|
|
@ -35,7 +35,7 @@ from .models import async_wemo_data
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
# Literal values must match options.error keys from strings.json.
|
# Literal values must match options.error keys from strings.json.
|
||||||
ErrorStringKey = Literal["long_press_requires_subscription"]
|
ErrorStringKey = Literal["long_press_requires_subscription"] # noqa: F821
|
||||||
# Literal values must match options.step.init.data keys from strings.json.
|
# Literal values must match options.step.init.data keys from strings.json.
|
||||||
OptionsFieldKey = Literal["enable_subscription", "enable_long_press"]
|
OptionsFieldKey = Literal["enable_subscription", "enable_long_press"]
|
||||||
|
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
|
|
||||||
black==23.7.0
|
black==23.7.0
|
||||||
codespell==2.2.2
|
codespell==2.2.2
|
||||||
ruff==0.0.277
|
ruff==0.0.280
|
||||||
yamllint==1.32.0
|
yamllint==1.32.0
|
||||||
|
|
|
@ -1304,9 +1304,7 @@ async def test_missing_discover_abbreviations(
|
||||||
and match[0] not in ABBREVIATIONS_WHITE_LIST
|
and match[0] not in ABBREVIATIONS_WHITE_LIST
|
||||||
):
|
):
|
||||||
missing.append(
|
missing.append(
|
||||||
"{}: no abbreviation for {} ({})".format(
|
f"{fil}: no abbreviation for {match[1]} ({match[0]})"
|
||||||
fil, match[1], match[0]
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
assert not missing
|
assert not missing
|
||||||
|
|
|
@ -357,9 +357,7 @@ async def test_service_descriptions(hass: HomeAssistant) -> None:
|
||||||
" example: 'This is a test of python_script.hello'"
|
" example: 'This is a test of python_script.hello'"
|
||||||
)
|
)
|
||||||
services_yaml1 = {
|
services_yaml1 = {
|
||||||
"{}/{}/services.yaml".format(
|
f"{hass.config.config_dir}/{FOLDER}/services.yaml": service_descriptions1
|
||||||
hass.config.config_dir, FOLDER
|
|
||||||
): service_descriptions1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -408,9 +406,7 @@ async def test_service_descriptions(hass: HomeAssistant) -> None:
|
||||||
" example: 'This is a test of python_script.hello2'"
|
" example: 'This is a test of python_script.hello2'"
|
||||||
)
|
)
|
||||||
services_yaml2 = {
|
services_yaml2 = {
|
||||||
"{}/{}/services.yaml".format(
|
f"{hass.config.config_dir}/{FOLDER}/services.yaml": service_descriptions2
|
||||||
hass.config.config_dir, FOLDER
|
|
||||||
): service_descriptions2
|
|
||||||
}
|
}
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
|
|
@ -37,9 +37,7 @@ async def test_flow_works(hass: HomeAssistant) -> None:
|
||||||
cookies={"slnet": TEST_APP_SLNET},
|
cookies={"slnet": TEST_APP_SLNET},
|
||||||
)
|
)
|
||||||
mock.get(
|
mock.get(
|
||||||
"https://developer.starline.ru/json/v2/user/{}/user_info".format(
|
f"https://developer.starline.ru/json/v2/user/{TEST_APP_UID}/user_info",
|
||||||
TEST_APP_UID
|
|
||||||
),
|
|
||||||
text='{"code": 200, "devices": [{"device_id": "123", "imei": "123", "alias": "123", "battery": "123", "ctemp": "123", "etemp": "123", "fw_version": "123", "gsm_lvl": "123", "phone": "123", "status": "1", "ts_activity": "123", "typename": "123", "balance": {}, "car_state": {}, "car_alr_state": {}, "functions": [], "position": {}}], "shared_devices": []}',
|
text='{"code": 200, "devices": [{"device_id": "123", "imei": "123", "alias": "123", "battery": "123", "ctemp": "123", "etemp": "123", "fw_version": "123", "gsm_lvl": "123", "phone": "123", "status": "1", "ts_activity": "123", "typename": "123", "balance": {}, "car_state": {}, "car_alr_state": {}, "functions": [], "position": {}}], "shared_devices": []}',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -261,4 +261,4 @@ async def test_discovery_already_configured(
|
||||||
flow.context = {"source": SOURCE_DISCOVERY}
|
flow.context = {"source": SOURCE_DISCOVERY}
|
||||||
|
|
||||||
with pytest.raises(data_entry_flow.AbortFlow):
|
with pytest.raises(data_entry_flow.AbortFlow):
|
||||||
result = await flow.async_step_discovery(["some-host", ""])
|
await flow.async_step_discovery(["some-host", ""])
|
||||||
|
|
|
@ -3013,11 +3013,6 @@ DEVICES = [
|
||||||
DEV_SIG_ENT_MAP_CLASS: "Illuminance",
|
DEV_SIG_ENT_MAP_CLASS: "Illuminance",
|
||||||
DEV_SIG_ENT_MAP_ID: "sensor.lumi_lumi_sensor_motion_aq2_illuminance",
|
DEV_SIG_ENT_MAP_ID: "sensor.lumi_lumi_sensor_motion_aq2_illuminance",
|
||||||
},
|
},
|
||||||
("sensor", "00:11:22:33:44:55:66:77-1-1"): {
|
|
||||||
DEV_SIG_CLUSTER_HANDLERS: ["power"],
|
|
||||||
DEV_SIG_ENT_MAP_CLASS: "Battery",
|
|
||||||
DEV_SIG_ENT_MAP_ID: "sensor.lumi_lumi_sensor_motion_aq2_battery",
|
|
||||||
},
|
|
||||||
("sensor", "00:11:22:33:44:55:66:77-1-2"): {
|
("sensor", "00:11:22:33:44:55:66:77-1-2"): {
|
||||||
DEV_SIG_CLUSTER_HANDLERS: ["device_temperature"],
|
DEV_SIG_CLUSTER_HANDLERS: ["device_temperature"],
|
||||||
DEV_SIG_ENT_MAP_CLASS: "DeviceTemperature",
|
DEV_SIG_ENT_MAP_CLASS: "DeviceTemperature",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue