Skip to content

Commit

Permalink
Enable collections-named-tuple (PYI024) rule in ruff (home-assistant#…
Browse files Browse the repository at this point in the history
  • Loading branch information
epenet authored Aug 2, 2024
1 parent b6c9fe8 commit e734971
Show file tree
Hide file tree
Showing 20 changed files with 21 additions and 22 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/ads/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def handle_write_data_by_name(call: ServiceCall) -> None:


# Tuple to hold data needed for notification
NotificationItem = namedtuple(
NotificationItem = namedtuple( # noqa: PYI024
"NotificationItem", "hnotify huser name plc_datatype callback"
)

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/asuswrt/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
SENSORS_TYPE_RATES = "sensors_rates"
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__)

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/bbox/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_scanner(hass: HomeAssistant, config: ConfigType) -> BboxDeviceScanner |
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):
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/bt_smarthub/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _create_device(data):
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):
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/epic_games_store/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from .const import DOMAIN, CalendarType
from .coordinator import EGSCalendarUpdateCoordinator

DateRange = namedtuple("DateRange", ["start", "end"])
DateRange = namedtuple("DateRange", ["start", "end"]) # noqa: PYI024


async def async_setup_entry(
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/fints/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

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_ACCOUNTS = "accounts"
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/hitron_coda/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def get_scanner(
return scanner if scanner.success_init else None


Device = namedtuple("Device", ["mac", "name"])
Device = namedtuple("Device", ["mac", "name"]) # noqa: PYI024


class HitronCODADeviceScanner(DeviceScanner):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/modbus/modbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@
_LOGGER = logging.getLogger(__name__)


ConfEntry = namedtuple("ConfEntry", "call_type attr func_name")
RunEntry = namedtuple("RunEntry", "attr func")
ConfEntry = namedtuple("ConfEntry", "call_type attr func_name") # noqa: PYI024
RunEntry = namedtuple("RunEntry", "attr func") # noqa: PYI024
PB_CALL = [
ConfEntry(
CALL_TYPE_COIL,
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/modbus/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

_LOGGER = logging.getLogger(__name__)

ENTRY = namedtuple(
ENTRY = namedtuple( # noqa: PYI024
"ENTRY",
[
"struct_id",
Expand All @@ -60,7 +60,7 @@
OPTIONAL = "O"
DEMANDED = "D"

PARM_IS_LEGAL = namedtuple(
PARM_IS_LEGAL = namedtuple( # noqa: PYI024
"PARM_IS_LEGAL",
[
"count",
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/ness_alarm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
SIGNAL_ZONE_CHANGED = "ness_alarm.zone_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
ZONE_SCHEMA = vol.Schema(
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/netio/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

DEFAULT_PORT = 1234
DEFAULT_USERNAME = "admin"
Device = namedtuple("Device", ["netio", "entities"])
Device = namedtuple("Device", ["netio", "entities"]) # noqa: PYI024
DEVICES: dict[str, Device] = {}

MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/tellstick/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

_LOGGER = logging.getLogger(__name__)

DatatypeDescription = namedtuple(
DatatypeDescription = namedtuple( # noqa: PYI024
"DatatypeDescription", ["name", "unit", "device_class"]
)

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/scripts/benchmark/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def _create_state_changed_event_from_old_new(
attributes_json = json.dumps(attributes, cls=JSONEncoder)
if attributes_json == "null":
attributes_json = "{}"
row = collections.namedtuple(
row = collections.namedtuple( # noqa: PYI024
"Row",
[
"event_type"
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,6 @@ ignore = [
"PLE0605",

# temporarily disabled
"PYI024", # Use typing.NamedTuple instead of collections.namedtuple
"RET503",
"RET501",
"TRY301"
Expand Down
2 changes: 1 addition & 1 deletion script/lint_and_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


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"
FAIL = "bold_red"
Expand Down
2 changes: 1 addition & 1 deletion tests/components/hardware/test_websocket_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def create_mock_psutil():
response = await client.receive_json()
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)

with (
Expand Down
2 changes: 1 addition & 1 deletion tests/components/jewish_calendar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from homeassistant.components import jewish_calendar
import homeassistant.util.dt as dt_util

_LatLng = namedtuple("_LatLng", ["lat", "lng"])
_LatLng = namedtuple("_LatLng", ["lat", "lng"]) # noqa: PYI024

HDATE_DEFAULT_ALTITUDE = 754
NYC_LATLNG = _LatLng(40.7128, -74.0060)
Expand Down
2 changes: 1 addition & 1 deletion tests/components/logbook/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def create_state_changed_event_from_old_new(
if new_state is not None:
attributes = new_state.get("attributes")
attributes_json = json.dumps(attributes, cls=JSONEncoder)
row = collections.namedtuple(
row = collections.namedtuple( # noqa: PYI024
"Row",
[
"event_type",
Expand Down
2 changes: 1 addition & 1 deletion tests/components/russound_rio/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"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)}
2 changes: 1 addition & 1 deletion tests/components/tplink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

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_CONFIG_FLOW = "homeassistant.components.tplink.config_flow"
Expand Down

0 comments on commit e734971

Please sign in to comment.