Enable collections-named-tuple (PYI024) rule in ruff (#123019)
This commit is contained in:
parent
b6c9fe86e1
commit
e734971d33
20 changed files with 21 additions and 22 deletions
|
@ -136,7 +136,7 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
|
|
||||||
|
|
||||||
# Tuple to hold data needed for notification
|
# Tuple to hold data needed for notification
|
||||||
NotificationItem = namedtuple(
|
NotificationItem = namedtuple( # noqa: PYI024
|
||||||
"NotificationItem", "hnotify huser name plc_datatype callback"
|
"NotificationItem", "hnotify huser name plc_datatype callback"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ SENSORS_TYPE_LOAD_AVG = "sensors_load_avg"
|
||||||
SENSORS_TYPE_RATES = "sensors_rates"
|
SENSORS_TYPE_RATES = "sensors_rates"
|
||||||
SENSORS_TYPE_TEMPERATURES = "sensors_temperatures"
|
SENSORS_TYPE_TEMPERATURES = "sensors_temperatures"
|
||||||
|
|
||||||
WrtDevice = namedtuple("WrtDevice", ["ip", "name", "connected_to"])
|
WrtDevice = namedtuple("WrtDevice", ["ip", "name", "connected_to"]) # noqa: PYI024
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ def get_scanner(hass: HomeAssistant, config: ConfigType) -> BboxDeviceScanner |
|
||||||
return scanner if scanner.success_init else None
|
return scanner if scanner.success_init else None
|
||||||
|
|
||||||
|
|
||||||
Device = namedtuple("Device", ["mac", "name", "ip", "last_update"])
|
Device = namedtuple("Device", ["mac", "name", "ip", "last_update"]) # noqa: PYI024
|
||||||
|
|
||||||
|
|
||||||
class BboxDeviceScanner(DeviceScanner):
|
class BboxDeviceScanner(DeviceScanner):
|
||||||
|
|
|
@ -51,7 +51,7 @@ def _create_device(data):
|
||||||
return _Device(ip_address, mac, host, status, name)
|
return _Device(ip_address, mac, host, status, name)
|
||||||
|
|
||||||
|
|
||||||
_Device = namedtuple("_Device", ["ip_address", "mac", "host", "status", "name"])
|
_Device = namedtuple("_Device", ["ip_address", "mac", "host", "status", "name"]) # noqa: PYI024
|
||||||
|
|
||||||
|
|
||||||
class BTSmartHubScanner(DeviceScanner):
|
class BTSmartHubScanner(DeviceScanner):
|
||||||
|
|
|
@ -16,7 +16,7 @@ from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
from .const import DOMAIN, CalendarType
|
from .const import DOMAIN, CalendarType
|
||||||
from .coordinator import EGSCalendarUpdateCoordinator
|
from .coordinator import EGSCalendarUpdateCoordinator
|
||||||
|
|
||||||
DateRange = namedtuple("DateRange", ["start", "end"])
|
DateRange = namedtuple("DateRange", ["start", "end"]) # noqa: PYI024
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
|
|
|
@ -28,7 +28,7 @@ SCAN_INTERVAL = timedelta(hours=4)
|
||||||
|
|
||||||
ICON = "mdi:currency-eur"
|
ICON = "mdi:currency-eur"
|
||||||
|
|
||||||
BankCredentials = namedtuple("BankCredentials", "blz login pin url")
|
BankCredentials = namedtuple("BankCredentials", "blz login pin url") # noqa: PYI024
|
||||||
|
|
||||||
CONF_BIN = "bank_identification_number"
|
CONF_BIN = "bank_identification_number"
|
||||||
CONF_ACCOUNTS = "accounts"
|
CONF_ACCOUNTS = "accounts"
|
||||||
|
|
|
@ -42,7 +42,7 @@ def get_scanner(
|
||||||
return scanner if scanner.success_init else None
|
return scanner if scanner.success_init else None
|
||||||
|
|
||||||
|
|
||||||
Device = namedtuple("Device", ["mac", "name"])
|
Device = namedtuple("Device", ["mac", "name"]) # noqa: PYI024
|
||||||
|
|
||||||
|
|
||||||
class HitronCODADeviceScanner(DeviceScanner):
|
class HitronCODADeviceScanner(DeviceScanner):
|
||||||
|
|
|
@ -76,8 +76,8 @@ from .validators import check_config
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
ConfEntry = namedtuple("ConfEntry", "call_type attr func_name")
|
ConfEntry = namedtuple("ConfEntry", "call_type attr func_name") # noqa: PYI024
|
||||||
RunEntry = namedtuple("RunEntry", "attr func")
|
RunEntry = namedtuple("RunEntry", "attr func") # noqa: PYI024
|
||||||
PB_CALL = [
|
PB_CALL = [
|
||||||
ConfEntry(
|
ConfEntry(
|
||||||
CALL_TYPE_COIL,
|
CALL_TYPE_COIL,
|
||||||
|
|
|
@ -46,7 +46,7 @@ from .const import (
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
ENTRY = namedtuple(
|
ENTRY = namedtuple( # noqa: PYI024
|
||||||
"ENTRY",
|
"ENTRY",
|
||||||
[
|
[
|
||||||
"struct_id",
|
"struct_id",
|
||||||
|
@ -60,7 +60,7 @@ ILLEGAL = "I"
|
||||||
OPTIONAL = "O"
|
OPTIONAL = "O"
|
||||||
DEMANDED = "D"
|
DEMANDED = "D"
|
||||||
|
|
||||||
PARM_IS_LEGAL = namedtuple(
|
PARM_IS_LEGAL = namedtuple( # noqa: PYI024
|
||||||
"PARM_IS_LEGAL",
|
"PARM_IS_LEGAL",
|
||||||
[
|
[
|
||||||
"count",
|
"count",
|
||||||
|
|
|
@ -44,7 +44,7 @@ DEFAULT_INFER_ARMING_STATE = False
|
||||||
SIGNAL_ZONE_CHANGED = "ness_alarm.zone_changed"
|
SIGNAL_ZONE_CHANGED = "ness_alarm.zone_changed"
|
||||||
SIGNAL_ARMING_STATE_CHANGED = "ness_alarm.arming_state_changed"
|
SIGNAL_ARMING_STATE_CHANGED = "ness_alarm.arming_state_changed"
|
||||||
|
|
||||||
ZoneChangedData = namedtuple("ZoneChangedData", ["zone_id", "state"])
|
ZoneChangedData = namedtuple("ZoneChangedData", ["zone_id", "state"]) # noqa: PYI024
|
||||||
|
|
||||||
DEFAULT_ZONE_TYPE = BinarySensorDeviceClass.MOTION
|
DEFAULT_ZONE_TYPE = BinarySensorDeviceClass.MOTION
|
||||||
ZONE_SCHEMA = vol.Schema(
|
ZONE_SCHEMA = vol.Schema(
|
||||||
|
|
|
@ -38,7 +38,7 @@ CONF_OUTLETS = "outlets"
|
||||||
|
|
||||||
DEFAULT_PORT = 1234
|
DEFAULT_PORT = 1234
|
||||||
DEFAULT_USERNAME = "admin"
|
DEFAULT_USERNAME = "admin"
|
||||||
Device = namedtuple("Device", ["netio", "entities"])
|
Device = namedtuple("Device", ["netio", "entities"]) # noqa: PYI024
|
||||||
DEVICES: dict[str, Device] = {}
|
DEVICES: dict[str, Device] = {}
|
||||||
|
|
||||||
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)
|
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)
|
||||||
|
|
|
@ -29,7 +29,7 @@ from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DatatypeDescription = namedtuple(
|
DatatypeDescription = namedtuple( # noqa: PYI024
|
||||||
"DatatypeDescription", ["name", "unit", "device_class"]
|
"DatatypeDescription", ["name", "unit", "device_class"]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -322,7 +322,7 @@ def _create_state_changed_event_from_old_new(
|
||||||
attributes_json = json.dumps(attributes, cls=JSONEncoder)
|
attributes_json = json.dumps(attributes, cls=JSONEncoder)
|
||||||
if attributes_json == "null":
|
if attributes_json == "null":
|
||||||
attributes_json = "{}"
|
attributes_json = "{}"
|
||||||
row = collections.namedtuple(
|
row = collections.namedtuple( # noqa: PYI024
|
||||||
"Row",
|
"Row",
|
||||||
[
|
[
|
||||||
"event_type"
|
"event_type"
|
||||||
|
|
|
@ -821,7 +821,6 @@ ignore = [
|
||||||
"PLE0605",
|
"PLE0605",
|
||||||
|
|
||||||
# temporarily disabled
|
# temporarily disabled
|
||||||
"PYI024", # Use typing.NamedTuple instead of collections.namedtuple
|
|
||||||
"RET503",
|
"RET503",
|
||||||
"RET501",
|
"RET501",
|
||||||
"TRY301"
|
"TRY301"
|
||||||
|
|
|
@ -20,7 +20,7 @@ except ImportError:
|
||||||
|
|
||||||
|
|
||||||
RE_ASCII = re.compile(r"\033\[[^m]*m")
|
RE_ASCII = re.compile(r"\033\[[^m]*m")
|
||||||
Error = namedtuple("Error", ["file", "line", "col", "msg", "skip"])
|
Error = namedtuple("Error", ["file", "line", "col", "msg", "skip"]) # noqa: PYI024
|
||||||
|
|
||||||
PASS = "green"
|
PASS = "green"
|
||||||
FAIL = "bold_red"
|
FAIL = "bold_red"
|
||||||
|
|
|
@ -61,7 +61,7 @@ async def test_system_status_subscription(
|
||||||
response = await client.receive_json()
|
response = await client.receive_json()
|
||||||
assert response["success"]
|
assert response["success"]
|
||||||
|
|
||||||
VirtualMem = namedtuple("VirtualMemory", ["available", "percent", "total"])
|
VirtualMem = namedtuple("VirtualMemory", ["available", "percent", "total"]) # noqa: PYI024
|
||||||
vmem = VirtualMem(10 * 1024**2, 50, 30 * 1024**2)
|
vmem = VirtualMem(10 * 1024**2, 50, 30 * 1024**2)
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
|
|
@ -8,7 +8,7 @@ from freezegun import freeze_time as alter_time # noqa: F401
|
||||||
from homeassistant.components import jewish_calendar
|
from homeassistant.components import jewish_calendar
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
_LatLng = namedtuple("_LatLng", ["lat", "lng"])
|
_LatLng = namedtuple("_LatLng", ["lat", "lng"]) # noqa: PYI024
|
||||||
|
|
||||||
HDATE_DEFAULT_ALTITUDE = 754
|
HDATE_DEFAULT_ALTITUDE = 754
|
||||||
NYC_LATLNG = _LatLng(40.7128, -74.0060)
|
NYC_LATLNG = _LatLng(40.7128, -74.0060)
|
||||||
|
|
|
@ -328,7 +328,7 @@ def create_state_changed_event_from_old_new(
|
||||||
if new_state is not None:
|
if new_state is not None:
|
||||||
attributes = new_state.get("attributes")
|
attributes = new_state.get("attributes")
|
||||||
attributes_json = json.dumps(attributes, cls=JSONEncoder)
|
attributes_json = json.dumps(attributes, cls=JSONEncoder)
|
||||||
row = collections.namedtuple(
|
row = collections.namedtuple( # noqa: PYI024
|
||||||
"Row",
|
"Row",
|
||||||
[
|
[
|
||||||
"event_type",
|
"event_type",
|
||||||
|
|
|
@ -12,5 +12,5 @@ MOCK_CONFIG = {
|
||||||
"port": PORT,
|
"port": PORT,
|
||||||
}
|
}
|
||||||
|
|
||||||
_CONTROLLER = namedtuple("Controller", ["mac_address", "controller_type"])
|
_CONTROLLER = namedtuple("Controller", ["mac_address", "controller_type"]) # noqa: PYI024
|
||||||
MOCK_CONTROLLERS = {1: _CONTROLLER(mac_address=HARDWARE_MAC, controller_type=MODEL)}
|
MOCK_CONTROLLERS = {1: _CONTROLLER(mac_address=HARDWARE_MAC, controller_type=MODEL)}
|
||||||
|
|
|
@ -39,7 +39,7 @@ from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from tests.common import MockConfigEntry, load_json_value_fixture
|
from tests.common import MockConfigEntry, load_json_value_fixture
|
||||||
|
|
||||||
ColorTempRange = namedtuple("ColorTempRange", ["min", "max"])
|
ColorTempRange = namedtuple("ColorTempRange", ["min", "max"]) # noqa: PYI024
|
||||||
|
|
||||||
MODULE = "homeassistant.components.tplink"
|
MODULE = "homeassistant.components.tplink"
|
||||||
MODULE_CONFIG_FLOW = "homeassistant.components.tplink.config_flow"
|
MODULE_CONFIG_FLOW = "homeassistant.components.tplink.config_flow"
|
||||||
|
|
Loading…
Add table
Reference in a new issue