Enable Ruff D212 (#87347)

This commit is contained in:
Franck Nijhof 2023-02-03 23:08:48 +01:00 committed by GitHub
parent 97de0c6d9a
commit ca1a12898c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
237 changed files with 353 additions and 707 deletions

View File

@ -1,5 +1,4 @@
"""
Sphinx extension for ReadTheDocs-style "Edit on GitHub" links on the sidebar.
"""Sphinx extension for ReadTheDocs-style "Edit on GitHub" links on the sidebar.
Loosely based on https://github.com/astropy/astropy/pull/347
"""

View File

@ -1,5 +1,4 @@
"""
Support Legacy API password auth provider.
"""Support Legacy API password auth provider.
It will be removed when auth system production ready
"""
@ -71,8 +70,7 @@ class LegacyApiPasswordAuthProvider(AuthProvider):
async def async_user_meta_for_credentials(
self, credentials: Credentials
) -> UserMeta:
"""
Return info for the user.
"""Return info for the user.
Will be used to populate info when creating a new user.
"""

View File

@ -26,8 +26,7 @@ class StrEnum(str, Enum):
def _generate_next_value_(
name: str, start: int, count: int, last_values: list[Any]
) -> Any:
"""
Make `auto()` explicitly unsupported.
"""Make `auto()` explicitly unsupported.
We may revisit this when it's very clear that Python 3.11's
`StrEnum.auto()` behavior will no longer change.

View File

@ -1,5 +1,4 @@
"""
This package contains components that can be plugged into Home Assistant.
"""This package contains components that can be plugged into Home Assistant.
Component design guidelines:
- Each component defines a constant DOMAIN that is equal to its filename.

View File

@ -38,8 +38,7 @@ _LOGGER = logging.getLogger(__name__)
def set_update_interval(instances_count: int, requests_remaining: int) -> timedelta:
"""
Return data update interval.
"""Return data update interval.
The number of requests is reset at midnight UTC so we calculate the update
interval based on number of minutes until midnight, the number of Airly instances

View File

@ -16,8 +16,7 @@ _LOGGER = logging.getLogger(__name__)
async def validate_input(hass: core.HomeAssistant, data):
"""
Validate the user input allows us to connect.
"""Validate the user input allows us to connect.
Data has the keys from DATA_SCHEMA with values provided by the user.
"""

View File

@ -41,8 +41,7 @@ def async_setup(hass):
async def async_setup_intents(hass):
"""
Do intents setup.
"""Do intents setup.
Right now this module does not expose any, but the intent component breaks
without it.

View File

@ -24,8 +24,7 @@ def build_app_list(app_list: dict[str, str]) -> BrowseMedia:
def item_payload(item: dict[str, Any]) -> BrowseMedia:
"""
Create response payload for a single media item.
"""Create response payload for a single media item.
Used by async_browse_media.
"""

View File

@ -139,8 +139,7 @@ AutomationTriggerInfo = TriggerInfo
@bind_hass
def is_on(hass: HomeAssistant, entity_id: str) -> bool:
"""
Return true if specified automation entity_id is on.
"""Return true if specified automation entity_id is on.
Async friendly.
"""

View File

@ -217,8 +217,7 @@ class BayesianBinarySensor(BinarySensorEntity):
}
async def async_added_to_hass(self) -> None:
"""
Call when entity about to be added.
"""Call when entity about to be added.
All relevant update logic for instance attributes occurs within this closure.
Other methods in this class are designed to avoid directly modifying instance
@ -233,8 +232,7 @@ class BayesianBinarySensor(BinarySensorEntity):
@callback
def async_threshold_sensor_state_listener(event: Event) -> None:
"""
Handle sensor state changes.
"""Handle sensor state changes.
When a state changes, we must update our list of current observations,
then calculate the new probability.
@ -384,8 +382,7 @@ class BayesianBinarySensor(BinarySensorEntity):
return prior
def _build_observations_by_entity(self) -> dict[str, list[Observation]]:
"""
Build and return data structure of the form below.
"""Build and return data structure of the form below.
{
"sensor.sensor1": [Observation, Observation],
@ -414,8 +411,7 @@ class BayesianBinarySensor(BinarySensorEntity):
return observations_by_entity
def _build_observations_by_template(self) -> dict[Template, list[Observation]]:
"""
Build and return data structure of the form below.
"""Build and return data structure of the form below.
{
"template": [Observation, Observation],

View File

@ -26,8 +26,7 @@ _T = TypeVar("_T")
class ActiveBluetoothDataUpdateCoordinator(
PassiveBluetoothDataUpdateCoordinator, Generic[_T]
):
"""
A coordinator that receives passive data from advertisements but can also poll.
"""A coordinator that receives passive data from advertisements but can also poll.
Unlike the passive processor coordinator, this coordinator does call a parser
method to parse the data from the advertisement.

View File

@ -96,8 +96,7 @@ async def see_device(
async def get_tracking_devices(hass: HomeAssistant) -> tuple[set[str], set[str]]:
"""
Load all known devices.
"""Load all known devices.
We just need the devices so set consider_home and home range to 0
"""

View File

@ -55,8 +55,7 @@ async def async_setup_entry(
class BruntDevice(
CoordinatorEntity[DataUpdateCoordinator[dict[str | None, Thing]]], CoverEntity
):
"""
Representation of a Brunt cover device.
"""Representation of a Brunt cover device.
Contains the common logic for all Brunt devices.
"""
@ -105,8 +104,7 @@ class BruntDevice(
@property
def current_cover_position(self) -> int | None:
"""
Return current position of cover.
"""Return current position of cover.
None is unknown, 0 is closed, 100 is fully open.
"""
@ -114,8 +112,7 @@ class BruntDevice(
@property
def request_cover_position(self) -> int | None:
"""
Return request position of cover.
"""Return request position of cover.
The request position is the position of the last request
to Brunt, at times there is a diff of 1 to current
@ -125,8 +122,7 @@ class BruntDevice(
@property
def move_state(self) -> int | None:
"""
Return current moving state of cover.
"""Return current moving state of cover.
None is unknown, 0 when stopped, 1 when opening, 2 when closing
"""

View File

@ -51,8 +51,7 @@ async def async_setup_entry(
class BuienradarCam(Camera):
"""
A camera component producing animated buienradar radar-imagery GIFs.
"""A camera component producing animated buienradar radar-imagery GIFs.
Rain radar imagery camera based on image URL taken from [0].
@ -62,8 +61,7 @@ class BuienradarCam(Camera):
def __init__(
self, latitude: float, longitude: float, delta: float, country: str
) -> None:
"""
Initialize the component.
"""Initialize the component.
This constructor must be run in the event loop.
"""
@ -145,8 +143,7 @@ class BuienradarCam(Camera):
async def async_camera_image(
self, width: int | None = None, height: int | None = None
) -> bytes | None:
"""
Return a still image response from the camera.
"""Return a still image response from the camera.
Uses asyncio conditions to make sure only one task enters the critical
section at the same time. Otherwise, two http requests would start

View File

@ -70,8 +70,7 @@ def scale_jpeg_camera_image(cam_image: Image, width: int, height: int) -> bytes:
class TurboJPEGSingleton:
"""
Load TurboJPEG only once.
"""Load TurboJPEG only once.
Ensures we do not log load failures each snapshot
since camera image fetches happen every few

View File

@ -476,8 +476,7 @@ class CastMediaPlayerEntity(CastDevice, MediaPlayerEntity):
# ========== Service Calls ==========
def _media_controller(self):
"""
Return media controller.
"""Return media controller.
First try from our own cast, then groups which our cast is a member in.
"""
@ -753,8 +752,7 @@ class CastMediaPlayerEntity(CastDevice, MediaPlayerEntity):
)
def _media_status(self):
"""
Return media status.
"""Return media status.
First try from our own cast, then groups which our cast is a member in.
"""

View File

@ -64,8 +64,7 @@ class CiscoDeviceScanner(DeviceScanner):
return self.last_results
def _update_info(self):
"""
Ensure the information from the Cisco router is up to date.
"""Ensure the information from the Cisco router is up to date.
Returns boolean if scanning successful.
"""
@ -139,8 +138,7 @@ class CiscoDeviceScanner(DeviceScanner):
def _parse_cisco_mac_address(cisco_hardware_addr):
"""
Parse a Cisco formatted HW address to normal MAC.
"""Parse a Cisco formatted HW address to normal MAC.
e.g. convert
001d.ec02.07ab

View File

@ -78,8 +78,7 @@ class CiscoMEDeviceScanner(DeviceScanner):
return name
def get_extra_attributes(self, device):
"""
Get extra attributes of a device.
"""Get extra attributes of a device.
Some known extra attributes that may be returned in the device tuple
include SSID, PT (eg 802.11ac), devtype (eg iPhone 7) among others.

View File

@ -24,8 +24,7 @@ def async_manage_legacy_subscription_issue(
hass: HomeAssistant,
subscription_info: dict[str, Any],
) -> None:
"""
Manage the legacy subscription issue.
"""Manage the legacy subscription issue.
If the provider is "legacy" create an issue,
in all other cases remove the issue.

View File

@ -1,5 +1,4 @@
"""
Support to allow pieces of code to request configuration from the user.
"""Support to allow pieces of code to request configuration from the user.
Initiate a request by calling the `request_config` method with a callback.
This will return a request id that has to be used for future calls.

View File

@ -19,8 +19,7 @@ class CrownstoneBaseEntity(Entity):
@property
def cloud_id(self) -> str:
"""
Return the unique identifier for this device.
"""Return the unique identifier for this device.
Used as device ID and to generate unique entity ID's.
"""

View File

@ -52,8 +52,7 @@ class CrownstoneEntryManager:
self.usb_sphere_id: str | None = None
async def async_setup(self) -> bool:
"""
Set up a Crownstone config entry.
"""Set up a Crownstone config entry.
Returns True if the setup was successful.
"""

View File

@ -13,8 +13,7 @@ from .const import DONT_USE_USB, MANUAL_PATH, REFRESH_LIST
def list_ports_as_str(
serial_ports: list[ListPortInfo], no_usb_option: bool = True
) -> list[str]:
"""
Represent currently available serial ports as string.
"""Represent currently available serial ports as string.
Adds option to not use usb on top of the list,
option to use manual path or refresh list at the end.

View File

@ -65,8 +65,7 @@ def hass_to_crownstone_state(value: int) -> int:
class CrownstoneEntity(CrownstoneBaseEntity, LightEntity):
"""
Representation of a crownstone.
"""Representation of a crownstone.
Light platform is used to support dimming.
"""

View File

@ -1,5 +1,4 @@
"""
Listeners for updating data in the Crownstone integration.
"""Listeners for updating data in the Crownstone integration.
For data updates, Cloud Push is used in form of an SSE server that sends out events.
For fast device switching Local Push is used in form of a USB dongle that hooks into a BLE mesh.

View File

@ -747,8 +747,7 @@ class DarkSkySensor(SensorEntity):
self._attr_native_value = self.get_state(currently)
def get_state(self, data):
"""
Return a new state based on the type.
"""Return a new state based on the type.
If the sensor type is unknown, the current state is returned.
"""
@ -827,8 +826,7 @@ class DarkSkyAlertSensor(SensorEntity):
self._attr_native_value = self.get_state(alerts)
def get_state(self, data):
"""
Return a new state based on the type.
"""Return a new state based on the type.
If the sensor type is unknown, the current state is returned.
"""
@ -851,8 +849,7 @@ class DarkSkyAlertSensor(SensorEntity):
def convert_to_camel(data):
"""
Convert snake case (foo_bar_bat) to camel case (fooBarBat).
"""Convert snake case (foo_bar_bat) to camel case (fooBarBat).
This is not pythonic, but needed for certain situations.
"""

View File

@ -139,8 +139,7 @@ async def async_setup_entry(
def async_log_errors(
func: Callable[Concatenate[_DenonDeviceT, _P], Awaitable[_R]],
) -> Callable[Concatenate[_DenonDeviceT, _P], Coroutine[Any, Any, _R | None]]:
"""
Log errors occurred when calling a Denon AVR receiver.
"""Log errors occurred when calling a Denon AVR receiver.
Decorates methods of DenonDevice class.
Declaration of staticmethod for this method is at the end of this class.

View File

@ -301,8 +301,7 @@ class ConfiguredDoorBird:
return self.get_webhook_id(url, favs) is not None
def get_webhook_id(self, url, favs=None) -> str | None:
"""
Return the device favorite ID for the given URL.
"""Return the device favorite ID for the given URL.
The favorite must exist or there will be problems.
"""

View File

@ -1,5 +1,4 @@
"""
Support for Dublin RTPI information from data.dublinked.ie.
"""Support for Dublin RTPI information from data.dublinked.ie.
For more info on the API see :
https://data.gov.ie/dataset/real-time-passenger-information-rtpi-for-dublin-bus-bus-eireann-luas-and-irish-rail/resource/4b9f2c4f-6bf5-4958-a43a-f12dab04cf61

View File

@ -1,5 +1,4 @@
"""
Support for getting statistical data from a DWD Weather Warnings.
"""Support for getting statistical data from a DWD Weather Warnings.
Data is fetched from DWD:
https://rcccm.dwd.de/DE/wetter/warnungen_aktuell/objekt_einbindung/objekteinbindung.html

View File

@ -1,5 +1,4 @@
"""
Support for EBox.
"""Support for EBox.
Get data from 'My Usage Page' page: https://client.ebox.ca/myusage
"""

View File

@ -32,8 +32,7 @@ class EcoalSwitch(SwitchEntity):
"""Representation of Ecoal switch."""
def __init__(self, ecoal_contr, name, state_attr):
"""
Initialize switch.
"""Initialize switch.
Sets HA switch to state as read from controller.
"""

View File

@ -29,8 +29,7 @@ CONFIG_SCHEMA = vol.Schema(
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""
Ecobee uses config flow for configuration.
"""Ecobee uses config flow for configuration.
But, an "ecobee:" entry in configuration.yaml will trigger an import flow
if a config entry doesn't already exist. If ecobee.conf exists, the import
@ -87,8 +86,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
class EcobeeData:
"""
Handle getting the latest data from ecobee.com so platforms can use it.
"""Handle getting the latest data from ecobee.com so platforms can use it.
Also handle refreshing tokens and updating config entry with refreshed tokens.
"""

View File

@ -76,8 +76,7 @@ class EcobeeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
)
async def async_step_import(self, import_data):
"""
Import ecobee config from configuration.yaml.
"""Import ecobee config from configuration.yaml.
Triggered by async_setup only if a config entry doesn't already exist.
If ecobee.conf exists, we will attempt to validate the credentials

View File

@ -1,5 +1,4 @@
"""
Read temperature information from Eddystone beacons.
"""Read temperature information from Eddystone beacons.
Your beacons must be configured to transmit UID (for identification) and TLM
(for temperature) frames.

View File

@ -236,8 +236,7 @@ class EmbyDevice(MediaPlayerEntity):
@property
def media_position_updated_at(self):
"""
When was the position of the current playing media valid.
"""When was the position of the current playing media valid.
Returns value from homeassistant.util.dt.utcnow().
"""

View File

@ -1,5 +1,4 @@
"""
Support for Fido.
"""Support for Fido.
Get data from 'Usage Summary' page:
https://www.fido.ca/pages/#/my-account/wireless

View File

@ -1,5 +1,4 @@
"""
Flux for Home-Assistant.
"""Flux for Home-Assistant.
The idea was taken from https://github.com/KpaBap/hue-flux/
"""

View File

@ -1,5 +1,4 @@
"""
Support to use FortiOS device like FortiGate as device tracker.
"""Support to use FortiOS device like FortiGate as device tracker.
This component is part of the device_tracker platform.
"""

View File

@ -86,8 +86,7 @@ class FroniusCoordinatorBase(
async_add_entities: AddEntitiesCallback,
entity_constructor: type[_FroniusEntityT],
) -> None:
"""
Add entities for received keys and registers listener for future seen keys.
"""Add entities for received keys and registers listener for future seen keys.
Called from a platforms `async_setup_entry`.
"""

View File

@ -27,8 +27,7 @@ _LOGGER = logging.getLogger(__name__)
def _item_preset_payload(preset: Preset, player_mode: str) -> BrowseMedia:
"""
Create response payload for a single media item.
"""Create response payload for a single media item.
Used by async_browse_media.
"""
@ -47,8 +46,7 @@ def _item_preset_payload(preset: Preset, player_mode: str) -> BrowseMedia:
def _item_payload(
key, item: dict[str, str], player_mode: str, parent_keys: list[str]
) -> BrowseMedia:
"""
Create response payload for a single media item.
"""Create response payload for a single media item.
Used by async_browse_media.
"""
@ -76,8 +74,7 @@ def _item_payload(
async def browse_top_level(current_mode, afsapi: AFSAPI):
"""
Create response payload to describe contents of a specific library.
"""Create response payload to describe contents of a specific library.
Used by async_browse_media.
"""

View File

@ -31,8 +31,7 @@ async def async_setup_services(hass: HomeAssistant) -> None:
*args: list[str],
**kwargs: dict[str, Any],
) -> None:
"""
Execute a Fully service call.
"""Execute a Fully service call.
:param call: {ServiceCall} HA service call.
:param fully_method: {Callable} A method of the FullyKiosk class.

View File

@ -1,5 +1,4 @@
"""
Generic GeoRSS events service.
"""Generic GeoRSS events service.
Retrieves current events (typically incidents or alerts) in GeoRSS format, and
shows information on events filtered by distance to the HA instance's location

View File

@ -110,8 +110,7 @@ class InMemoryStorage:
self.mem: dict[str, bytes] = {}
def store_and_get_identifier(self, data: bytes) -> str:
"""
Temporarily store data and return identifier to be able to retrieve it.
"""Temporarily store data and return identifier to be able to retrieve it.
Data expires after 5 minutes.
"""

View File

@ -25,8 +25,7 @@ LANG_TO_BROADCAST_COMMAND = {
def broadcast_commands(language_code: str):
"""
Get the commands for broadcasting a message for the given language code.
"""Get the commands for broadcasting a message for the given language code.
Return type is a tuple where [0] is for broadcasting to your entire home,
while [1] is for broadcasting to a specific target.

View File

@ -1,5 +1,4 @@
"""
Growatt Sensor definitions for the TLX type.
"""Growatt Sensor definitions for the TLX type.
TLX Type is also shown on the UI as: "MIN/MIC/MOD/NEO"
"""

View File

@ -308,8 +308,7 @@ def setup(hass: HomeAssistant, base_config: ConfigType) -> bool: # noqa: C901
_LOGGER.info("Selected %s (%s)", call.data[ATTR_DEVICE], addr)
def _update(call: ServiceCall) -> None:
"""
Update if device update is needed.
"""Update if device update is needed.
Called by service, requests CEC network to update data.
"""

View File

@ -458,8 +458,7 @@ class SourceManager:
)
def connect_update(self, hass, controller):
"""
Connect listener for when sources change and signal player update.
"""Connect listener for when sources change and signal player update.
EVENT_SOURCES_CHANGED is often raised multiple times in response to a
physical event therefore throttle it. Retrieving sources immediately

View File

@ -1,5 +1,4 @@
"""
Manage allocation of accessory ID's.
"""Manage allocation of accessory ID's.
HomeKit needs to allocate unique numbers to each accessory. These need to
be stable between reboots and upgrades.
@ -60,8 +59,7 @@ def _generate_aids(unique_id: str | None, entity_id: str) -> Generator[int, None
class AccessoryAidStorage:
"""
Holds a map of entity ID to HomeKit ID.
"""Holds a map of entity ID to HomeKit ID.
Will generate new ID's, ensure they are unique and store them to make sure they
persist over reboots.

View File

@ -1,5 +1,4 @@
"""
Manage allocation of instance ID's.
"""Manage allocation of instance ID's.
HomeKit needs to allocate unique numbers to each accessory. These need to
be stable between reboots and upgrades.
@ -61,8 +60,7 @@ class IIDStorage(Store):
class AccessoryIIDStorage:
"""
Provide stable allocation of IIDs for the lifetime of an accessory.
"""Provide stable allocation of IIDs for the lifetime of an accessory.
Will generate new ID's, ensure they are unique and store them to make sure they
persist over reboots.

View File

@ -1,5 +1,4 @@
"""
Support for Homekit buttons.
"""Support for Homekit buttons.
These are mostly used where a HomeKit accessory exposes additional non-standard
characteristics that don't map to a Home Assistant feature.

View File

@ -91,8 +91,7 @@ def find_existing_host(
def ensure_pin_format(pin: str, allow_insecure_setup_codes: Any = None) -> str:
"""
Ensure a pin code is correctly formatted.
"""Ensure a pin code is correctly formatted.
Ensures a pin code is in the format 111-11-111. Handles codes with and without dashes.

View File

@ -465,8 +465,7 @@ class HKDevice:
@callback
def async_create_devices(self) -> None:
"""
Build device registry entries for all accessories paired with the bridge.
"""Build device registry entries for all accessories paired with the bridge.
This is done as well as by the entities for 2 reasons. First, the bridge
might not have any entities attached to it. Secondly there are stateless
@ -536,8 +535,7 @@ class HKDevice:
self.unreliable_serial_numbers = unreliable_serial_numbers
async def async_process_entity_map(self) -> None:
"""
Process the entity map and load any platforms or entities that need adding.
"""Process the entity map and load any platforms or entities that need adding.
This is idempotent and will be called at startup and when we detect metadata changes
via the c# counter on the zeroconf record.
@ -759,8 +757,7 @@ class HKDevice:
@property
def unique_id(self) -> str:
"""
Return a unique id for this accessory or bridge.
"""Return a unique id for this accessory or bridge.
This id is random and will change if a device undergoes a hard reset.
"""

View File

@ -72,8 +72,7 @@ class HomeKitEntity(Entity):
self._accessory.remove_watchable_characteristics(self._aid)
async def async_put_characteristics(self, characteristics: dict[str, Any]) -> None:
"""
Write characteristics to the device.
"""Write characteristics to the device.
A characteristic type is unique within a service, but in order to write
to a named characteristic on a bridge we need to turn its type into
@ -195,8 +194,7 @@ class AccessoryEntity(HomeKitEntity):
class CharacteristicEntity(HomeKitEntity):
"""
A HomeKit entity that is related to an single characteristic rather than a whole service.
"""A HomeKit entity that is related to an single characteristic rather than a whole service.
This is typically used to expose additional sensor, binary_sensor or number entities that don't belong with
the service entity.

View File

@ -1,5 +1,4 @@
"""
Support for Homekit number ranges.
"""Support for Homekit number ranges.
These are mostly used where a HomeKit accessory exposes additional non-standard
characteristics that don't map to a Home Assistant feature.

View File

@ -55,8 +55,7 @@ class HomeKitSensorEntityDescription(SensorEntityDescription):
def thread_node_capability_to_str(char: Characteristic) -> str:
"""
Return the thread device type as a string.
"""Return the thread device type as a string.
The underlying value is a bitmask, but we want to turn that to
a human readable string. Some devices will have multiple capabilities.
@ -93,8 +92,7 @@ def thread_node_capability_to_str(char: Characteristic) -> str:
def thread_status_to_str(char: Characteristic) -> str:
"""
Return the thread status as a string.
"""Return the thread status as a string.
The underlying value is a bitmask, but we want to turn that to
a human readable string. So we check the flags in order. E.g. BORDER_ROUTER implies
@ -501,8 +499,7 @@ class HomeKitBatterySensor(HomeKitSensor):
class SimpleSensor(CharacteristicEntity, SensorEntity):
"""
A simple sensor for a single characteristic.
"""A simple sensor for a single characteristic.
This may be an additional secondary entity that is part of another service. An
example is a switch that has an energy sensor.

View File

@ -19,8 +19,7 @@ _LOGGER = logging.getLogger(__name__)
class EntityMapStorage:
"""
Holds a cache of entity structure data from a paired HomeKit device.
"""Holds a cache of entity structure data from a paired HomeKit device.
HomeKit has a cacheable entity map that describes how an IP or BLE
endpoint is structured. This object holds the latest copy of that data.

View File

@ -44,8 +44,7 @@ class HMCover(HMDevice, CoverEntity):
@property
def current_cover_position(self) -> int | None:
"""
Return current position of cover.
"""Return current position of cover.
None is unknown, 0 is closed, 100 is fully open.
"""
@ -126,8 +125,7 @@ class HMGarage(HMCover):
@property
def current_cover_position(self) -> None:
"""
Return current position of cover.
"""Return current position of cover.
None is unknown, 0 is closed, 100 is fully open.
"""

View File

@ -131,8 +131,7 @@ class HomematicipHeatingGroup(HomematicipGenericEntity, ClimateEntity):
@property
def hvac_action(self) -> HVACAction | None:
"""
Return the current hvac_action.
"""Return the current hvac_action.
This is only relevant for radiator thermostats.
"""

View File

@ -256,8 +256,7 @@ class HomematicipNotificationLight(HomematicipGenericEntity, LightEntity):
def _convert_color(color: tuple) -> RGBColorState:
"""
Convert the given color to the reduced RGBColorState color.
"""Convert the given color to the reduced RGBColorState color.
RGBColorStat contains only 8 colors including white and black,
so a conversion is required.

View File

@ -139,8 +139,7 @@ async def async_setup_auth(hass: HomeAssistant, app: Application) -> None:
hass.data[STORAGE_KEY] = refresh_token.id
async def async_validate_auth_header(request: Request) -> bool:
"""
Test authorization header against access token.
"""Test authorization header against access token.
Basic auth_type is legacy code, should be removed with api_password.
"""

View File

@ -456,8 +456,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
)
def _update_router(*_: Any) -> None:
"""
Update router data.
"""Update router data.
Separate passthrough function because lambdas don't work with track_time_interval.
"""
@ -496,8 +495,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
hass.data[DOMAIN] = HuaweiLteData(hass_config=config, routers={})
def service_handler(service: ServiceCall) -> None:
"""
Apply a service.
"""Apply a service.
We key this using the router URL instead of its unique id / serial number,
because the latter is not available anywhere in the UI.

View File

@ -251,8 +251,7 @@ class ConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
self._abort_if_unique_id_configured(updates={CONF_URL: url})
def _is_supported_device() -> bool:
"""
See if we are looking at a possibly supported device.
"""See if we are looking at a possibly supported device.
Matching solely on SSDP data does not yield reliable enough results.
"""

View File

@ -122,8 +122,7 @@ def _get_cumulative_value(
source_type: str,
period_type: str,
):
"""
Get the cumulative energy consumption for a certain period.
"""Get the cumulative energy consumption for a certain period.
:param current_measurements: The result from the Huisbaasje client
:param source_type: The source of energy (electricity or gas)

View File

@ -219,8 +219,7 @@ class EmailContentSensor(SensorEntity):
@staticmethod
def get_msg_text(email_message):
"""
Get the message text from the email.
"""Get the message text from the email.
Will look for text/plain or use text/html if not found.
"""

View File

@ -223,8 +223,7 @@ class ControllerDevice(ClimateEntity):
@callback
def set_available(self, available: bool, ex: Exception | None = None) -> None:
"""
Set availability for the controller.
"""Set availability for the controller.
Also sets zone availability as they follow the same availability.
"""

View File

@ -114,8 +114,7 @@ ia_validator = vol.Any(
def ip_v4_validator(value: Any, multicast: bool | None = None) -> str:
"""
Validate that value is parsable as IPv4 address.
"""Validate that value is parsable as IPv4 address.
Optionally check if address is in a reserved multicast block or is explicitly not.
"""

View File

@ -84,8 +84,7 @@ async def build_item_response(media_library, payload, get_thumbnail_url=None):
async def item_payload(item, get_thumbnail_url=None):
"""
Create response payload for a single media item.
"""Create response payload for a single media item.
Used by async_browse_media.
"""
@ -179,8 +178,7 @@ def media_source_content_filter(item: BrowseMedia) -> bool:
async def library_payload(hass):
"""
Create response payload to describe contents of a specific library.
"""Create response payload to describe contents of a specific library.
Used by async_browse_media.
"""

View File

@ -42,8 +42,7 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
class LircInterface(threading.Thread):
"""
This interfaces with the lirc daemon to read IR commands.
"""This interfaces with the lirc daemon to read IR commands.
When using lirc in blocking mode, sometimes repeated commands get produced
in the next read of a command so we use a thread here to just wait

View File

@ -77,8 +77,7 @@ class LuciDeviceScanner(DeviceScanner):
return name
def get_extra_attributes(self, device):
"""
Get extra attributes of a device.
"""Get extra attributes of a device.
Some known extra attributes that may be returned in the device tuple
include MAC address (mac), network device (dev), IP address

View File

@ -174,8 +174,7 @@ def setup_platform(
class ManualAlarm(alarm.AlarmControlPanelEntity, RestoreEntity):
"""
Representation of an alarm status.
"""Representation of an alarm status.
When armed, will be arming for 'arming_time', after that armed.
When triggered, will be pending for the triggering state's 'delay_time'.
@ -339,8 +338,7 @@ class ManualAlarm(alarm.AlarmControlPanelEntity, RestoreEntity):
self._async_update_state(STATE_ALARM_ARMED_CUSTOM_BYPASS)
async def async_alarm_trigger(self, code: str | None = None) -> None:
"""
Send alarm trigger command.
"""Send alarm trigger command.
No code needed, a trigger time of zero for the current state
disables the alarm.

View File

@ -216,8 +216,7 @@ def setup_platform(
class ManualMQTTAlarm(alarm.AlarmControlPanelEntity):
"""
Representation of an alarm status.
"""Representation of an alarm status.
When armed, will be pending for 'pending_time', after that armed.
When triggered, will be pending for the triggering state's 'delay_time'
@ -397,8 +396,7 @@ class ManualMQTTAlarm(alarm.AlarmControlPanelEntity):
self._async_update_state(STATE_ALARM_ARMED_CUSTOM_BYPASS)
async def async_alarm_trigger(self, code: str | None = None) -> None:
"""
Send alarm trigger command.
"""Send alarm trigger command.
No code needed, a trigger time of zero for the current state
disables the alarm.

View File

@ -276,8 +276,7 @@ class MatrixBot:
_LOGGER.error("Could not join room %s: %s", room_id, ex)
def _get_auth_tokens(self):
"""
Read sorted authentication tokens from disk.
"""Read sorted authentication tokens from disk.
Returns the auth_tokens dictionary.
"""

View File

@ -134,8 +134,7 @@ class MaxCubeClimate(ClimateEntity):
raise ValueError(f"unsupported HVAC mode {hvac_mode}")
def _set_target(self, mode: int | None, temp: float | None) -> None:
"""
Set the mode and/or temperature of the thermostat.
"""Set the mode and/or temperature of the thermostat.
@param mode: this is the mode to change to.
@param temp: the temperature to target.

View File

@ -236,8 +236,7 @@ _ENTITY_IMAGE_CACHE = _ImageCache(images=collections.OrderedDict(), maxsize=16)
@bind_hass
def is_on(hass: HomeAssistant, entity_id: str | None = None) -> bool:
"""
Return true if specified media player entity_id is on.
"""Return true if specified media player entity_id is on.
Check all media player if no entity_id specified.
"""
@ -591,8 +590,7 @@ class MediaPlayerEntity(Entity):
media_content_id: str,
media_image_id: str | None = None,
) -> tuple[bytes | None, str | None]:
"""
Optionally fetch internally accessible image for media browser.
"""Optionally fetch internally accessible image for media browser.
Must be implemented by integration.
"""
@ -1198,8 +1196,7 @@ async def websocket_browse_media(
connection: websocket_api.connection.ActiveConnection,
msg: dict[str, Any],
) -> None:
"""
Browse media available to the media_player entity.
"""Browse media available to the media_player entity.
To use, media_player integrations can implement
MediaPlayerEntity.async_browse_media()

View File

@ -192,8 +192,7 @@ class LocalSource(MediaSource):
class LocalMediaView(http.HomeAssistantView):
"""
Local Media Finder View.
"""Local Media Finder View.
Returns media files in config/media.
"""

View File

@ -187,8 +187,7 @@ class MinioEventThread(threading.Thread):
def iterate_objects(event):
"""
Iterate over file records of notification event.
"""Iterate over file records of notification event.
Most of the time it should still be only one record.
"""

View File

@ -230,8 +230,7 @@ class MotionPositionDevice(CoordinatorEntity, CoverEntity):
@property
def current_cover_position(self) -> int | None:
"""
Return current position of cover.
"""Return current position of cover.
None is unknown, 0 is open, 100 is closed.
"""
@ -343,8 +342,7 @@ class MotionTiltDevice(MotionPositionDevice):
@property
def current_cover_tilt_position(self) -> int | None:
"""
Return current angle of cover.
"""Return current angle of cover.
None is unknown, 0 is closed/minimum tilt, 100 is fully open/maximum tilt.
"""
@ -440,8 +438,7 @@ class MotionTDBUDevice(MotionPositionDevice):
@property
def current_cover_position(self) -> int | None:
"""
Return current position of cover.
"""Return current position of cover.
None is unknown, 0 is open, 100 is closed.
"""

View File

@ -748,8 +748,7 @@ class MqttCover(MqttEntity, CoverEntity):
def find_in_range_from_percent(
self, percentage: float, range_type: str = TILT_PAYLOAD
) -> int:
"""
Find the adjusted value for 0-100% within the specified range.
"""Find the adjusted value for 0-100% within the specified range.
if the range is 80-180 and the percentage is 90
this method would determine the value to send on the topic

View File

@ -168,8 +168,7 @@ class NAD(MediaPlayerEntity):
)
def calc_volume(self, decibel):
"""
Calculate the volume given the decibel.
"""Calculate the volume given the decibel.
Return the volume (0..1).
"""
@ -178,8 +177,7 @@ class NAD(MediaPlayerEntity):
)
def calc_db(self, volume):
"""
Calculate the decibel given the volume.
"""Calculate the decibel given the volume.
Return the dB.
"""

View File

@ -82,8 +82,7 @@ CANCEL_ETA_SCHEMA = vol.Schema(
def nest_update_event_broker(hass, nest):
"""
Dispatch SIGNAL_NEST_UPDATE to devices when nest stream API received data.
"""Dispatch SIGNAL_NEST_UPDATE to devices when nest stream API received data.
Used for the legacy nest API.

View File

@ -156,8 +156,7 @@ class NetatmoDataHandler:
await self.async_dispatch()
async def async_update(self, event_time: datetime) -> None:
"""
Update device.
"""Update device.
We do up to BATCH_SIZE calls in one update in order
to minimize the calls on the api service.

View File

@ -163,8 +163,7 @@ class NukiCoordinator(DataUpdateCoordinator[None]):
self.hass.bus.async_fire("nuki_event", event_data)
def update_devices(self, devices: list[NukiDevice]) -> dict[str, set[str]]:
"""
Update the Nuki devices.
"""Update the Nuki devices.
Returns:
A dict with the events to be fired. The event type is the key and the device ids are the value

View File

@ -43,8 +43,7 @@ def base_unique_id(latitude: float, longitude: float) -> str:
class NwsDataUpdateCoordinator(DataUpdateCoordinator[None]):
"""
NWS data update coordinator.
"""NWS data update coordinator.
Implements faster data update intervals for failed updates and exposes a last successful update time.
"""

View File

@ -55,8 +55,7 @@ PARALLEL_UPDATES = 0
def convert_condition(
time: str, weather: tuple[tuple[str, int | None], ...]
) -> tuple[str, int | None]:
"""
Convert NWS codes to HA condition.
"""Convert NWS codes to HA condition.
Choose first condition in CONDITION_CLASSES that exists in weather code.
If no match is found, return first condition from NWS

View File

@ -355,8 +355,7 @@ class OnkyoDevice(MediaPlayerEntity):
self.command("system-power standby")
def set_volume_level(self, volume: float) -> None:
"""
Set volume level, input is range 0..1.
"""Set volume level, input is range 0..1.
However full volume on the amp is usually far too loud so allow the user to specify the upper range
with CONF_MAX_VOLUME. we change as per max_volume set by user. This means that if max volume is 80 then full
@ -523,8 +522,7 @@ class OnkyoDeviceZone(OnkyoDevice):
self.command(f"zone{self._zone}.power=standby")
def set_volume_level(self, volume: float) -> None:
"""
Set volume level, input is range 0..1.
"""Set volume level, input is range 0..1.
However full volume on the amp is usually far too loud so allow the user to specify the upper range
with CONF_MAX_VOLUME. we change as per max_volume set by user. This means that if max volume is 80 then full

View File

@ -86,8 +86,7 @@ class OpenThermGwConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return await self.async_step_init(user_input)
async def async_step_import(self, import_config):
"""
Import an OpenTherm Gateway device as a config entry.
"""Import an OpenTherm Gateway device as a config entry.
This flow is triggered by `async_setup` for configured devices.
"""

View File

@ -45,8 +45,7 @@ class Awning(OverkizGenericCover):
@property
def current_cover_position(self) -> int | None:
"""
Return current position of cover.
"""Return current position of cover.
None is unknown, 0 is closed, 100 is fully open.
"""

View File

@ -75,8 +75,7 @@ class VerticalCover(OverkizGenericCover):
@property
def current_cover_position(self) -> int | None:
"""
Return current position of cover.
"""Return current position of cover.
None is unknown, 0 is closed, 100 is fully open.
"""

View File

@ -152,8 +152,7 @@ class OverkizExecutor:
await self.coordinator.client.cancel_command(exec_id)
def get_gateway_id(self) -> str:
"""
Retrieve gateway id from device url.
"""Retrieve gateway id from device url.
device URL (<protocol>://<gatewayId>/<deviceAddress>[#<subsystemId>])
"""

View File

@ -91,8 +91,7 @@ class PanasonicBluRay(MediaPlayerEntity):
self._attr_media_duration = state[2]
def turn_off(self) -> None:
"""
Instruct the device to turn standby.
"""Instruct the device to turn standby.
Sending the "POWER" button will turn the device to standby - there
is no way to turn it completely off remotely. However this works in

View File

@ -255,8 +255,7 @@ class PandoraMediaPlayer(MediaPlayerEntity):
@util.Throttle(MIN_TIME_BETWEEN_UPDATES)
def _update_song_position(self):
"""
Get the song position and duration.
"""Get the song position and duration.
It's hard to predict whether or not the music will start during init
so we have to detect state by checking the ticker.
@ -312,8 +311,7 @@ class PandoraMediaPlayer(MediaPlayerEntity):
self._pianobar.sendcontrol("m") # do it twice in case an 'i' got in
def _clear_buffer(self):
"""
Clear buffer from pexpect.
"""Clear buffer from pexpect.
This is necessary because there are a bunch of 00:00 in the buffer

View File

@ -62,8 +62,7 @@ def _base_gw_schema(discovery_info: ZeroconfServiceInfo | None) -> vol.Schema:
async def validate_gw_input(hass: HomeAssistant, data: dict[str, Any]) -> Smile:
"""
Validate whether the user input allows us to connect to the gateway.
"""Validate whether the user input allows us to connect to the gateway.
Data has the keys from _base_gw_schema() with values provided by the user.
"""

View File

@ -349,8 +349,7 @@ def get_significant_states_with_session(
no_attributes: bool = False,
compressed_state_format: bool = False,
) -> MutableMapping[str, list[State | dict[str, Any]]]:
"""
Return states changes during UTC period start_time - end_time.
"""Return states changes during UTC period start_time - end_time.
entity_ids is an optional iterable of entities to include in the results.

View File

@ -1,5 +1,4 @@
"""
Support for Rejseplanen information from rejseplanen.dk.
"""Support for Rejseplanen information from rejseplanen.dk.
For more info on the API see:
https://help.rejseplanen.dk/hc/en-us/articles/214174465-Rejseplanen-s-API

View File

@ -222,8 +222,7 @@ def item_payload(
coordinator: RokuDataUpdateCoordinator,
get_browse_image_url: GetBrowseImageUrlType,
) -> BrowseMedia:
"""
Create response payload for a single media item.
"""Create response payload for a single media item.
Used by async_browse_media.
"""

View File

@ -1,5 +1,4 @@
"""
A sensor platform which detects underruns and capped status from the official Raspberry Pi Kernel.
"""A sensor platform which detects underruns and capped status from the official Raspberry Pi Kernel.
Minimal Kernel needed is 4.14+
"""

View File

@ -145,8 +145,7 @@ async def migrate_unique_id(hass: HomeAssistant, entry: ConfigEntry):
@callback
def async_migrate_callback(entity_entry: RegistryEntry) -> dict | None:
"""
Define a callback to migrate appropriate SabnzbdSensor entities to new unique IDs.
"""Define a callback to migrate appropriate SabnzbdSensor entities to new unique IDs.
Old: description.key
New: {entry_id}_description.key

View File

@ -153,8 +153,7 @@ class SharkVacuumEntity(CoordinatorEntity[SharkIqUpdateCoordinator], StateVacuum
@property
def state(self) -> str | None:
"""
Get the current vacuum state.
"""Get the current vacuum state.
NB: Currently, we do not return an error state because they can be very, very stale.
In the app, these are (usually) handled by showing the robot as stopped and sending the

View File

@ -59,8 +59,7 @@ class SirenTurnOnServiceParameters(TypedDict, total=False):
def process_turn_on_params(
siren: SirenEntity, params: SirenTurnOnServiceParameters
) -> SirenTurnOnServiceParameters:
"""
Process turn_on service params.
"""Process turn_on service params.
Filters out unsupported params and validates the rest.
"""
@ -178,8 +177,7 @@ class SirenEntity(ToggleEntity):
@property
def available_tones(self) -> list[int | str] | dict[int, str] | None:
"""
Return a list of available tones.
"""Return a list of available tones.
Requires SirenEntityFeature.TONES.
"""

Some files were not shown because too many files have changed in this diff Show More