Skip to content

Commit afe242a

Browse files
committed
remove attributes with no fields from the non-visited list after removal
1 parent 16138b2 commit afe242a

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/pynxtools/dataconverter/validation.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,12 +898,18 @@ def check_attributes_of_nonexisting_field(
898898
type_of_parent_from_tree == "group"
899899
or type_of_parent_from_tree is None
900900
):
901-
keys_to_remove.append(key)
902901
collector.collect_and_log(
903902
key[0:last_index],
904903
ValidationProblem.AttributeForNonExistingField,
905904
"attribute",
906905
)
906+
collector.collect_and_log(
907+
key,
908+
ValidationProblem.KeyToBeRemoved,
909+
"attribute",
910+
)
911+
keys_to_remove.append(key)
912+
remove_from_not_visited(key)
907913

908914
def check_type_with_tree(
909915
node: NexusNode,

tests/dataconverter/test_validation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ def listify_template(data_dict: Template):
861861
{"link": "/my_entry/nxodd_name/char_value"},
862862
),
863863
[],
864-
id="base-class-links-with-matching-nexus-types",
864+
id="baseclass-links-with-matching-nexus-types",
865865
),
866866
pytest.param(
867867
alter_dict(
@@ -878,7 +878,7 @@ def listify_template(data_dict: Template):
878878
"Field /ENTRY[my_entry]/SAMPLE[my_sample] written without documentation.",
879879
"Expected a field at /ENTRY[my_entry]/SAMPLE[my_sample]/name but found a group.",
880880
],
881-
id="base-class-links-with-wrong-nexus-types",
881+
id="baseclass-links-with-wrong-nexus-types",
882882
),
883883
pytest.param(
884884
alter_dict(
@@ -1340,7 +1340,7 @@ def listify_template(data_dict: Template):
13401340
[
13411341
"Reserved suffix '_weights' was used in /ENTRY[my_entry]/OPTIONAL_group[my_group]/FIELDNAME_weights[some_random_field_weights], but there is no associated field some_random_field.",
13421342
],
1343-
id="reserved-suffix-from-base-class",
1343+
id="reserved-suffix-from-baseclass",
13441344
),
13451345
pytest.param(
13461346
alter_dict(

0 commit comments

Comments
 (0)