Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#882)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.1.6 → v0.2.0](astral-sh/ruff-pre-commit@v0.1.6...v0.2.0)
- [github.com/psf/black: 23.11.0 → 24.1.1](psf/black@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>
  • Loading branch information
pre-commit-ci[bot] authored Feb 5, 2024
1 parent a47f7ce commit 95a5943
Show file tree
Hide file tree
Showing 17 changed files with 45 additions and 28 deletions.
3 changes: 2 additions & 1 deletion .github/update-services.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
"""Creates a services.yaml file with the latest docs."""

import sys
from pathlib import Path

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
Expand Down
3 changes: 2 additions & 1 deletion .github/update-strings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Update strings.json and en.json from const.py."""

import json
import sys
from pathlib import Path
Expand All @@ -8,7 +9,7 @@

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"
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions custom_components/adaptive_lighting/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Adaptive Lighting integration in Home-Assistant."""

import logging
from typing import Any

Expand Down
1 change: 1 addition & 0 deletions custom_components/adaptive_lighting/adaptation_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utility functions for adaptation commands."""

import logging
from collections.abc import AsyncGenerator
from dataclasses import dataclass
Expand Down
3 changes: 3 additions & 0 deletions custom_components/adaptive_lighting/color_and_brightness.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Switch for the Adaptive Lighting integration."""

from __future__ import annotations

import bisect
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions custom_components/adaptive_lighting/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Config flow for Adaptive Lighting integration."""

import logging

import homeassistant.helpers.config_validation as cv
Expand Down
48 changes: 24 additions & 24 deletions custom_components/adaptive_lighting/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
)

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. 🔄"
Expand Down Expand Up @@ -112,30 +112,30 @@
)

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] = (
Expand All @@ -144,22 +144,22 @@
)

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] = (
Expand Down
1 change: 1 addition & 0 deletions custom_components/adaptive_lighting/hass_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utility functions for HA core."""

import logging
from collections.abc import Awaitable, Callable

Expand Down
1 change: 1 addition & 0 deletions custom_components/adaptive_lighting/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def int_to_base36(num: int) -> str:
>>> base36_num = int_to_base36(num)
>>> print(base36_num)
'2N9'
"""
alphanumeric_chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"

Expand Down
1 change: 1 addition & 0 deletions custom_components/adaptive_lighting/switch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Switch for the Adaptive Lighting integration."""

from __future__ import annotations

import asyncio
Expand Down
1 change: 1 addition & 0 deletions test_dependencies.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Extracts the dependencies of the components required for testing."""

from collections import defaultdict
from pathlib import Path

Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Fixtures for testing."""

import os
import sys

Expand Down
1 change: 1 addition & 0 deletions tests/test_config_flow.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/test_init.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/test_switch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for Adaptive Lighting switches."""

# pylint: disable=protected-access
import asyncio
import itertools
Expand Down
1 change: 1 addition & 0 deletions webapp/homeassistant_util_color.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 95a5943

Please sign in to comment.