diff --git a/aas_core_codegen/protobuf/common.py b/aas_core_codegen/protobuf/common.py index b6b84dbc..8f1abd8a 100644 --- a/aas_core_codegen/protobuf/common.py +++ b/aas_core_codegen/protobuf/common.py @@ -1,12 +1,12 @@ """Provide common functions shared among different ProtoBuf code generation modules.""" import re -from typing import List, cast, Optional +from typing import List, cast from icontract import ensure, require from aas_core_codegen import intermediate -from aas_core_codegen.common import Stripped, assert_never +from aas_core_codegen.common import Stripped, assert_never, Identifier from aas_core_codegen.protobuf import naming as proto_naming @@ -147,7 +147,7 @@ def generate_type(type_annotation: intermediate.TypeAnnotationUnion) -> Stripped # We have to add the suffix ``_choice`` since this field points # to one of the concrete descendants of the class as well as # the concrete class itself. - message_name += "_choice" + message_name = Identifier(message_name + "_choice") return Stripped(message_name) diff --git a/aas_core_codegen/protobuf/structure/_generate.py b/aas_core_codegen/protobuf/structure/_generate.py index c641c630..e2dda3c5 100644 --- a/aas_core_codegen/protobuf/structure/_generate.py +++ b/aas_core_codegen/protobuf/structure/_generate.py @@ -9,13 +9,11 @@ Tuple, cast, Union, - Set, ) from icontract import ensure, require from aas_core_codegen import intermediate -from aas_core_codegen import specific_implementations from aas_core_codegen.common import ( Error, Identifier, @@ -403,7 +401,7 @@ def _generate_choice_class(cls: intermediate.ClassUnion) -> Stripped: # Protocol Buffers do not support inheritance, so we have to work around that # circumstance. - message_name = proto_naming.class_name(cls.name) + "_choice" + message_name = Identifier(proto_naming.class_name(cls.name) + "_choice") else: assert_never(cls) @@ -440,8 +438,6 @@ def generate( errors = [] # type: List[Error] - required_choice_objects = set([]) # type: Set[intermediate.AbstractClass] - for our_type in symbol_table.our_types: if not isinstance( our_type,