mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 18:28:14 +02:00
Enforce kwargs in unit system initialisation (#80620)
* Enforce kwargs in unit system initialisation * Fix tests * Sort kwargs in unit_system
This commit is contained in:
@ -9,15 +9,15 @@ import voluptuous as vol
|
||||
from homeassistant.const import (
|
||||
ACCUMULATED_PRECIPITATION,
|
||||
LENGTH,
|
||||
LENGTH_INCHES,
|
||||
LENGTH_KILOMETERS,
|
||||
LENGTH_MILES,
|
||||
LENGTH_MILLIMETERS,
|
||||
MASS,
|
||||
MASS_GRAMS,
|
||||
MASS_KILOGRAMS,
|
||||
MASS_OUNCES,
|
||||
MASS_POUNDS,
|
||||
PRECIPITATION_INCHES,
|
||||
PRECIPITATION_MILLIMETERS,
|
||||
PRESSURE,
|
||||
PRESSURE_PA,
|
||||
PRESSURE_PSI,
|
||||
@ -87,13 +87,14 @@ class UnitSystem:
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
temperature: str,
|
||||
*,
|
||||
accumulated_precipitation: str,
|
||||
length: str,
|
||||
wind_speed: str,
|
||||
volume: str,
|
||||
mass: str,
|
||||
pressure: str,
|
||||
accumulated_precipitation: str,
|
||||
temperature: str,
|
||||
volume: str,
|
||||
wind_speed: str,
|
||||
) -> None:
|
||||
"""Initialize the unit system object."""
|
||||
errors: str = ", ".join(
|
||||
@ -241,24 +242,24 @@ validate_unit_system = vol.All(
|
||||
|
||||
METRIC_SYSTEM = UnitSystem(
|
||||
_CONF_UNIT_SYSTEM_METRIC,
|
||||
TEMP_CELSIUS,
|
||||
LENGTH_KILOMETERS,
|
||||
SPEED_METERS_PER_SECOND,
|
||||
VOLUME_LITERS,
|
||||
MASS_GRAMS,
|
||||
PRESSURE_PA,
|
||||
LENGTH_MILLIMETERS,
|
||||
accumulated_precipitation=PRECIPITATION_MILLIMETERS,
|
||||
length=LENGTH_KILOMETERS,
|
||||
mass=MASS_GRAMS,
|
||||
pressure=PRESSURE_PA,
|
||||
temperature=TEMP_CELSIUS,
|
||||
volume=VOLUME_LITERS,
|
||||
wind_speed=SPEED_METERS_PER_SECOND,
|
||||
)
|
||||
|
||||
US_CUSTOMARY_SYSTEM = UnitSystem(
|
||||
_CONF_UNIT_SYSTEM_US_CUSTOMARY,
|
||||
TEMP_FAHRENHEIT,
|
||||
LENGTH_MILES,
|
||||
SPEED_MILES_PER_HOUR,
|
||||
VOLUME_GALLONS,
|
||||
MASS_POUNDS,
|
||||
PRESSURE_PSI,
|
||||
LENGTH_INCHES,
|
||||
accumulated_precipitation=PRECIPITATION_INCHES,
|
||||
length=LENGTH_MILES,
|
||||
mass=MASS_POUNDS,
|
||||
pressure=PRESSURE_PSI,
|
||||
temperature=TEMP_FAHRENHEIT,
|
||||
volume=VOLUME_GALLONS,
|
||||
wind_speed=SPEED_MILES_PER_HOUR,
|
||||
)
|
||||
|
||||
IMPERIAL_SYSTEM = US_CUSTOMARY_SYSTEM
|
||||
|
Reference in New Issue
Block a user