[pre-commit.ci] pre-commit autoupdate (#882)

* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.1.6 → v0.2.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.6...v0.2.0)
- [github.com/psf/black: 23.11.0 → 24.1.1](https://github.com/psf/black/compare/23.11.0...24.1.1)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
pre-commit-ci[bot] 2024-02-05 14:13:13 -08:00 committed by GitHub
commit 95a59438b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 45 additions and 28 deletions

View file

@ -1,4 +1,5 @@
"""Creates a services.yaml file with the latest docs."""
import sys
from pathlib import Path
@ -6,7 +7,7 @@ import yaml
sys.path.append(str(Path(__file__).parent.parent))
from custom_components.adaptive_lighting import const # noqa: E402
from custom_components.adaptive_lighting import const
services_filename = Path("custom_components") / "adaptive_lighting" / "services.yaml"
with open(services_filename) as f: # noqa: PTH123

View file

@ -1,4 +1,5 @@
"""Update strings.json and en.json from const.py."""
import json
import sys
from pathlib import Path
@ -8,7 +9,7 @@ import yaml
sys.path.append(str(Path(__file__).parent.parent))
from custom_components.adaptive_lighting import const # noqa: E402
from custom_components.adaptive_lighting import const
folder = Path("custom_components") / "adaptive_lighting"
strings_fname = folder / "strings.json"

View file

@ -8,11 +8,11 @@ repos:
- id: mixed-line-ending
args: ["--fix=lf"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
rev: v0.2.0
hooks:
- id: ruff
args: ["--fix"]
- repo: https://github.com/psf/black
rev: 23.11.0
rev: 24.1.1
hooks:
- id: black

View file

@ -1,4 +1,5 @@
"""Adaptive Lighting integration in Home-Assistant."""
import logging
from typing import Any

View file

@ -1,4 +1,5 @@
"""Utility functions for adaptation commands."""
import logging
from collections.abc import AsyncGenerator
from dataclasses import dataclass

View file

@ -1,4 +1,5 @@
"""Switch for the Adaptive Lighting integration."""
from __future__ import annotations
import bisect
@ -432,6 +433,7 @@ def find_a_b(x1: float, x2: float, y1: float, y2: float) -> tuple[float, float]:
Notes
-----
The values of y1 and y2 should lie between 0 and 1, inclusive.
"""
a = (math.atanh(2 * y2 - 1) - math.atanh(2 * y1 - 1)) / (x2 - x1)
b = x1 - (math.atanh(2 * y1 - 1) / a)
@ -477,6 +479,7 @@ def scaled_tanh(
Returns
-------
float: The output of the function, which lies in the range [y_min, y_max].
"""
a, b = find_a_b(x1, x2, y1, y2)
return y_min + (y_max - y_min) * 0.5 * (math.tanh(a * (x - b)) + 1)

View file

@ -1,4 +1,5 @@
"""Config flow for Adaptive Lighting integration."""
import logging
import homeassistant.helpers.config_validation as cv

View file

@ -50,9 +50,9 @@ DOCS[CONF_INITIAL_TRANSITION] = (
)
CONF_SLEEP_TRANSITION, DEFAULT_SLEEP_TRANSITION = "sleep_transition", 1
DOCS[
CONF_SLEEP_TRANSITION
] = 'Duration of transition when "sleep mode" is toggled in seconds. 😴'
DOCS[CONF_SLEEP_TRANSITION] = (
'Duration of transition when "sleep mode" is toggled in seconds. 😴'
)
CONF_INTERVAL, DEFAULT_INTERVAL = "interval", 90
DOCS[CONF_INTERVAL] = "Frequency to adapt the lights, in seconds. 🔄"
@ -112,30 +112,30 @@ DOCS[CONF_SLEEP_COLOR_TEMP] = (
)
CONF_SLEEP_RGB_COLOR, DEFAULT_SLEEP_RGB_COLOR = "sleep_rgb_color", [255, 56, 0]
DOCS[
CONF_SLEEP_RGB_COLOR
] = 'RGB color in sleep mode (used when `sleep_rgb_or_color_temp` is "rgb_color"). 🌈'
DOCS[CONF_SLEEP_RGB_COLOR] = (
'RGB color in sleep mode (used when `sleep_rgb_or_color_temp` is "rgb_color"). 🌈'
)
CONF_SLEEP_RGB_OR_COLOR_TEMP, DEFAULT_SLEEP_RGB_OR_COLOR_TEMP = (
"sleep_rgb_or_color_temp",
"color_temp",
)
DOCS[
CONF_SLEEP_RGB_OR_COLOR_TEMP
] = 'Use either `"rgb_color"` or `"color_temp"` in sleep mode. 🌙'
DOCS[CONF_SLEEP_RGB_OR_COLOR_TEMP] = (
'Use either `"rgb_color"` or `"color_temp"` in sleep mode. 🌙'
)
CONF_SUNRISE_OFFSET, DEFAULT_SUNRISE_OFFSET = "sunrise_offset", 0
DOCS[
CONF_SUNRISE_OFFSET
] = "Adjust sunrise time with a positive or negative offset in seconds. ⏰"
DOCS[CONF_SUNRISE_OFFSET] = (
"Adjust sunrise time with a positive or negative offset in seconds. ⏰"
)
CONF_SUNRISE_TIME = "sunrise_time"
DOCS[CONF_SUNRISE_TIME] = "Set a fixed time (HH:MM:SS) for sunrise. 🌅"
CONF_MIN_SUNRISE_TIME = "min_sunrise_time"
DOCS[
CONF_MIN_SUNRISE_TIME
] = "Set the earliest virtual sunrise time (HH:MM:SS), allowing for later sunrises. 🌅"
DOCS[CONF_MIN_SUNRISE_TIME] = (
"Set the earliest virtual sunrise time (HH:MM:SS), allowing for later sunrises. 🌅"
)
CONF_MAX_SUNRISE_TIME = "max_sunrise_time"
DOCS[CONF_MAX_SUNRISE_TIME] = (
@ -144,22 +144,22 @@ DOCS[CONF_MAX_SUNRISE_TIME] = (
)
CONF_SUNSET_OFFSET, DEFAULT_SUNSET_OFFSET = "sunset_offset", 0
DOCS[
CONF_SUNSET_OFFSET
] = "Adjust sunset time with a positive or negative offset in seconds. ⏰"
DOCS[CONF_SUNSET_OFFSET] = (
"Adjust sunset time with a positive or negative offset in seconds. ⏰"
)
CONF_SUNSET_TIME = "sunset_time"
DOCS[CONF_SUNSET_TIME] = "Set a fixed time (HH:MM:SS) for sunset. 🌇"
CONF_MIN_SUNSET_TIME = "min_sunset_time"
DOCS[
CONF_MIN_SUNSET_TIME
] = "Set the earliest virtual sunset time (HH:MM:SS), allowing for later sunsets. 🌇"
DOCS[CONF_MIN_SUNSET_TIME] = (
"Set the earliest virtual sunset time (HH:MM:SS), allowing for later sunsets. 🌇"
)
CONF_MAX_SUNSET_TIME = "max_sunset_time"
DOCS[
CONF_MAX_SUNSET_TIME
] = "Set the latest virtual sunset time (HH:MM:SS), allowing for earlier sunsets. 🌇"
DOCS[CONF_MAX_SUNSET_TIME] = (
"Set the latest virtual sunset time (HH:MM:SS), allowing for earlier sunsets. 🌇"
)
CONF_BRIGHTNESS_MODE, DEFAULT_BRIGHTNESS_MODE = "brightness_mode", "default"
DOCS[CONF_BRIGHTNESS_MODE] = (

View file

@ -1,4 +1,5 @@
"""Utility functions for HA core."""
import logging
from collections.abc import Awaitable, Callable

View file

@ -34,6 +34,7 @@ def int_to_base36(num: int) -> str:
>>> base36_num = int_to_base36(num)
>>> print(base36_num)
'2N9'
"""
alphanumeric_chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"

View file

@ -1,4 +1,5 @@
"""Switch for the Adaptive Lighting integration."""
from __future__ import annotations
import asyncio

View file

@ -1,4 +1,5 @@
"""Extracts the dependencies of the components required for testing."""
from collections import defaultdict
from pathlib import Path

View file

@ -1,4 +1,5 @@
"""Fixtures for testing."""
import os
import sys

View file

@ -1,4 +1,5 @@
"""Test Adaptive Lighting config flow."""
from homeassistant import data_entry_flow
from homeassistant.config_entries import SOURCE_IMPORT
from homeassistant.const import CONF_NAME

View file

@ -1,4 +1,5 @@
"""Tests for Adaptive Lighting integration."""
from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import CONF_NAME
from homeassistant.setup import async_setup_component

View file

@ -1,4 +1,5 @@
"""Tests for Adaptive Lighting switches."""
# pylint: disable=protected-access
import asyncio
import itertools

View file

@ -1,4 +1,5 @@
"""Color util methods."""
# Slightly modified from homeassistant.util.color at
# https://github.com/home-assistant/core/blob/798fb3e31a6ba87358adc93a4c5b772b64451712/homeassistant/util/color.py#L14
# to remove the dependency on homeassistant.util.color in sun.py