Skip to content

Commit

Permalink
extract logic to function
Browse files Browse the repository at this point in the history
  • Loading branch information
pyohannes committed Mar 12, 2024
1 parent ccf8203 commit 7f704bf
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,20 @@ def _get_attributes(self, templates: Optional[bool]):
if not hasattr(self, "attrs_by_name"):
return []

def comparison_key(attr):
if attr.requirement_level:
return attr.requirement_level.value, attr.fqn
else:
return RequirementLevel.RECOMMENDED.value, attr.fqn

return sorted(
[
attr
for attr in self.attrs_by_name.values()
if templates is None
or templates == AttributeType.is_template_type(attr.attr_type)
],
key=lambda attr: (
(
attr.requirement_level.value
if attr.requirement_level
else RequirementLevel.RECOMMENDED.value
),
attr.fqn,
),
key=comparison_key
)

def __init__(self, group, strict_validation=True):
Expand Down

0 comments on commit 7f704bf

Please sign in to comment.