mirror of
https://github.com/home-assistant/core.git
synced 2025-07-31 19:25:12 +02:00
Remove single-use function
This commit is contained in:
@@ -76,7 +76,14 @@ async def websocket_detect_config(hass, connection, msg):
|
||||
connection.send_result(msg["id"], info)
|
||||
return
|
||||
|
||||
info["unit_system"] = unit_system.get_default_key(location_info.use_metric)
|
||||
# We don't want any integrations to use the name of the unit system
|
||||
# so we are using the private attribute here
|
||||
if location_info.use_metric:
|
||||
# pylint: disable-next=protected-access
|
||||
info["unit_system"] = unit_system._CONF_UNIT_SYSTEM_METRIC
|
||||
else:
|
||||
# pylint: disable-next=protected-access
|
||||
info["unit_system"] = unit_system._CONF_UNIT_SYSTEM_IMPERIAL
|
||||
|
||||
if location_info.latitude:
|
||||
info["latitude"] = location_info.latitude
|
||||
|
@@ -2011,7 +2011,7 @@ class Config:
|
||||
"latitude": self.latitude,
|
||||
"longitude": self.longitude,
|
||||
"elevation": self.elevation,
|
||||
# We don't want any components to use the name of the unit system
|
||||
# We don't want any integrations to use the name of the unit system
|
||||
# so we are using the private attribute here
|
||||
"unit_system": self.units._name, # pylint: disable=protected-access
|
||||
"location_name": self.location_name,
|
||||
|
@@ -220,13 +220,6 @@ def get_unit_system(key: str) -> UnitSystem:
|
||||
raise ValueError(f"`{key}` is not a valid unit system key")
|
||||
|
||||
|
||||
def get_default_key(use_metric: bool) -> str:
|
||||
"""Get default unit system based on location information."""
|
||||
if use_metric:
|
||||
return _CONF_UNIT_SYSTEM_METRIC
|
||||
return _CONF_UNIT_SYSTEM_IMPERIAL
|
||||
|
||||
|
||||
validate_unit_system = vol.All(
|
||||
vol.Lower, vol.Any(_CONF_UNIT_SYSTEM_METRIC, _CONF_UNIT_SYSTEM_IMPERIAL)
|
||||
)
|
||||
|
@@ -25,7 +25,6 @@ from homeassistant.util.unit_system import (
|
||||
IMPERIAL_SYSTEM,
|
||||
METRIC_SYSTEM,
|
||||
UnitSystem,
|
||||
get_default_key,
|
||||
get_unit_system,
|
||||
)
|
||||
|
||||
@@ -338,18 +337,6 @@ def test_deprecated_name(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"use_metric, expected_key",
|
||||
[
|
||||
(True, _CONF_UNIT_SYSTEM_METRIC),
|
||||
(False, _CONF_UNIT_SYSTEM_IMPERIAL),
|
||||
],
|
||||
)
|
||||
def test_get_default_key(use_metric: bool, expected_key: str) -> None:
|
||||
"""Test get_default_key."""
|
||||
assert get_default_key(use_metric) == expected_key
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"key, expected_system",
|
||||
[
|
||||
|
Reference in New Issue
Block a user