Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions backend/infrahub/core/schema/basenode_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,12 @@ def diff(self, other: Self) -> HashableModelDiff:
other=other,
get_func=BaseNodeSchema.get_attribute,
get_map_func=BaseNodeSchema.get_attributes_name_id_map,
obj_type=AttributeSchema,
)
# Relationships
rels_diff = self._diff_element(
other=other,
get_func=BaseNodeSchema.get_relationship,
get_map_func=BaseNodeSchema.get_relationship_name_id_map,
obj_type=RelationshipSchema,
)

if attrs_diff.has_diff:
Expand All @@ -230,7 +228,6 @@ def _diff_element(
other: Self,
get_func: Callable,
get_map_func: Callable,
obj_type: type[AttributeSchema | RelationshipSchema],
) -> HashableModelDiff:
"""The goal of this function is to reduce the amount of code duplicated between Attribute and Relationship to calculate a diff.

Expand Down Expand Up @@ -266,15 +263,15 @@ def _diff_element(

# Process element b
for name in sorted(present_both):
local_element: obj_type = get_func(self, name=name)
other_element: obj_type = get_func(other, name=name)
local_element = get_func(self, name=name)
other_element = get_func(other, name=name)
element_diff = local_element.diff(other_element)
if element_diff.has_diff:
elements_diff.changed[name] = element_diff

for element_id in shared_ids:
local_element: obj_type = get_func(self, name=reversed_map_local[element_id])
other_element: obj_type = get_func(other, name=reversed_map_other[element_id])
local_element = get_func(self, name=reversed_map_local[element_id])
other_element = get_func(other, name=reversed_map_other[element_id])
element_diff = local_element.diff(other_element)
if element_diff.has_diff:
elements_diff.changed[reversed_map_local[element_id]] = element_diff
Expand Down
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,8 @@ disable_error_code = [
"arg-type",
"assignment",
"attr-defined",
"no-redef",
"return-value",
"union-attr",
"valid-type",
"var-annotated",
]

Expand Down Expand Up @@ -1370,7 +1368,6 @@ invalid-assignment = "ignore"
include = [
"backend/infrahub/core/graph/constraints.py",
"backend/infrahub/core/query/relationship.py",
"backend/infrahub/core/schema/basenode_schema.py",
"backend/infrahub/core/schema/manager.py",
"backend/infrahub/core/schema/schema_branch.py",
]
Expand Down
Loading