Skip to content

Commit b7abe3e

Browse files
committed
Pre-compute keys
1 parent 23c8876 commit b7abe3e

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

linode_api4/objects/base.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -408,15 +408,14 @@ def _populate(self, json):
408408
self._set("_raw_json", json)
409409
self._set("_updated", False)
410410

411+
valid_keys = set(
412+
k
413+
for k, v in type(self).properties.items()
414+
if (not v.identifier) and (not v.alias_of)
415+
) | set(self.properties_with_alias.keys())
416+
411417
for api_key in json:
412-
if api_key in chain(
413-
(
414-
k
415-
for k, v in type(self).properties.items()
416-
if (not v.identifier) and (not v.alias_of)
417-
), # Exclude identifiers and aliased properties to avoid conflicts with API attributes
418-
self.properties_with_alias.keys(),
419-
):
418+
if api_key in valid_keys:
420419
prop = type(self).properties.get(api_key)
421420
prop_key = api_key
422421

0 commit comments

Comments
 (0)