Replace lambda with attrgetter in homekit_controller (#99666)

pull/99677/head
J. Nick Koston 2023-09-05 10:36:43 -05:00 committed by GitHub
parent abb0537928
commit e9062bb1b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 3 deletions

View File

@ -5,6 +5,7 @@ import asyncio
from collections.abc import Callable, Iterable
from datetime import datetime, timedelta
import logging
from operator import attrgetter
from types import MappingProxyType
from typing import Any
@ -508,9 +509,7 @@ class HKDevice:
# Accessories need to be created in the correct order or setting up
# relationships with ATTR_VIA_DEVICE may fail.
for accessory in sorted(
self.entity_map.accessories, key=lambda accessory: accessory.aid
):
for accessory in sorted(self.entity_map.accessories, key=attrgetter("aid")):
device_info = self.device_info_for_accessory(accessory)
device = device_registry.async_get_or_create(