Skip to content

Commit

Permalink
[V3RC2] Fix nullability checks in invariants (#274)
Browse files Browse the repository at this point in the history
We missed to ensure non-nullability in various invariants, and fix them
in this patch. This was revealed once we implemented stricter
nullability checks in aas-core-codegen, which is to be merged in
shortly.
  • Loading branch information
mristin committed Jun 9, 2023
1 parent 5671db7 commit 2a81612
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions aas_core_meta/v3rc2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2251,7 +2251,7 @@ def __init__(
not (self.qualifiers is not None)
or (
not any(
qualifier.kind == Qualifier_kind.Template_qualifier
qualifier.kind_or_default() == Qualifier_kind.Template_qualifier
for qualifier in self.qualifiers
) or (
self.kind_or_default() == Modeling_kind.Template
Expand Down Expand Up @@ -2354,7 +2354,7 @@ def __init__(
not (self.qualifiers is not None)
or (
not any(
qualifier.kind == Qualifier_kind.Template_qualifier
qualifier.kind_or_default() == Qualifier_kind.Template_qualifier
for qualifier in self.qualifiers
) or (
self.kind_or_default() == Modeling_kind.Template
Expand Down Expand Up @@ -5288,8 +5288,10 @@ def is_BCP_47_for_english(text: str) -> bool:
)
@invariant(
lambda self:
not (self.data_type is None and self.data_type in IEC_61360_data_types_with_unit)
or (
not (
self.data_type is not None
and self.data_type in IEC_61360_data_types_with_unit
) or (
self.unit is not None or self.unit_id is not None
),
"Constraint AASc-009: If data type is a an integer, real or rational with "
Expand Down
2 changes: 1 addition & 1 deletion tests/test_v3rc2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@ def test_constraint_119_in_all_qualifiable_with_has_kind(self) -> None:
not (self.qualifiers is not None)
or (
not any(
qualifier.kind == Qualifier_kind.Template_qualifier
qualifier.kind_or_default() == Qualifier_kind.Template_qualifier
for qualifier in self.qualifiers
) or (
self.kind_or_default() == Modeling_kind.Template
Expand Down

0 comments on commit 2a81612

Please sign in to comment.