File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed
Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 11# Changelog
22
3+ ## Ongoing
4+
5+ - Fix issue introduced by ruff: replace using .keys() in xml-find result
6+
37## v0.31.9: Further typing improvements
48
59- Add NumberType, SelectType and SelectOptionsType constants to improve typing further
Original file line number Diff line number Diff line change 7676# from typing import cast
7777
7878
79+ def etree_to_dict (element : etree ) -> dict [str , str ]:
80+ """Helper-function translating xml Element to dict."""
81+ node : dict [str , str ] = {}
82+ getattr (element , "text" , None )
83+ if element is not None :
84+ node .update (element .items ())
85+
86+ return node
87+
88+
7989def update_helper (
8090 data : DeviceData ,
8191 devices : dict [str , DeviceData ],
@@ -1303,10 +1313,12 @@ def _preset(self, loc_id: str) -> str | None:
13031313
13041314 locator = "./rule[active='true']/directives/when/then"
13051315 if (
1306- active_rule := self ._domain_objects .find (locator )
1307- ) is None or "icon" not in active_rule .keys (): # noqa: SIM118
1316+ not (active_rule := etree_to_dict (self ._domain_objects .find (locator )))
1317+ or "icon" not in active_rule
1318+ ):
13081319 return None
1309- return str (active_rule .attrib ["icon" ])
1320+
1321+ return active_rule ["icon" ]
13101322
13111323 def _schedules_legacy (
13121324 self , avail : list [str ], sel : str
You can’t perform that action at this time.
0 commit comments