Prevent use of deprecated units (#83384)

* Prevent use of deprecated units

* Adjust obsolete util

* More units

* Add FREQUENCY

* Adjust pylint ignore

* Add ELECTRIC (current/potential)

* Add TIME

* Adjust units
pull/84371/head
epenet 2022-12-21 15:24:11 +01:00 committed by GitHub
parent 55133b3a27
commit d6fc2d9452
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 75 additions and 10 deletions

View File

@ -3,7 +3,8 @@ from __future__ import annotations
from collections.abc import Callable
from homeassistant.const import ( # pylint: disable=unused-import # noqa: F401
# pylint: disable-next=unused-import,hass-deprecated-import
from homeassistant.const import ( # noqa: F401
LENGTH,
LENGTH_CENTIMETERS,
LENGTH_FEET,

View File

@ -1,7 +1,8 @@
"""Pressure util functions."""
from __future__ import annotations
from homeassistant.const import ( # pylint: disable=unused-import # noqa: F401
# pylint: disable-next=unused-import,hass-deprecated-import
from homeassistant.const import ( # noqa: F401
PRESSURE,
PRESSURE_BAR,
PRESSURE_CBAR,

View File

@ -1,7 +1,8 @@
"""Distance util functions."""
from __future__ import annotations
from homeassistant.const import ( # pylint: disable=unused-import # noqa: F401
# pylint: disable-next=unused-import,hass-deprecated-import
from homeassistant.const import ( # noqa: F401
SPEED,
SPEED_FEET_PER_SECOND,
SPEED_INCHES_PER_DAY,

View File

@ -1,5 +1,6 @@
"""Temperature util functions."""
from homeassistant.const import ( # pylint: disable=unused-import # noqa: F401
# pylint: disable-next=unused-import,hass-deprecated-import
from homeassistant.const import ( # noqa: F401
TEMP_CELSIUS,
TEMP_FAHRENHEIT,
TEMP_KELVIN,

View File

@ -1,7 +1,8 @@
"""Volume conversion util functions."""
from __future__ import annotations
from homeassistant.const import ( # pylint: disable=unused-import # noqa: F401
# pylint: disable-next=unused-import,hass-deprecated-import
from homeassistant.const import ( # noqa: F401
UNIT_NOT_RECOGNIZED_TEMPLATE,
VOLUME,
VOLUME_CUBIC_FEET,

View File

@ -260,16 +260,76 @@ _OBSOLETE_IMPORT: dict[str, list[ObsoleteImportMatch]] = {
],
"homeassistant.const": [
ObsoleteImportMatch(
reason="replaced by SensorDeviceClass enum",
constant=re.compile(r"^DEVICE_CLASS_(\w*)$"),
reason="replaced by local constants",
constant=re.compile(r"^CONF_UNIT_SYSTEM_(\w+)$"),
),
ObsoleteImportMatch(
reason="replaced by unit enums",
constant=re.compile(r"^DATA_(\w+)$"),
),
ObsoleteImportMatch(
reason="replaced by ***DeviceClass enum",
constant=re.compile(r"^DEVICE_CLASS_(\w+)$"),
),
ObsoleteImportMatch(
reason="replaced by unit enums",
constant=re.compile(r"^ELECTRIC_(\w+)$"),
),
ObsoleteImportMatch(
reason="replaced by unit enums",
constant=re.compile(r"^ENERGY_(\w+)$"),
),
ObsoleteImportMatch(
reason="replaced by EntityCategory enum",
constant=re.compile(r"^(ENTITY_CATEGORY_(\w*))|(ENTITY_CATEGORIES)$"),
constant=re.compile(r"^(ENTITY_CATEGORY_(\w+))|(ENTITY_CATEGORIES)$"),
),
ObsoleteImportMatch(
reason="replaced by local constants",
constant=re.compile(r"^(CONF_UNIT_SYSTEM_(\w*))$"),
reason="replaced by unit enums",
constant=re.compile(r"^FREQUENCY_(\w+)$"),
),
ObsoleteImportMatch(
reason="replaced by unit enums",
constant=re.compile(r"^IRRADIATION_(\w+)$"),
),
ObsoleteImportMatch(
reason="replaced by unit enums",
constant=re.compile(r"^LENGTH_(\w+)$"),
),
ObsoleteImportMatch(
reason="replaced by unit enums",
constant=re.compile(r"^MASS_(\w+)$"),
),
ObsoleteImportMatch(
reason="replaced by unit enums",
constant=re.compile(r"^POWER_(?!VOLT_AMPERE_REACTIVE)(\w+)$"),
),
ObsoleteImportMatch(
reason="replaced by unit enums",
constant=re.compile(r"^PRECIPITATION_(\w+)$"),
),
ObsoleteImportMatch(
reason="replaced by unit enums",
constant=re.compile(r"^PRESSURE_(\w+)$"),
),
ObsoleteImportMatch(
reason="replaced by unit enums",
constant=re.compile(r"^SOUND_PRESSURE_(\w+)$"),
),
ObsoleteImportMatch(
reason="replaced by unit enums",
constant=re.compile(r"^SPEED_(\w+)$"),
),
ObsoleteImportMatch(
reason="replaced by unit enums",
constant=re.compile(r"^TEMP_(\w+)$"),
),
ObsoleteImportMatch(
reason="replaced by unit enums",
constant=re.compile(r"^TIME_(\w+)$"),
),
ObsoleteImportMatch(
reason="replaced by unit enums",
constant=re.compile(r"^VOLUME_(\w+)$"),
),
],
"homeassistant.core": [