mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Deduplicate handling of duplicated constants (#107074)
* Deduplicate handling of duplicated constants * Use DeprecatedConstant + DeprecatedConstantEnum * Fixup * Remove test cases with unnamed tuples
This commit is contained in:
parent
1a08bcce77
commit
9eefd95e91
@ -2,7 +2,15 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from enum import StrEnum
|
||||
from typing import Any, Final
|
||||
from functools import partial
|
||||
from typing import Final
|
||||
|
||||
from .helpers.deprecation import (
|
||||
DeprecatedConstant,
|
||||
DeprecatedConstantEnum,
|
||||
check_if_deprecated_constant,
|
||||
dir_with_deprecated_constants,
|
||||
)
|
||||
|
||||
APPLICATION_NAME: Final = "HomeAssistant"
|
||||
MAJOR_VERSION: Final = 2024
|
||||
@ -307,146 +315,135 @@ EVENT_SHOPPING_LIST_UPDATED: Final = "shopping_list_updated"
|
||||
# #### DEVICE CLASSES ####
|
||||
# DEVICE_CLASS_* below are deprecated as of 2021.12
|
||||
# use the SensorDeviceClass enum instead.
|
||||
_DEPRECATED_DEVICE_CLASS_AQI: Final = ("aqi", "SensorDeviceClass.AQI", "2025.1")
|
||||
_DEPRECATED_DEVICE_CLASS_BATTERY: Final = (
|
||||
_DEPRECATED_DEVICE_CLASS_AQI: Final = DeprecatedConstant(
|
||||
"aqi", "SensorDeviceClass.AQI", "2025.1"
|
||||
)
|
||||
_DEPRECATED_DEVICE_CLASS_BATTERY: Final = DeprecatedConstant(
|
||||
"battery",
|
||||
"SensorDeviceClass.BATTERY",
|
||||
"2025.1",
|
||||
)
|
||||
_DEPRECATED_DEVICE_CLASS_CO: Final = (
|
||||
_DEPRECATED_DEVICE_CLASS_CO: Final = DeprecatedConstant(
|
||||
"carbon_monoxide",
|
||||
"SensorDeviceClass.CO",
|
||||
"2025.1",
|
||||
)
|
||||
_DEPRECATED_DEVICE_CLASS_CO2: Final = (
|
||||
_DEPRECATED_DEVICE_CLASS_CO2: Final = DeprecatedConstant(
|
||||
"carbon_dioxide",
|
||||
"SensorDeviceClass.CO2",
|
||||
"2025.1",
|
||||
)
|
||||
_DEPRECATED_DEVICE_CLASS_CURRENT: Final = (
|
||||
_DEPRECATED_DEVICE_CLASS_CURRENT: Final = DeprecatedConstant(
|
||||
"current",
|
||||
"SensorDeviceClass.CURRENT",
|
||||
"2025.1",
|
||||
)
|
||||
_DEPRECATED_DEVICE_CLASS_DATE: Final = ("date", "SensorDeviceClass.DATE", "2025.1")
|
||||
_DEPRECATED_DEVICE_CLASS_ENERGY: Final = (
|
||||
_DEPRECATED_DEVICE_CLASS_DATE: Final = DeprecatedConstant(
|
||||
"date", "SensorDeviceClass.DATE", "2025.1"
|
||||
)
|
||||
_DEPRECATED_DEVICE_CLASS_ENERGY: Final = DeprecatedConstant(
|
||||
"energy",
|
||||
"SensorDeviceClass.ENERGY",
|
||||
"2025.1",
|
||||
)
|
||||
_DEPRECATED_DEVICE_CLASS_FREQUENCY: Final = (
|
||||
_DEPRECATED_DEVICE_CLASS_FREQUENCY: Final = DeprecatedConstant(
|
||||
"frequency",
|
||||
"SensorDeviceClass.FREQUENCY",
|
||||
"2025.1",
|
||||
)
|
||||
_DEPRECATED_DEVICE_CLASS_GAS: Final = ("gas", "SensorDeviceClass.GAS", "2025.1")
|
||||
_DEPRECATED_DEVICE_CLASS_HUMIDITY: Final = (
|
||||
_DEPRECATED_DEVICE_CLASS_GAS: Final = DeprecatedConstant(
|
||||
"gas", "SensorDeviceClass.GAS", "2025.1"
|
||||
)
|
||||
_DEPRECATED_DEVICE_CLASS_HUMIDITY: Final = DeprecatedConstant(
|
||||
"humidity",
|
||||
"SensorDeviceClass.HUMIDITY",
|
||||
"2025.1",
|
||||
)
|
||||
_DEPRECATED_DEVICE_CLASS_ILLUMINANCE: Final = (
|
||||
_DEPRECATED_DEVICE_CLASS_ILLUMINANCE: Final = DeprecatedConstant(
|
||||
"illuminance",
|
||||
"SensorDeviceClass.ILLUMINANCE",
|
||||
"2025.1",
|
||||
)
|
||||
_DEPRECATED_DEVICE_CLASS_MONETARY: Final = (
|
||||
_DEPRECATED_DEVICE_CLASS_MONETARY: Final = DeprecatedConstant(
|
||||
"monetary",
|
||||
"SensorDeviceClass.MONETARY",
|
||||
"2025.1",
|
||||
)
|
||||
_DEPRECATED_DEVICE_CLASS_NITROGEN_DIOXIDE = (
|
||||
_DEPRECATED_DEVICE_CLASS_NITROGEN_DIOXIDE: Final = DeprecatedConstant(
|
||||
"nitrogen_dioxide",
|
||||
"SensorDeviceClass.NITROGEN_DIOXIDE",
|
||||
"2025.1",
|
||||
)
|
||||
_DEPRECATED_DEVICE_CLASS_NITROGEN_MONOXIDE = (
|
||||
_DEPRECATED_DEVICE_CLASS_NITROGEN_MONOXIDE: Final = DeprecatedConstant(
|
||||
"nitrogen_monoxide",
|
||||
"SensorDeviceClass.NITROGEN_MONOXIDE",
|
||||
"2025.1",
|
||||
)
|
||||
_DEPRECATED_DEVICE_CLASS_NITROUS_OXIDE = (
|
||||
_DEPRECATED_DEVICE_CLASS_NITROUS_OXIDE: Final = DeprecatedConstant(
|
||||
"nitrous_oxide",
|
||||
"SensorDeviceClass.NITROUS_OXIDE",
|
||||
"2025.1",
|
||||
)
|
||||
_DEPRECATED_DEVICE_CLASS_OZONE: Final = ("ozone", "SensorDeviceClass.OZONE", "2025.1")
|
||||
_DEPRECATED_DEVICE_CLASS_PM1: Final = ("pm1", "SensorDeviceClass.PM1", "2025.1")
|
||||
_DEPRECATED_DEVICE_CLASS_PM10: Final = ("pm10", "SensorDeviceClass.PM10", "2025.1")
|
||||
_DEPRECATED_DEVICE_CLASS_PM25: Final = ("pm25", "SensorDeviceClass.PM25", "2025.1")
|
||||
_DEPRECATED_DEVICE_CLASS_POWER_FACTOR: Final = (
|
||||
_DEPRECATED_DEVICE_CLASS_OZONE: Final = DeprecatedConstant(
|
||||
"ozone", "SensorDeviceClass.OZONE", "2025.1"
|
||||
)
|
||||
_DEPRECATED_DEVICE_CLASS_PM1: Final = DeprecatedConstant(
|
||||
"pm1", "SensorDeviceClass.PM1", "2025.1"
|
||||
)
|
||||
_DEPRECATED_DEVICE_CLASS_PM10: Final = DeprecatedConstant(
|
||||
"pm10", "SensorDeviceClass.PM10", "2025.1"
|
||||
)
|
||||
_DEPRECATED_DEVICE_CLASS_PM25: Final = DeprecatedConstant(
|
||||
"pm25", "SensorDeviceClass.PM25", "2025.1"
|
||||
)
|
||||
_DEPRECATED_DEVICE_CLASS_POWER_FACTOR: Final = DeprecatedConstant(
|
||||
"power_factor",
|
||||
"SensorDeviceClass.POWER_FACTOR",
|
||||
"2025.1",
|
||||
)
|
||||
_DEPRECATED_DEVICE_CLASS_POWER: Final = ("power", "SensorDeviceClass.POWER", "2025.1")
|
||||
_DEPRECATED_DEVICE_CLASS_PRESSURE: Final = (
|
||||
_DEPRECATED_DEVICE_CLASS_POWER: Final = DeprecatedConstant(
|
||||
"power", "SensorDeviceClass.POWER", "2025.1"
|
||||
)
|
||||
_DEPRECATED_DEVICE_CLASS_PRESSURE: Final = DeprecatedConstant(
|
||||
"pressure",
|
||||
"SensorDeviceClass.PRESSURE",
|
||||
"2025.1",
|
||||
)
|
||||
_DEPRECATED_DEVICE_CLASS_SIGNAL_STRENGTH: Final = (
|
||||
_DEPRECATED_DEVICE_CLASS_SIGNAL_STRENGTH: Final = DeprecatedConstant(
|
||||
"signal_strength",
|
||||
"SensorDeviceClass.SIGNAL_STRENGTH",
|
||||
"2025.1",
|
||||
)
|
||||
_DEPRECATED_DEVICE_CLASS_SULPHUR_DIOXIDE = (
|
||||
_DEPRECATED_DEVICE_CLASS_SULPHUR_DIOXIDE: Final = DeprecatedConstant(
|
||||
"sulphur_dioxide",
|
||||
"SensorDeviceClass.SULPHUR_DIOXIDE",
|
||||
"2025.1",
|
||||
)
|
||||
_DEPRECATED_DEVICE_CLASS_TEMPERATURE: Final = (
|
||||
_DEPRECATED_DEVICE_CLASS_TEMPERATURE: Final = DeprecatedConstant(
|
||||
"temperature",
|
||||
"SensorDeviceClass.TEMPERATURE",
|
||||
"2025.1",
|
||||
)
|
||||
_DEPRECATED_DEVICE_CLASS_TIMESTAMP: Final = (
|
||||
_DEPRECATED_DEVICE_CLASS_TIMESTAMP: Final = DeprecatedConstant(
|
||||
"timestamp",
|
||||
"SensorDeviceClass.TIMESTAMP",
|
||||
"2025.1",
|
||||
)
|
||||
_DEPRECATED_DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS = (
|
||||
_DEPRECATED_DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS: Final = DeprecatedConstant(
|
||||
"volatile_organic_compounds",
|
||||
"SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS",
|
||||
"2025.1",
|
||||
)
|
||||
_DEPRECATED_DEVICE_CLASS_VOLTAGE: Final = (
|
||||
_DEPRECATED_DEVICE_CLASS_VOLTAGE: Final = DeprecatedConstant(
|
||||
"voltage",
|
||||
"SensorDeviceClass.VOLTAGE",
|
||||
"2025.1",
|
||||
)
|
||||
|
||||
|
||||
# Can be removed if no deprecated constant are in this module anymore
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Check if the not found name is a deprecated constant.
|
||||
|
||||
If it is, print a deprecation warning and return the value of the constant.
|
||||
Otherwise raise AttributeError.
|
||||
"""
|
||||
module_globals = globals()
|
||||
if f"_DEPRECATED_{name}" not in module_globals:
|
||||
raise AttributeError(f"Module {__name__} has no attribute {name!r}")
|
||||
|
||||
# Avoid circular import
|
||||
from .helpers.deprecation import ( # pylint: disable=import-outside-toplevel
|
||||
check_if_deprecated_constant,
|
||||
)
|
||||
|
||||
return check_if_deprecated_constant(name, module_globals)
|
||||
|
||||
|
||||
# Can be removed if no deprecated constant are in this module anymore
|
||||
def __dir__() -> list[str]:
|
||||
"""Return dir() with deprecated constants."""
|
||||
# Copied method from homeassistant.helpers.deprecattion#dir_with_deprecated_constants to avoid import cycle
|
||||
module_globals = globals()
|
||||
|
||||
return list(module_globals) + [
|
||||
name.removeprefix("_DEPRECATED_")
|
||||
for name in module_globals
|
||||
if name.startswith("_DEPRECATED_")
|
||||
]
|
||||
# Both can be removed if no deprecated constant are in this module anymore
|
||||
__getattr__ = partial(check_if_deprecated_constant, module_globals=globals())
|
||||
__dir__ = partial(dir_with_deprecated_constants, module_globals=globals())
|
||||
|
||||
|
||||
# #### STATES ####
|
||||
@ -621,7 +618,7 @@ class UnitOfApparentPower(StrEnum):
|
||||
VOLT_AMPERE = "VA"
|
||||
|
||||
|
||||
_DEPRECATED_POWER_VOLT_AMPERE: Final = (
|
||||
_DEPRECATED_POWER_VOLT_AMPERE: Final = DeprecatedConstantEnum(
|
||||
UnitOfApparentPower.VOLT_AMPERE,
|
||||
"2025.1",
|
||||
)
|
||||
@ -637,17 +634,17 @@ class UnitOfPower(StrEnum):
|
||||
BTU_PER_HOUR = "BTU/h"
|
||||
|
||||
|
||||
_DEPRECATED_POWER_WATT: Final = (
|
||||
_DEPRECATED_POWER_WATT: Final = DeprecatedConstantEnum(
|
||||
UnitOfPower.WATT,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfPower.WATT."""
|
||||
_DEPRECATED_POWER_KILO_WATT: Final = (
|
||||
_DEPRECATED_POWER_KILO_WATT: Final = DeprecatedConstantEnum(
|
||||
UnitOfPower.KILO_WATT,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfPower.KILO_WATT."""
|
||||
_DEPRECATED_POWER_BTU_PER_HOUR: Final = (
|
||||
_DEPRECATED_POWER_BTU_PER_HOUR: Final = DeprecatedConstantEnum(
|
||||
UnitOfPower.BTU_PER_HOUR,
|
||||
"2025.1",
|
||||
)
|
||||
@ -668,17 +665,17 @@ class UnitOfEnergy(StrEnum):
|
||||
WATT_HOUR = "Wh"
|
||||
|
||||
|
||||
_DEPRECATED_ENERGY_KILO_WATT_HOUR: Final = (
|
||||
_DEPRECATED_ENERGY_KILO_WATT_HOUR: Final = DeprecatedConstantEnum(
|
||||
UnitOfEnergy.KILO_WATT_HOUR,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfEnergy.KILO_WATT_HOUR."""
|
||||
_DEPRECATED_ENERGY_MEGA_WATT_HOUR: Final = (
|
||||
_DEPRECATED_ENERGY_MEGA_WATT_HOUR: Final = DeprecatedConstantEnum(
|
||||
UnitOfEnergy.MEGA_WATT_HOUR,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfEnergy.MEGA_WATT_HOUR."""
|
||||
_DEPRECATED_ENERGY_WATT_HOUR: Final = (
|
||||
_DEPRECATED_ENERGY_WATT_HOUR: Final = DeprecatedConstantEnum(
|
||||
UnitOfEnergy.WATT_HOUR,
|
||||
"2025.1",
|
||||
)
|
||||
@ -693,12 +690,12 @@ class UnitOfElectricCurrent(StrEnum):
|
||||
AMPERE = "A"
|
||||
|
||||
|
||||
_DEPRECATED_ELECTRIC_CURRENT_MILLIAMPERE: Final = (
|
||||
_DEPRECATED_ELECTRIC_CURRENT_MILLIAMPERE: Final = DeprecatedConstantEnum(
|
||||
UnitOfElectricCurrent.MILLIAMPERE,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfElectricCurrent.MILLIAMPERE."""
|
||||
_DEPRECATED_ELECTRIC_CURRENT_AMPERE: Final = (
|
||||
_DEPRECATED_ELECTRIC_CURRENT_AMPERE: Final = DeprecatedConstantEnum(
|
||||
UnitOfElectricCurrent.AMPERE,
|
||||
"2025.1",
|
||||
)
|
||||
@ -713,12 +710,12 @@ class UnitOfElectricPotential(StrEnum):
|
||||
VOLT = "V"
|
||||
|
||||
|
||||
_DEPRECATED_ELECTRIC_POTENTIAL_MILLIVOLT: Final = (
|
||||
_DEPRECATED_ELECTRIC_POTENTIAL_MILLIVOLT: Final = DeprecatedConstantEnum(
|
||||
UnitOfElectricPotential.MILLIVOLT,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfElectricPotential.MILLIVOLT."""
|
||||
_DEPRECATED_ELECTRIC_POTENTIAL_VOLT: Final = (
|
||||
_DEPRECATED_ELECTRIC_POTENTIAL_VOLT: Final = DeprecatedConstantEnum(
|
||||
UnitOfElectricPotential.VOLT,
|
||||
"2025.1",
|
||||
)
|
||||
@ -742,17 +739,17 @@ class UnitOfTemperature(StrEnum):
|
||||
KELVIN = "K"
|
||||
|
||||
|
||||
_DEPRECATED_TEMP_CELSIUS: Final = (
|
||||
_DEPRECATED_TEMP_CELSIUS: Final = DeprecatedConstantEnum(
|
||||
UnitOfTemperature.CELSIUS,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfTemperature.CELSIUS"""
|
||||
_DEPRECATED_TEMP_FAHRENHEIT: Final = (
|
||||
_DEPRECATED_TEMP_FAHRENHEIT: Final = DeprecatedConstantEnum(
|
||||
UnitOfTemperature.FAHRENHEIT,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfTemperature.FAHRENHEIT"""
|
||||
_DEPRECATED_TEMP_KELVIN: Final = (
|
||||
_DEPRECATED_TEMP_KELVIN: Final = DeprecatedConstantEnum(
|
||||
UnitOfTemperature.KELVIN,
|
||||
"2025.1",
|
||||
)
|
||||
@ -774,47 +771,47 @@ class UnitOfTime(StrEnum):
|
||||
YEARS = "y"
|
||||
|
||||
|
||||
_DEPRECATED_TIME_MICROSECONDS: Final = (
|
||||
_DEPRECATED_TIME_MICROSECONDS: Final = DeprecatedConstantEnum(
|
||||
UnitOfTime.MICROSECONDS,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfTime.MICROSECONDS."""
|
||||
_DEPRECATED_TIME_MILLISECONDS: Final = (
|
||||
_DEPRECATED_TIME_MILLISECONDS: Final = DeprecatedConstantEnum(
|
||||
UnitOfTime.MILLISECONDS,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfTime.MILLISECONDS."""
|
||||
_DEPRECATED_TIME_SECONDS: Final = (
|
||||
_DEPRECATED_TIME_SECONDS: Final = DeprecatedConstantEnum(
|
||||
UnitOfTime.SECONDS,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfTime.SECONDS."""
|
||||
_DEPRECATED_TIME_MINUTES: Final = (
|
||||
_DEPRECATED_TIME_MINUTES: Final = DeprecatedConstantEnum(
|
||||
UnitOfTime.MINUTES,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfTime.MINUTES."""
|
||||
_DEPRECATED_TIME_HOURS: Final = (
|
||||
_DEPRECATED_TIME_HOURS: Final = DeprecatedConstantEnum(
|
||||
UnitOfTime.HOURS,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfTime.HOURS."""
|
||||
_DEPRECATED_TIME_DAYS: Final = (
|
||||
_DEPRECATED_TIME_DAYS: Final = DeprecatedConstantEnum(
|
||||
UnitOfTime.DAYS,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfTime.DAYS."""
|
||||
_DEPRECATED_TIME_WEEKS: Final = (
|
||||
_DEPRECATED_TIME_WEEKS: Final = DeprecatedConstantEnum(
|
||||
UnitOfTime.WEEKS,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfTime.WEEKS."""
|
||||
_DEPRECATED_TIME_MONTHS: Final = (
|
||||
_DEPRECATED_TIME_MONTHS: Final = DeprecatedConstantEnum(
|
||||
UnitOfTime.MONTHS,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfTime.MONTHS."""
|
||||
_DEPRECATED_TIME_YEARS: Final = (
|
||||
_DEPRECATED_TIME_YEARS: Final = DeprecatedConstantEnum(
|
||||
UnitOfTime.YEARS,
|
||||
"2025.1",
|
||||
)
|
||||
@ -835,42 +832,42 @@ class UnitOfLength(StrEnum):
|
||||
MILES = "mi"
|
||||
|
||||
|
||||
_DEPRECATED_LENGTH_MILLIMETERS: Final = (
|
||||
_DEPRECATED_LENGTH_MILLIMETERS: Final = DeprecatedConstantEnum(
|
||||
UnitOfLength.MILLIMETERS,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfLength.MILLIMETERS."""
|
||||
_DEPRECATED_LENGTH_CENTIMETERS: Final = (
|
||||
_DEPRECATED_LENGTH_CENTIMETERS: Final = DeprecatedConstantEnum(
|
||||
UnitOfLength.CENTIMETERS,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfLength.CENTIMETERS."""
|
||||
_DEPRECATED_LENGTH_METERS: Final = (
|
||||
_DEPRECATED_LENGTH_METERS: Final = DeprecatedConstantEnum(
|
||||
UnitOfLength.METERS,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfLength.METERS."""
|
||||
_DEPRECATED_LENGTH_KILOMETERS: Final = (
|
||||
_DEPRECATED_LENGTH_KILOMETERS: Final = DeprecatedConstantEnum(
|
||||
UnitOfLength.KILOMETERS,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfLength.KILOMETERS."""
|
||||
_DEPRECATED_LENGTH_INCHES: Final = (
|
||||
_DEPRECATED_LENGTH_INCHES: Final = DeprecatedConstantEnum(
|
||||
UnitOfLength.INCHES,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfLength.INCHES."""
|
||||
_DEPRECATED_LENGTH_FEET: Final = (
|
||||
_DEPRECATED_LENGTH_FEET: Final = DeprecatedConstantEnum(
|
||||
UnitOfLength.FEET,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfLength.FEET."""
|
||||
_DEPRECATED_LENGTH_YARD: Final = (
|
||||
_DEPRECATED_LENGTH_YARD: Final = DeprecatedConstantEnum(
|
||||
UnitOfLength.YARDS,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfLength.YARDS."""
|
||||
_DEPRECATED_LENGTH_MILES: Final = (
|
||||
_DEPRECATED_LENGTH_MILES: Final = DeprecatedConstantEnum(
|
||||
UnitOfLength.MILES,
|
||||
"2025.1",
|
||||
)
|
||||
@ -887,22 +884,22 @@ class UnitOfFrequency(StrEnum):
|
||||
GIGAHERTZ = "GHz"
|
||||
|
||||
|
||||
_DEPRECATED_FREQUENCY_HERTZ: Final = (
|
||||
_DEPRECATED_FREQUENCY_HERTZ: Final = DeprecatedConstantEnum(
|
||||
UnitOfFrequency.HERTZ,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfFrequency.HERTZ"""
|
||||
_DEPRECATED_FREQUENCY_KILOHERTZ: Final = (
|
||||
_DEPRECATED_FREQUENCY_KILOHERTZ: Final = DeprecatedConstantEnum(
|
||||
UnitOfFrequency.KILOHERTZ,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfFrequency.KILOHERTZ"""
|
||||
_DEPRECATED_FREQUENCY_MEGAHERTZ: Final = (
|
||||
_DEPRECATED_FREQUENCY_MEGAHERTZ: Final = DeprecatedConstantEnum(
|
||||
UnitOfFrequency.MEGAHERTZ,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfFrequency.MEGAHERTZ"""
|
||||
_DEPRECATED_FREQUENCY_GIGAHERTZ: Final = (
|
||||
_DEPRECATED_FREQUENCY_GIGAHERTZ: Final = DeprecatedConstantEnum(
|
||||
UnitOfFrequency.GIGAHERTZ,
|
||||
"2025.1",
|
||||
)
|
||||
@ -924,47 +921,47 @@ class UnitOfPressure(StrEnum):
|
||||
PSI = "psi"
|
||||
|
||||
|
||||
_DEPRECATED_PRESSURE_PA: Final = (
|
||||
_DEPRECATED_PRESSURE_PA: Final = DeprecatedConstantEnum(
|
||||
UnitOfPressure.PA,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfPressure.PA"""
|
||||
_DEPRECATED_PRESSURE_HPA: Final = (
|
||||
_DEPRECATED_PRESSURE_HPA: Final = DeprecatedConstantEnum(
|
||||
UnitOfPressure.HPA,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfPressure.HPA"""
|
||||
_DEPRECATED_PRESSURE_KPA: Final = (
|
||||
_DEPRECATED_PRESSURE_KPA: Final = DeprecatedConstantEnum(
|
||||
UnitOfPressure.KPA,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfPressure.KPA"""
|
||||
_DEPRECATED_PRESSURE_BAR: Final = (
|
||||
_DEPRECATED_PRESSURE_BAR: Final = DeprecatedConstantEnum(
|
||||
UnitOfPressure.BAR,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfPressure.BAR"""
|
||||
_DEPRECATED_PRESSURE_CBAR: Final = (
|
||||
_DEPRECATED_PRESSURE_CBAR: Final = DeprecatedConstantEnum(
|
||||
UnitOfPressure.CBAR,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfPressure.CBAR"""
|
||||
_DEPRECATED_PRESSURE_MBAR: Final = (
|
||||
_DEPRECATED_PRESSURE_MBAR: Final = DeprecatedConstantEnum(
|
||||
UnitOfPressure.MBAR,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfPressure.MBAR"""
|
||||
_DEPRECATED_PRESSURE_MMHG: Final = (
|
||||
_DEPRECATED_PRESSURE_MMHG: Final = DeprecatedConstantEnum(
|
||||
UnitOfPressure.MMHG,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfPressure.MMHG"""
|
||||
_DEPRECATED_PRESSURE_INHG: Final = (
|
||||
_DEPRECATED_PRESSURE_INHG: Final = DeprecatedConstantEnum(
|
||||
UnitOfPressure.INHG,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfPressure.INHG"""
|
||||
_DEPRECATED_PRESSURE_PSI: Final = (
|
||||
_DEPRECATED_PRESSURE_PSI: Final = DeprecatedConstantEnum(
|
||||
UnitOfPressure.PSI,
|
||||
"2025.1",
|
||||
)
|
||||
@ -979,12 +976,12 @@ class UnitOfSoundPressure(StrEnum):
|
||||
WEIGHTED_DECIBEL_A = "dBA"
|
||||
|
||||
|
||||
_DEPRECATED_SOUND_PRESSURE_DB: Final = (
|
||||
_DEPRECATED_SOUND_PRESSURE_DB: Final = DeprecatedConstantEnum(
|
||||
UnitOfSoundPressure.DECIBEL,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfSoundPressure.DECIBEL"""
|
||||
_DEPRECATED_SOUND_PRESSURE_WEIGHTED_DBA: Final = (
|
||||
_DEPRECATED_SOUND_PRESSURE_WEIGHTED_DBA: Final = DeprecatedConstantEnum(
|
||||
UnitOfSoundPressure.WEIGHTED_DECIBEL_A,
|
||||
"2025.1",
|
||||
)
|
||||
@ -1010,33 +1007,33 @@ class UnitOfVolume(StrEnum):
|
||||
British/Imperial fluid ounces are not yet supported"""
|
||||
|
||||
|
||||
_DEPRECATED_VOLUME_LITERS: Final = (
|
||||
_DEPRECATED_VOLUME_LITERS: Final = DeprecatedConstantEnum(
|
||||
UnitOfVolume.LITERS,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfVolume.LITERS"""
|
||||
_DEPRECATED_VOLUME_MILLILITERS: Final = (
|
||||
_DEPRECATED_VOLUME_MILLILITERS: Final = DeprecatedConstantEnum(
|
||||
UnitOfVolume.MILLILITERS,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfVolume.MILLILITERS"""
|
||||
_DEPRECATED_VOLUME_CUBIC_METERS: Final = (
|
||||
_DEPRECATED_VOLUME_CUBIC_METERS: Final = DeprecatedConstantEnum(
|
||||
UnitOfVolume.CUBIC_METERS,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfVolume.CUBIC_METERS"""
|
||||
_DEPRECATED_VOLUME_CUBIC_FEET: Final = (
|
||||
_DEPRECATED_VOLUME_CUBIC_FEET: Final = DeprecatedConstantEnum(
|
||||
UnitOfVolume.CUBIC_FEET,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfVolume.CUBIC_FEET"""
|
||||
|
||||
_DEPRECATED_VOLUME_GALLONS: Final = (
|
||||
_DEPRECATED_VOLUME_GALLONS: Final = DeprecatedConstantEnum(
|
||||
UnitOfVolume.GALLONS,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfVolume.GALLONS"""
|
||||
_DEPRECATED_VOLUME_FLUID_OUNCE: Final = (
|
||||
_DEPRECATED_VOLUME_FLUID_OUNCE: Final = DeprecatedConstantEnum(
|
||||
UnitOfVolume.FLUID_OUNCES,
|
||||
"2025.1",
|
||||
)
|
||||
@ -1051,12 +1048,12 @@ class UnitOfVolumeFlowRate(StrEnum):
|
||||
CUBIC_FEET_PER_MINUTE = "ft³/m"
|
||||
|
||||
|
||||
_DEPRECATED_VOLUME_FLOW_RATE_CUBIC_METERS_PER_HOUR: Final = (
|
||||
_DEPRECATED_VOLUME_FLOW_RATE_CUBIC_METERS_PER_HOUR: Final = DeprecatedConstantEnum(
|
||||
UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR"""
|
||||
_DEPRECATED_VOLUME_FLOW_RATE_CUBIC_FEET_PER_MINUTE: Final = (
|
||||
_DEPRECATED_VOLUME_FLOW_RATE_CUBIC_FEET_PER_MINUTE: Final = DeprecatedConstantEnum(
|
||||
UnitOfVolumeFlowRate.CUBIC_FEET_PER_MINUTE,
|
||||
"2025.1",
|
||||
)
|
||||
@ -1079,32 +1076,32 @@ class UnitOfMass(StrEnum):
|
||||
STONES = "st"
|
||||
|
||||
|
||||
_DEPRECATED_MASS_GRAMS: Final = (
|
||||
_DEPRECATED_MASS_GRAMS: Final = DeprecatedConstantEnum(
|
||||
UnitOfMass.GRAMS,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfMass.GRAMS"""
|
||||
_DEPRECATED_MASS_KILOGRAMS: Final = (
|
||||
_DEPRECATED_MASS_KILOGRAMS: Final = DeprecatedConstantEnum(
|
||||
UnitOfMass.KILOGRAMS,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfMass.KILOGRAMS"""
|
||||
_DEPRECATED_MASS_MILLIGRAMS: Final = (
|
||||
_DEPRECATED_MASS_MILLIGRAMS: Final = DeprecatedConstantEnum(
|
||||
UnitOfMass.MILLIGRAMS,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfMass.MILLIGRAMS"""
|
||||
_DEPRECATED_MASS_MICROGRAMS: Final = (
|
||||
_DEPRECATED_MASS_MICROGRAMS: Final = DeprecatedConstantEnum(
|
||||
UnitOfMass.MICROGRAMS,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfMass.MICROGRAMS"""
|
||||
_DEPRECATED_MASS_OUNCES: Final = (
|
||||
_DEPRECATED_MASS_OUNCES: Final = DeprecatedConstantEnum(
|
||||
UnitOfMass.OUNCES,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfMass.OUNCES"""
|
||||
_DEPRECATED_MASS_POUNDS: Final = (
|
||||
_DEPRECATED_MASS_POUNDS: Final = DeprecatedConstantEnum(
|
||||
UnitOfMass.POUNDS,
|
||||
"2025.1",
|
||||
)
|
||||
@ -1135,12 +1132,12 @@ class UnitOfIrradiance(StrEnum):
|
||||
|
||||
|
||||
# Irradiation units
|
||||
_DEPRECATED_IRRADIATION_WATTS_PER_SQUARE_METER: Final = (
|
||||
_DEPRECATED_IRRADIATION_WATTS_PER_SQUARE_METER: Final = DeprecatedConstantEnum(
|
||||
UnitOfIrradiance.WATTS_PER_SQUARE_METER,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfIrradiance.WATTS_PER_SQUARE_METER"""
|
||||
_DEPRECATED_IRRADIATION_BTUS_PER_HOUR_SQUARE_FOOT: Final = (
|
||||
_DEPRECATED_IRRADIATION_BTUS_PER_HOUR_SQUARE_FOOT: Final = DeprecatedConstantEnum(
|
||||
UnitOfIrradiance.BTUS_PER_HOUR_SQUARE_FOOT,
|
||||
"2025.1",
|
||||
)
|
||||
@ -1185,19 +1182,21 @@ class UnitOfPrecipitationDepth(StrEnum):
|
||||
|
||||
|
||||
# Precipitation units
|
||||
_DEPRECATED_PRECIPITATION_INCHES: Final = (UnitOfPrecipitationDepth.INCHES, "2025.1")
|
||||
_DEPRECATED_PRECIPITATION_INCHES: Final = DeprecatedConstantEnum(
|
||||
UnitOfPrecipitationDepth.INCHES, "2025.1"
|
||||
)
|
||||
"""Deprecated: please use UnitOfPrecipitationDepth.INCHES"""
|
||||
_DEPRECATED_PRECIPITATION_MILLIMETERS: Final = (
|
||||
_DEPRECATED_PRECIPITATION_MILLIMETERS: Final = DeprecatedConstantEnum(
|
||||
UnitOfPrecipitationDepth.MILLIMETERS,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfPrecipitationDepth.MILLIMETERS"""
|
||||
_DEPRECATED_PRECIPITATION_MILLIMETERS_PER_HOUR: Final = (
|
||||
_DEPRECATED_PRECIPITATION_MILLIMETERS_PER_HOUR: Final = DeprecatedConstantEnum(
|
||||
UnitOfVolumetricFlux.MILLIMETERS_PER_HOUR,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfVolumetricFlux.MILLIMETERS_PER_HOUR"""
|
||||
_DEPRECATED_PRECIPITATION_INCHES_PER_HOUR: Final = (
|
||||
_DEPRECATED_PRECIPITATION_INCHES_PER_HOUR: Final = DeprecatedConstantEnum(
|
||||
UnitOfVolumetricFlux.INCHES_PER_HOUR,
|
||||
"2025.1",
|
||||
)
|
||||
@ -1223,33 +1222,39 @@ class UnitOfSpeed(StrEnum):
|
||||
MILES_PER_HOUR = "mph"
|
||||
|
||||
|
||||
_DEPRECATED_SPEED_FEET_PER_SECOND: Final = (UnitOfSpeed.FEET_PER_SECOND, "2025.1")
|
||||
_DEPRECATED_SPEED_FEET_PER_SECOND: Final = DeprecatedConstantEnum(
|
||||
UnitOfSpeed.FEET_PER_SECOND, "2025.1"
|
||||
)
|
||||
"""Deprecated: please use UnitOfSpeed.FEET_PER_SECOND"""
|
||||
_DEPRECATED_SPEED_METERS_PER_SECOND: Final = (UnitOfSpeed.METERS_PER_SECOND, "2025.1")
|
||||
_DEPRECATED_SPEED_METERS_PER_SECOND: Final = DeprecatedConstantEnum(
|
||||
UnitOfSpeed.METERS_PER_SECOND, "2025.1"
|
||||
)
|
||||
"""Deprecated: please use UnitOfSpeed.METERS_PER_SECOND"""
|
||||
_DEPRECATED_SPEED_KILOMETERS_PER_HOUR: Final = (
|
||||
_DEPRECATED_SPEED_KILOMETERS_PER_HOUR: Final = DeprecatedConstantEnum(
|
||||
UnitOfSpeed.KILOMETERS_PER_HOUR,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfSpeed.KILOMETERS_PER_HOUR"""
|
||||
_DEPRECATED_SPEED_KNOTS: Final = (UnitOfSpeed.KNOTS, "2025.1")
|
||||
_DEPRECATED_SPEED_KNOTS: Final = DeprecatedConstantEnum(UnitOfSpeed.KNOTS, "2025.1")
|
||||
"""Deprecated: please use UnitOfSpeed.KNOTS"""
|
||||
_DEPRECATED_SPEED_MILES_PER_HOUR: Final = (UnitOfSpeed.MILES_PER_HOUR, "2025.1")
|
||||
_DEPRECATED_SPEED_MILES_PER_HOUR: Final = DeprecatedConstantEnum(
|
||||
UnitOfSpeed.MILES_PER_HOUR, "2025.1"
|
||||
)
|
||||
"""Deprecated: please use UnitOfSpeed.MILES_PER_HOUR"""
|
||||
|
||||
_DEPRECATED_SPEED_MILLIMETERS_PER_DAY: Final = (
|
||||
_DEPRECATED_SPEED_MILLIMETERS_PER_DAY: Final = DeprecatedConstantEnum(
|
||||
UnitOfVolumetricFlux.MILLIMETERS_PER_DAY,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfVolumetricFlux.MILLIMETERS_PER_DAY"""
|
||||
|
||||
_DEPRECATED_SPEED_INCHES_PER_DAY: Final = (
|
||||
_DEPRECATED_SPEED_INCHES_PER_DAY: Final = DeprecatedConstantEnum(
|
||||
UnitOfVolumetricFlux.INCHES_PER_DAY,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfVolumetricFlux.INCHES_PER_DAY"""
|
||||
|
||||
_DEPRECATED_SPEED_INCHES_PER_HOUR: Final = (
|
||||
_DEPRECATED_SPEED_INCHES_PER_HOUR: Final = DeprecatedConstantEnum(
|
||||
UnitOfVolumetricFlux.INCHES_PER_HOUR,
|
||||
"2025.1",
|
||||
)
|
||||
@ -1288,47 +1293,87 @@ class UnitOfInformation(StrEnum):
|
||||
YOBIBYTES = "YiB"
|
||||
|
||||
|
||||
_DEPRECATED_DATA_BITS: Final = (UnitOfInformation.BITS, "2025.1")
|
||||
_DEPRECATED_DATA_BITS: Final = DeprecatedConstantEnum(UnitOfInformation.BITS, "2025.1")
|
||||
"""Deprecated: please use UnitOfInformation.BITS"""
|
||||
_DEPRECATED_DATA_KILOBITS: Final = (UnitOfInformation.KILOBITS, "2025.1")
|
||||
_DEPRECATED_DATA_KILOBITS: Final = DeprecatedConstantEnum(
|
||||
UnitOfInformation.KILOBITS, "2025.1"
|
||||
)
|
||||
"""Deprecated: please use UnitOfInformation.KILOBITS"""
|
||||
_DEPRECATED_DATA_MEGABITS: Final = (UnitOfInformation.MEGABITS, "2025.1")
|
||||
_DEPRECATED_DATA_MEGABITS: Final = DeprecatedConstantEnum(
|
||||
UnitOfInformation.MEGABITS, "2025.1"
|
||||
)
|
||||
"""Deprecated: please use UnitOfInformation.MEGABITS"""
|
||||
_DEPRECATED_DATA_GIGABITS: Final = (UnitOfInformation.GIGABITS, "2025.1")
|
||||
_DEPRECATED_DATA_GIGABITS: Final = DeprecatedConstantEnum(
|
||||
UnitOfInformation.GIGABITS, "2025.1"
|
||||
)
|
||||
"""Deprecated: please use UnitOfInformation.GIGABITS"""
|
||||
_DEPRECATED_DATA_BYTES: Final = (UnitOfInformation.BYTES, "2025.1")
|
||||
_DEPRECATED_DATA_BYTES: Final = DeprecatedConstantEnum(
|
||||
UnitOfInformation.BYTES, "2025.1"
|
||||
)
|
||||
"""Deprecated: please use UnitOfInformation.BYTES"""
|
||||
_DEPRECATED_DATA_KILOBYTES: Final = (UnitOfInformation.KILOBYTES, "2025.1")
|
||||
_DEPRECATED_DATA_KILOBYTES: Final = DeprecatedConstantEnum(
|
||||
UnitOfInformation.KILOBYTES, "2025.1"
|
||||
)
|
||||
"""Deprecated: please use UnitOfInformation.KILOBYTES"""
|
||||
_DEPRECATED_DATA_MEGABYTES: Final = (UnitOfInformation.MEGABYTES, "2025.1")
|
||||
_DEPRECATED_DATA_MEGABYTES: Final = DeprecatedConstantEnum(
|
||||
UnitOfInformation.MEGABYTES, "2025.1"
|
||||
)
|
||||
"""Deprecated: please use UnitOfInformation.MEGABYTES"""
|
||||
_DEPRECATED_DATA_GIGABYTES: Final = (UnitOfInformation.GIGABYTES, "2025.1")
|
||||
_DEPRECATED_DATA_GIGABYTES: Final = DeprecatedConstantEnum(
|
||||
UnitOfInformation.GIGABYTES, "2025.1"
|
||||
)
|
||||
"""Deprecated: please use UnitOfInformation.GIGABYTES"""
|
||||
_DEPRECATED_DATA_TERABYTES: Final = (UnitOfInformation.TERABYTES, "2025.1")
|
||||
_DEPRECATED_DATA_TERABYTES: Final = DeprecatedConstantEnum(
|
||||
UnitOfInformation.TERABYTES, "2025.1"
|
||||
)
|
||||
"""Deprecated: please use UnitOfInformation.TERABYTES"""
|
||||
_DEPRECATED_DATA_PETABYTES: Final = (UnitOfInformation.PETABYTES, "2025.1")
|
||||
_DEPRECATED_DATA_PETABYTES: Final = DeprecatedConstantEnum(
|
||||
UnitOfInformation.PETABYTES, "2025.1"
|
||||
)
|
||||
"""Deprecated: please use UnitOfInformation.PETABYTES"""
|
||||
_DEPRECATED_DATA_EXABYTES: Final = (UnitOfInformation.EXABYTES, "2025.1")
|
||||
_DEPRECATED_DATA_EXABYTES: Final = DeprecatedConstantEnum(
|
||||
UnitOfInformation.EXABYTES, "2025.1"
|
||||
)
|
||||
"""Deprecated: please use UnitOfInformation.EXABYTES"""
|
||||
_DEPRECATED_DATA_ZETTABYTES: Final = (UnitOfInformation.ZETTABYTES, "2025.1")
|
||||
_DEPRECATED_DATA_ZETTABYTES: Final = DeprecatedConstantEnum(
|
||||
UnitOfInformation.ZETTABYTES, "2025.1"
|
||||
)
|
||||
"""Deprecated: please use UnitOfInformation.ZETTABYTES"""
|
||||
_DEPRECATED_DATA_YOTTABYTES: Final = (UnitOfInformation.YOTTABYTES, "2025.1")
|
||||
_DEPRECATED_DATA_YOTTABYTES: Final = DeprecatedConstantEnum(
|
||||
UnitOfInformation.YOTTABYTES, "2025.1"
|
||||
)
|
||||
"""Deprecated: please use UnitOfInformation.YOTTABYTES"""
|
||||
_DEPRECATED_DATA_KIBIBYTES: Final = (UnitOfInformation.KIBIBYTES, "2025.1")
|
||||
_DEPRECATED_DATA_KIBIBYTES: Final = DeprecatedConstantEnum(
|
||||
UnitOfInformation.KIBIBYTES, "2025.1"
|
||||
)
|
||||
"""Deprecated: please use UnitOfInformation.KIBIBYTES"""
|
||||
_DEPRECATED_DATA_MEBIBYTES: Final = (UnitOfInformation.MEBIBYTES, "2025.1")
|
||||
_DEPRECATED_DATA_MEBIBYTES: Final = DeprecatedConstantEnum(
|
||||
UnitOfInformation.MEBIBYTES, "2025.1"
|
||||
)
|
||||
"""Deprecated: please use UnitOfInformation.MEBIBYTES"""
|
||||
_DEPRECATED_DATA_GIBIBYTES: Final = (UnitOfInformation.GIBIBYTES, "2025.1")
|
||||
_DEPRECATED_DATA_GIBIBYTES: Final = DeprecatedConstantEnum(
|
||||
UnitOfInformation.GIBIBYTES, "2025.1"
|
||||
)
|
||||
"""Deprecated: please use UnitOfInformation.GIBIBYTES"""
|
||||
_DEPRECATED_DATA_TEBIBYTES: Final = (UnitOfInformation.TEBIBYTES, "2025.1")
|
||||
_DEPRECATED_DATA_TEBIBYTES: Final = DeprecatedConstantEnum(
|
||||
UnitOfInformation.TEBIBYTES, "2025.1"
|
||||
)
|
||||
"""Deprecated: please use UnitOfInformation.TEBIBYTES"""
|
||||
_DEPRECATED_DATA_PEBIBYTES: Final = (UnitOfInformation.PEBIBYTES, "2025.1")
|
||||
_DEPRECATED_DATA_PEBIBYTES: Final = DeprecatedConstantEnum(
|
||||
UnitOfInformation.PEBIBYTES, "2025.1"
|
||||
)
|
||||
"""Deprecated: please use UnitOfInformation.PEBIBYTES"""
|
||||
_DEPRECATED_DATA_EXBIBYTES: Final = (UnitOfInformation.EXBIBYTES, "2025.1")
|
||||
_DEPRECATED_DATA_EXBIBYTES: Final = DeprecatedConstantEnum(
|
||||
UnitOfInformation.EXBIBYTES, "2025.1"
|
||||
)
|
||||
"""Deprecated: please use UnitOfInformation.EXBIBYTES"""
|
||||
_DEPRECATED_DATA_ZEBIBYTES: Final = (UnitOfInformation.ZEBIBYTES, "2025.1")
|
||||
_DEPRECATED_DATA_ZEBIBYTES: Final = DeprecatedConstantEnum(
|
||||
UnitOfInformation.ZEBIBYTES, "2025.1"
|
||||
)
|
||||
"""Deprecated: please use UnitOfInformation.ZEBIBYTES"""
|
||||
_DEPRECATED_DATA_YOBIBYTES: Final = (UnitOfInformation.YOBIBYTES, "2025.1")
|
||||
_DEPRECATED_DATA_YOBIBYTES: Final = DeprecatedConstantEnum(
|
||||
UnitOfInformation.YOBIBYTES, "2025.1"
|
||||
)
|
||||
"""Deprecated: please use UnitOfInformation.YOBIBYTES"""
|
||||
|
||||
|
||||
@ -1349,57 +1394,57 @@ class UnitOfDataRate(StrEnum):
|
||||
GIBIBYTES_PER_SECOND = "GiB/s"
|
||||
|
||||
|
||||
_DEPRECATED_DATA_RATE_BITS_PER_SECOND: Final = (
|
||||
_DEPRECATED_DATA_RATE_BITS_PER_SECOND: Final = DeprecatedConstantEnum(
|
||||
UnitOfDataRate.BITS_PER_SECOND,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfDataRate.BITS_PER_SECOND"""
|
||||
_DEPRECATED_DATA_RATE_KILOBITS_PER_SECOND: Final = (
|
||||
_DEPRECATED_DATA_RATE_KILOBITS_PER_SECOND: Final = DeprecatedConstantEnum(
|
||||
UnitOfDataRate.KILOBITS_PER_SECOND,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfDataRate.KILOBITS_PER_SECOND"""
|
||||
_DEPRECATED_DATA_RATE_MEGABITS_PER_SECOND: Final = (
|
||||
_DEPRECATED_DATA_RATE_MEGABITS_PER_SECOND: Final = DeprecatedConstantEnum(
|
||||
UnitOfDataRate.MEGABITS_PER_SECOND,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfDataRate.MEGABITS_PER_SECOND"""
|
||||
_DEPRECATED_DATA_RATE_GIGABITS_PER_SECOND: Final = (
|
||||
_DEPRECATED_DATA_RATE_GIGABITS_PER_SECOND: Final = DeprecatedConstantEnum(
|
||||
UnitOfDataRate.GIGABITS_PER_SECOND,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfDataRate.GIGABITS_PER_SECOND"""
|
||||
_DEPRECATED_DATA_RATE_BYTES_PER_SECOND: Final = (
|
||||
_DEPRECATED_DATA_RATE_BYTES_PER_SECOND: Final = DeprecatedConstantEnum(
|
||||
UnitOfDataRate.BYTES_PER_SECOND,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfDataRate.BYTES_PER_SECOND"""
|
||||
_DEPRECATED_DATA_RATE_KILOBYTES_PER_SECOND: Final = (
|
||||
_DEPRECATED_DATA_RATE_KILOBYTES_PER_SECOND: Final = DeprecatedConstantEnum(
|
||||
UnitOfDataRate.KILOBYTES_PER_SECOND,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfDataRate.KILOBYTES_PER_SECOND"""
|
||||
_DEPRECATED_DATA_RATE_MEGABYTES_PER_SECOND: Final = (
|
||||
_DEPRECATED_DATA_RATE_MEGABYTES_PER_SECOND: Final = DeprecatedConstantEnum(
|
||||
UnitOfDataRate.MEGABYTES_PER_SECOND,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfDataRate.MEGABYTES_PER_SECOND"""
|
||||
_DEPRECATED_DATA_RATE_GIGABYTES_PER_SECOND: Final = (
|
||||
_DEPRECATED_DATA_RATE_GIGABYTES_PER_SECOND: Final = DeprecatedConstantEnum(
|
||||
UnitOfDataRate.GIGABYTES_PER_SECOND,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfDataRate.GIGABYTES_PER_SECOND"""
|
||||
_DEPRECATED_DATA_RATE_KIBIBYTES_PER_SECOND: Final = (
|
||||
_DEPRECATED_DATA_RATE_KIBIBYTES_PER_SECOND: Final = DeprecatedConstantEnum(
|
||||
UnitOfDataRate.KIBIBYTES_PER_SECOND,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfDataRate.KIBIBYTES_PER_SECOND"""
|
||||
_DEPRECATED_DATA_RATE_MEBIBYTES_PER_SECOND: Final = (
|
||||
_DEPRECATED_DATA_RATE_MEBIBYTES_PER_SECOND: Final = DeprecatedConstantEnum(
|
||||
UnitOfDataRate.MEBIBYTES_PER_SECOND,
|
||||
"2025.1",
|
||||
)
|
||||
"""Deprecated: please use UnitOfDataRate.MEBIBYTES_PER_SECOND"""
|
||||
_DEPRECATED_DATA_RATE_GIBIBYTES_PER_SECOND: Final = (
|
||||
_DEPRECATED_DATA_RATE_GIBIBYTES_PER_SECOND: Final = DeprecatedConstantEnum(
|
||||
UnitOfDataRate.GIBIBYTES_PER_SECOND,
|
||||
"2025.1",
|
||||
)
|
||||
@ -1540,8 +1585,12 @@ class EntityCategory(StrEnum):
|
||||
|
||||
# ENTITY_CATEGOR* below are deprecated as of 2021.12
|
||||
# use the EntityCategory enum instead.
|
||||
_DEPRECATED_ENTITY_CATEGORY_CONFIG: Final = (EntityCategory.CONFIG, "2025.1")
|
||||
_DEPRECATED_ENTITY_CATEGORY_DIAGNOSTIC: Final = (EntityCategory.DIAGNOSTIC, "2025.1")
|
||||
_DEPRECATED_ENTITY_CATEGORY_CONFIG: Final = DeprecatedConstantEnum(
|
||||
EntityCategory.CONFIG, "2025.1"
|
||||
)
|
||||
_DEPRECATED_ENTITY_CATEGORY_DIAGNOSTIC: Final = DeprecatedConstantEnum(
|
||||
EntityCategory.DIAGNOSTIC, "2025.1"
|
||||
)
|
||||
ENTITY_CATEGORIES: Final[list[str]] = [cls.value for cls in EntityCategory]
|
||||
|
||||
# The ID of the Home Assistant Media Player Cast App
|
||||
|
@ -81,6 +81,11 @@ from .exceptions import (
|
||||
ServiceNotFound,
|
||||
Unauthorized,
|
||||
)
|
||||
from .helpers.deprecation import (
|
||||
DeprecatedConstantEnum,
|
||||
check_if_deprecated_constant,
|
||||
dir_with_deprecated_constants,
|
||||
)
|
||||
from .helpers.json import json_dumps
|
||||
from .util import dt as dt_util, location
|
||||
from .util.async_ import (
|
||||
@ -147,41 +152,16 @@ class ConfigSource(enum.StrEnum):
|
||||
|
||||
|
||||
# SOURCE_* are deprecated as of Home Assistant 2022.2, use ConfigSource instead
|
||||
_DEPRECATED_SOURCE_DISCOVERED = (ConfigSource.DISCOVERED, "2025.1")
|
||||
_DEPRECATED_SOURCE_STORAGE = (ConfigSource.STORAGE, "2025.1")
|
||||
_DEPRECATED_SOURCE_YAML = (ConfigSource.YAML, "2025.1")
|
||||
_DEPRECATED_SOURCE_DISCOVERED = DeprecatedConstantEnum(
|
||||
ConfigSource.DISCOVERED, "2025.1"
|
||||
)
|
||||
_DEPRECATED_SOURCE_STORAGE = DeprecatedConstantEnum(ConfigSource.STORAGE, "2025.1")
|
||||
_DEPRECATED_SOURCE_YAML = DeprecatedConstantEnum(ConfigSource.YAML, "2025.1")
|
||||
|
||||
|
||||
# Can be removed if no deprecated constant are in this module anymore
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Check if the not found name is a deprecated constant.
|
||||
|
||||
If it is, print a deprecation warning and return the value of the constant.
|
||||
Otherwise raise AttributeError.
|
||||
"""
|
||||
module_globals = globals()
|
||||
if f"_DEPRECATED_{name}" not in module_globals:
|
||||
raise AttributeError(f"Module {__name__} has no attribute {name!r}")
|
||||
|
||||
# Avoid circular import
|
||||
from .helpers.deprecation import ( # pylint: disable=import-outside-toplevel
|
||||
check_if_deprecated_constant,
|
||||
)
|
||||
|
||||
return check_if_deprecated_constant(name, module_globals)
|
||||
|
||||
|
||||
# Can be removed if no deprecated constant are in this module anymore
|
||||
def __dir__() -> list[str]:
|
||||
"""Return dir() with deprecated constants."""
|
||||
# Copied method from homeassistant.helpers.deprecattion#dir_with_deprecated_constants to avoid import cycle
|
||||
module_globals = globals()
|
||||
|
||||
return list(module_globals) + [
|
||||
name.removeprefix("_DEPRECATED_")
|
||||
for name in module_globals
|
||||
if name.startswith("_DEPRECATED_")
|
||||
]
|
||||
# Both can be removed if no deprecated constant are in this module anymore
|
||||
__getattr__ = functools.partial(check_if_deprecated_constant, module_globals=globals())
|
||||
__dir__ = functools.partial(dir_with_deprecated_constants, module_globals=globals())
|
||||
|
||||
|
||||
# How long to wait until things that run on startup have to finish.
|
||||
|
@ -9,12 +9,6 @@ import inspect
|
||||
import logging
|
||||
from typing import Any, NamedTuple, ParamSpec, TypeVar
|
||||
|
||||
from homeassistant.core import HomeAssistant, async_get_hass
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.loader import async_suggest_report_issue
|
||||
|
||||
from .frame import MissingIntegrationFrame, get_integration_frame
|
||||
|
||||
_ObjectT = TypeVar("_ObjectT", bound=object)
|
||||
_R = TypeVar("_R")
|
||||
_P = ParamSpec("_P")
|
||||
@ -175,6 +169,13 @@ def _print_deprecation_warning_internal(
|
||||
*,
|
||||
log_when_no_integration_is_found: bool,
|
||||
) -> None:
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from homeassistant.core import HomeAssistant, async_get_hass
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.loader import async_suggest_report_issue
|
||||
|
||||
from .frame import MissingIntegrationFrame, get_integration_frame
|
||||
|
||||
logger = logging.getLogger(module_name)
|
||||
if breaks_in_ha_version:
|
||||
breaks_in = f" which will be removed in HA Core {breaks_in_ha_version}"
|
||||
@ -265,18 +266,6 @@ def check_if_deprecated_constant(name: str, module_globals: dict[str, Any]) -> A
|
||||
f"{deprecated_const.enum.__class__.__name__}.{deprecated_const.enum.name}"
|
||||
)
|
||||
breaks_in_ha_version = deprecated_const.breaks_in_ha_version
|
||||
elif isinstance(deprecated_const, tuple):
|
||||
# Use DeprecatedConstant and DeprecatedConstant instead, where possible
|
||||
# Used to avoid import cycles.
|
||||
if len(deprecated_const) == 3:
|
||||
value = deprecated_const[0]
|
||||
replacement = deprecated_const[1]
|
||||
breaks_in_ha_version = deprecated_const[2]
|
||||
elif len(deprecated_const) == 2 and isinstance(deprecated_const[0], Enum):
|
||||
enum = deprecated_const[0]
|
||||
value = enum.value
|
||||
replacement = f"{enum.__class__.__name__}.{enum.name}"
|
||||
breaks_in_ha_version = deprecated_const[1]
|
||||
|
||||
if value is None or replacement is None:
|
||||
msg = (
|
||||
|
@ -299,22 +299,6 @@ def _get_value(obj: DeprecatedConstant | DeprecatedConstantEnum | tuple) -> Any:
|
||||
DeprecatedConstantEnum(TestDeprecatedConstantEnum.TEST, "2099.1"),
|
||||
" which will be removed in HA Core 2099.1. Use TestDeprecatedConstantEnum.TEST instead",
|
||||
),
|
||||
(
|
||||
("value", "NEW_CONSTANT", None),
|
||||
". Use NEW_CONSTANT instead",
|
||||
),
|
||||
(
|
||||
(1, "NEW_CONSTANT", "2099.1"),
|
||||
" which will be removed in HA Core 2099.1. Use NEW_CONSTANT instead",
|
||||
),
|
||||
(
|
||||
(TestDeprecatedConstantEnum.TEST, None),
|
||||
". Use TestDeprecatedConstantEnum.TEST instead",
|
||||
),
|
||||
(
|
||||
(TestDeprecatedConstantEnum.TEST, "2099.1"),
|
||||
" which will be removed in HA Core 2099.1. Use TestDeprecatedConstantEnum.TEST instead",
|
||||
),
|
||||
],
|
||||
)
|
||||
@pytest.mark.parametrize(
|
||||
@ -391,22 +375,6 @@ def test_check_if_deprecated_constant(
|
||||
DeprecatedConstantEnum(TestDeprecatedConstantEnum.TEST, "2099.1"),
|
||||
" which will be removed in HA Core 2099.1. Use TestDeprecatedConstantEnum.TEST instead",
|
||||
),
|
||||
(
|
||||
("value", "NEW_CONSTANT", None),
|
||||
". Use NEW_CONSTANT instead",
|
||||
),
|
||||
(
|
||||
(1, "NEW_CONSTANT", "2099.1"),
|
||||
" which will be removed in HA Core 2099.1. Use NEW_CONSTANT instead",
|
||||
),
|
||||
(
|
||||
(TestDeprecatedConstantEnum.TEST, None),
|
||||
". Use TestDeprecatedConstantEnum.TEST instead",
|
||||
),
|
||||
(
|
||||
(TestDeprecatedConstantEnum.TEST, "2099.1"),
|
||||
" which will be removed in HA Core 2099.1. Use TestDeprecatedConstantEnum.TEST instead",
|
||||
),
|
||||
],
|
||||
)
|
||||
@pytest.mark.parametrize(
|
||||
|
Loading…
x
Reference in New Issue
Block a user