Skip to content
Merged
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: 7 additions & 4 deletions aas_core_codegen/intermediate/_translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4456,17 +4456,20 @@ def _verify_only_simple_type_patterns(symbol_table: SymbolTable) -> List[Error]:
type_anno = beneath_optional(prop.type_annotation)
if isinstance(type_anno, ListTypeAnnotation):
if not (
isinstance(type_anno.items, OurTypeAnnotation)
and isinstance(
type_anno.items.our_type, (AbstractClass, ConcreteClass)
isinstance(type_anno.items, PrimitiveTypeAnnotation)
or (
isinstance(type_anno.items, OurTypeAnnotation)
and isinstance(
type_anno.items.our_type, (AbstractClass, ConcreteClass)
)
)
):
errors.append(
Error(
prop.parsed.node,
f"We currently support only a limited set of "
f"type annotation patterns. At the moment, we handle "
f"only lists of classes (both concrete or abstract), "
f"only lists of classes (both concrete or abstract) or primitive types, "
f"but the property {prop.name!r} "
f"of the class {cls.name!r} "
f"has type: {prop.type_annotation}. "
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
SymbolTable(
our_types=[
ConcreteClass(
name='SomeContainerClass',
inheritances=[],
inheritance_id_set=...,
ancestors=[],
ancestor_id_set=...,
is_implementation_specific=False,
interface=None,
descendant_id_set=...,
descendants=[],
concrete_descendant_id_set=...,
concrete_descendants=[],
properties=[
Property(
name='x',
type_annotation=ListTypeAnnotation(
items=PrimitiveTypeAnnotation(
a_type='STR',
parsed=...),
parsed=...),
description=None,
specified_for='Reference to ConcreteClass SomeContainerClass',
parsed=...)],
methods=[],
constructor=Constructor(
name='__init__',
arguments=[
Argument(
name='x',
type_annotation=ListTypeAnnotation(
items=PrimitiveTypeAnnotation(
a_type='STR',
parsed=...),
parsed=...),
default=None,
parsed=...)],
returns=None,
description=None,
contracts=Contracts(
preconditions=[],
snapshots=[],
postconditions=[]),
parsed=...,
arguments_by_name=...,
is_implementation_specific=False,
statements=[
textwrap.dedent("""\
AssignArgument(
name='x',
argument='x',
default=None)""")],
inlined_statements=[
textwrap.dedent("""\
AssignArgument(
name='x',
argument='x',
default=None)""")]),
invariants=[],
serialization=Serialization(
with_model_type=False),
description=None,
parsed=...,
properties_by_name=...,
property_id_set=...,
methods_by_name=...,
method_id_set=...,
invariant_id_set=...)],
our_types_topologically_sorted=[
'Reference to our type SomeContainerClass'],
enumerations=[],
constrained_primitives=[],
classes=[
'Reference to our type SomeContainerClass'],
concrete_classes=[
'Reference to our type SomeContainerClass'],
constants=[],
constants_by_name=...,
verification_functions=[],
verification_functions_by_name=...,
meta_model=MetaModel(
description=None,
version='dummy',
xml_namespace='https://dummy.com'))
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class SomeContainerClass:
x: List[str]

def __init__(self, x: List[str]) -> None:
self.x = x


__version__ = "dummy"
__xml_namespace__ = "https://dummy.com"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The constructor argument 'x' and the property 'x' for the class 'SomeContainerClass' mismatch in type. The argument is typed as List[int] while the property is typed as List[str]. We expect the constructors and the properties to match in type.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class SomeContainerClass:
x: List[str]

def __init__(self, x: List[int]) -> None:
self.x = x


__version__ = "dummy"
__xml_namespace__ = "https://dummy.com"