mirror of
https://github.com/esphome/esphome.git
synced 2026-02-18 15:35:59 -07:00
[pre-commit.ci lite] apply automatic fixes
This commit is contained in:
committed by
GitHub
parent
6b91ba5353
commit
c05f0589fc
@@ -272,9 +272,7 @@ async def obj_hide_to_code(config, action_id, template_arg, args):
|
|||||||
async def do_hide(widget: Widget):
|
async def do_hide(widget: Widget):
|
||||||
widget.add_flag("LV_OBJ_FLAG_HIDDEN")
|
widget.add_flag("LV_OBJ_FLAG_HIDDEN")
|
||||||
|
|
||||||
widgets = [
|
widgets = [widget.outer or widget for widget in await get_widgets(config)]
|
||||||
widget.outer if widget.outer else widget for widget in await get_widgets(config)
|
|
||||||
]
|
|
||||||
return await action_to_code(widgets, do_hide, action_id, template_arg, args)
|
return await action_to_code(widgets, do_hide, action_id, template_arg, args)
|
||||||
|
|
||||||
|
|
||||||
@@ -285,9 +283,7 @@ async def obj_show_to_code(config, action_id, template_arg, args):
|
|||||||
if widget.move_to_foreground:
|
if widget.move_to_foreground:
|
||||||
lv_obj.move_foreground(widget.obj)
|
lv_obj.move_foreground(widget.obj)
|
||||||
|
|
||||||
widgets = [
|
widgets = [widget.outer or widget for widget in await get_widgets(config)]
|
||||||
widget.outer if widget.outer else widget for widget in await get_widgets(config)
|
|
||||||
]
|
|
||||||
return await action_to_code(widgets, do_show, action_id, template_arg, args)
|
return await action_to_code(widgets, do_show, action_id, template_arg, args)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,9 @@ def define_has_settings(keys: list[str], schemas: dict[str, SettingSchema]) -> N
|
|||||||
cg.RawExpression(
|
cg.RawExpression(
|
||||||
" sep ".join(
|
" sep ".join(
|
||||||
map(
|
map(
|
||||||
lambda key: f"F({schemas[key].backing_type}, {key}_setting, {schemas[key].default_value})",
|
lambda key: (
|
||||||
|
f"F({schemas[key].backing_type}, {key}_setting, {schemas[key].default_value})"
|
||||||
|
),
|
||||||
keys,
|
keys,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -682,7 +682,7 @@ def only_with_framework(
|
|||||||
def validator_(obj):
|
def validator_(obj):
|
||||||
if CORE.target_framework not in frameworks:
|
if CORE.target_framework not in frameworks:
|
||||||
err_str = f"This feature is only available with framework(s) {', '.join([framework.value for framework in frameworks])}"
|
err_str = f"This feature is only available with framework(s) {', '.join([framework.value for framework in frameworks])}"
|
||||||
if suggestion := suggestions.get(CORE.target_framework, None):
|
if suggestion := suggestions.get(CORE.target_framework):
|
||||||
(component, docs_path) = suggestion
|
(component, docs_path) = suggestion
|
||||||
err_str += f"\nPlease use '{component}'"
|
err_str += f"\nPlease use '{component}'"
|
||||||
if docs_path:
|
if docs_path:
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ class TypeInfo(ABC):
|
|||||||
"""
|
"""
|
||||||
field_id_size = self.calculate_field_id_size()
|
field_id_size = self.calculate_field_id_size()
|
||||||
method = f"{base_method}_force" if force else base_method
|
method = f"{base_method}_force" if force else base_method
|
||||||
value = value_expr if value_expr else name
|
value = value_expr or name
|
||||||
return f"size.{method}({field_id_size}, {value});"
|
return f"size.{method}({field_id_size}, {value});"
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ def merge_component_configs(
|
|||||||
|
|
||||||
if all_packages is None:
|
if all_packages is None:
|
||||||
# First component - initialize package dict
|
# First component - initialize package dict
|
||||||
all_packages = comp_packages if comp_packages else {}
|
all_packages = comp_packages or {}
|
||||||
elif comp_packages:
|
elif comp_packages:
|
||||||
# Merge packages - combine all unique package types
|
# Merge packages - combine all unique package types
|
||||||
# If both have the same package type, verify they're identical
|
# If both have the same package type, verify they're identical
|
||||||
|
|||||||
@@ -98,9 +98,11 @@ async def test_script_queued(
|
|||||||
if not test3_complete.done():
|
if not test3_complete.done():
|
||||||
loop.call_later(
|
loop.call_later(
|
||||||
0.3,
|
0.3,
|
||||||
lambda: test3_complete.set_result(True)
|
lambda: (
|
||||||
if not test3_complete.done()
|
test3_complete.set_result(True)
|
||||||
else None,
|
if not test3_complete.done()
|
||||||
|
else None
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Test 4: Rejection
|
# Test 4: Rejection
|
||||||
|
|||||||
@@ -1011,8 +1011,8 @@ def test_get_all_dependencies_handles_missing_components() -> None:
|
|||||||
comp.dependencies = ["missing_comp"]
|
comp.dependencies = ["missing_comp"]
|
||||||
comp.auto_load = []
|
comp.auto_load = []
|
||||||
|
|
||||||
mock_get_component.side_effect = (
|
mock_get_component.side_effect = lambda name: (
|
||||||
lambda name: comp if name == "existing" else None
|
comp if name == "existing" else None
|
||||||
)
|
)
|
||||||
|
|
||||||
result = helpers.get_all_dependencies({"existing", "nonexistent"})
|
result = helpers.get_all_dependencies({"existing", "nonexistent"})
|
||||||
|
|||||||
@@ -453,11 +453,14 @@ def test_preload_core_config_no_platform(setup_core: Path) -> None:
|
|||||||
# Mock _is_target_platform to avoid expensive component loading
|
# Mock _is_target_platform to avoid expensive component loading
|
||||||
with patch("esphome.core.config._is_target_platform") as mock_is_platform:
|
with patch("esphome.core.config._is_target_platform") as mock_is_platform:
|
||||||
# Return True for known platforms
|
# Return True for known platforms
|
||||||
mock_is_platform.side_effect = lambda name: name in [
|
mock_is_platform.side_effect = lambda name: (
|
||||||
"esp32",
|
name
|
||||||
"esp8266",
|
in [
|
||||||
"rp2040",
|
"esp32",
|
||||||
]
|
"esp8266",
|
||||||
|
"rp2040",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
with pytest.raises(cv.Invalid, match="Platform missing"):
|
with pytest.raises(cv.Invalid, match="Platform missing"):
|
||||||
preload_core_config(config, result)
|
preload_core_config(config, result)
|
||||||
@@ -477,11 +480,14 @@ def test_preload_core_config_multiple_platforms(setup_core: Path) -> None:
|
|||||||
# Mock _is_target_platform to avoid expensive component loading
|
# Mock _is_target_platform to avoid expensive component loading
|
||||||
with patch("esphome.core.config._is_target_platform") as mock_is_platform:
|
with patch("esphome.core.config._is_target_platform") as mock_is_platform:
|
||||||
# Return True for known platforms
|
# Return True for known platforms
|
||||||
mock_is_platform.side_effect = lambda name: name in [
|
mock_is_platform.side_effect = lambda name: (
|
||||||
"esp32",
|
name
|
||||||
"esp8266",
|
in [
|
||||||
"rp2040",
|
"esp32",
|
||||||
]
|
"esp8266",
|
||||||
|
"rp2040",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
with pytest.raises(cv.Invalid, match="Found multiple target platform blocks"):
|
with pytest.raises(cv.Invalid, match="Found multiple target platform blocks"):
|
||||||
preload_core_config(config, result)
|
preload_core_config(config, result)
|
||||||
|
|||||||
@@ -466,8 +466,8 @@ def test_clean_build(
|
|||||||
) as mock_get_instance:
|
) as mock_get_instance:
|
||||||
mock_config = MagicMock()
|
mock_config = MagicMock()
|
||||||
mock_get_instance.return_value = mock_config
|
mock_get_instance.return_value = mock_config
|
||||||
mock_config.get.side_effect = (
|
mock_config.get.side_effect = lambda section, option: (
|
||||||
lambda section, option: str(platformio_cache_dir)
|
str(platformio_cache_dir)
|
||||||
if (section, option) == ("platformio", "cache_dir")
|
if (section, option) == ("platformio", "cache_dir")
|
||||||
else ""
|
else ""
|
||||||
)
|
)
|
||||||
@@ -630,8 +630,8 @@ def test_clean_build_empty_cache_dir(
|
|||||||
) as mock_get_instance:
|
) as mock_get_instance:
|
||||||
mock_config = MagicMock()
|
mock_config = MagicMock()
|
||||||
mock_get_instance.return_value = mock_config
|
mock_get_instance.return_value = mock_config
|
||||||
mock_config.get.side_effect = (
|
mock_config.get.side_effect = lambda section, option: (
|
||||||
lambda section, option: " " # Whitespace only
|
" " # Whitespace only
|
||||||
if (section, option) == ("platformio", "cache_dir")
|
if (section, option) == ("platformio", "cache_dir")
|
||||||
else ""
|
else ""
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user