diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a4945ca..ef382af 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,7 +9,7 @@ ci: repos: - repo: https://github.com/commitizen-tools/commitizen - rev: v4.9.1 + rev: v4.18.1 hooks: - id: commitizen stages: [commit-msg] @@ -34,18 +34,18 @@ repos: - id: prettier args: ["--tab-width", "2"] - repo: https://github.com/asottile/pyupgrade - rev: v3.21.0 + rev: v3.21.2 hooks: - id: pyupgrade args: [--py37-plus] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.14.2 + rev: v0.16.8 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] - id: ruff-format - repo: https://github.com/codespell-project/codespell - rev: v2.4.1 + rev: v2.4.3 hooks: - id: codespell - repo: https://github.com/PyCQA/flake8 @@ -53,12 +53,12 @@ repos: hooks: - id: flake8 - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.18.2 + rev: v2.3.1 hooks: - id: mypy additional_dependencies: [] - repo: https://github.com/PyCQA/bandit - rev: 1.8.6 + rev: 1.9.4 hooks: - id: bandit args: [-x, tests] diff --git a/docs/source/conf.py b/docs/source/conf.py index b38de98..eab5670 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -13,7 +13,7 @@ # import os # import sys # sys.path.insert(0, os.path.abspath('.')) -from typing import Any, List +from typing import Any # -- Project information ----------------------------------------------------- @@ -40,7 +40,7 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path. -exclude_patterns: List[Any] = [] +exclude_patterns: list[Any] = [] # -- Options for HTML output ------------------------------------------------- diff --git a/src/sensor_state_data/__init__.py b/src/sensor_state_data/__init__.py index e1ff494..ad4826b 100644 --- a/src/sensor_state_data/__init__.py +++ b/src/sensor_state_data/__init__.py @@ -14,9 +14,9 @@ __all__ = [ "BaseDeviceClass", "BaseValue", - "BinarySensorValue", "BinarySensorDescription", "BinarySensorDeviceClass", + "BinarySensorValue", "DeviceClass", "DeviceKey", "Event", diff --git a/src/sensor_state_data/data.py b/src/sensor_state_data/data.py index 69b866d..f1c7288 100644 --- a/src/sensor_state_data/data.py +++ b/src/sensor_state_data/data.py @@ -218,7 +218,7 @@ def update_predefined_binary_sensor( def update_predefined_sensor( self, base_description: BaseSensorDescription, - native_value: None | str | int | float | date | datetime | Decimal, + native_value: None | str | float | date | datetime | Decimal, key: str | None = None, name: str | None = None, device_id: str | None = None, @@ -268,7 +268,7 @@ def update_sensor( self, key: str, native_unit_of_measurement: Units | None, - native_value: None | str | int | float | date | datetime | Decimal, + native_value: None | str | float | date | datetime | Decimal, device_class: SensorDeviceClass | None = None, name: str | None = None, device_id: str | None = None, diff --git a/src/sensor_state_data/enum.py b/src/sensor_state_data/enum.py index 9eb76c2..009afd5 100644 --- a/src/sensor_state_data/enum.py +++ b/src/sensor_state_data/enum.py @@ -5,15 +5,15 @@ from enum import Enum from typing import Any, TypeVar +from typing_extensions import Self + _StrEnumT = TypeVar("_StrEnumT", bound="StrEnum") class StrEnum(str, Enum): """Partial backport of Python 3.11's StrEnum for our basic use cases.""" - def __new__( - cls: type[_StrEnumT], value: str, *args: Any, **kwargs: Any - ) -> _StrEnumT: + def __new__(cls, value: str, *args: Any, **kwargs: Any) -> Self: """Create a new StrEnum instance.""" if not isinstance(value, str): raise TypeError(f"{value!r} is not a string")