Skip to content

Commit

Permalink
fix None return bug
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
  • Loading branch information
InvincibleRMC committed Oct 19, 2024
1 parent cece6d4 commit d90aa1a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions rosidl_parser/rosidl_parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
from rosidl_parser.definition import BasicTypeValues


AbstractTypeAlias = Union[AbstractNestableType, BoundedSequence, UnboundedSequence]
AbstractTypeAlias = Union[AbstractNestableType, BasicType, BoundedSequence, UnboundedSequence]

grammar_file = os.path.join(os.path.dirname(__file__), 'grammar.lark')
with open(grammar_file, mode='r', encoding='utf-8') as h:
Expand Down Expand Up @@ -352,6 +352,7 @@ def _find_path(node: ParseTree, target: ParseTree) -> List[ParseTree]:
tail = _find_path(c, target)
if tail is not None:
return [node] + tail
return None
raise ValueError(f'No path found between {node} and {target}')


Expand Down Expand Up @@ -402,21 +403,21 @@ def add_message_members(msg: Message, tree: ParseTree) -> None:
type_specs = list(member.find_data('type_spec'))
type_spec = type_specs[-1]
abstract_type = get_abstract_type_from_type_spec(type_spec)
assert isinstance(abstract_type, AbstractNestableType)
declarators = member.find_data('declarator')
annotations = get_annotations(member)
for declarator in declarators:
assert len(declarator.children) == 1
child = declarator.children[0]
assert isinstance(child, Tree)
if child.data == 'array_declarator':
assert isinstance(abstract_type, AbstractNestableType)
fixed_array_sizes = list(child.find_data('fixed_array_size'))
assert len(fixed_array_sizes) == 1, \
'Unsupported multidimensional array: ' + str(member)
positive_int_const = next(
fixed_array_sizes[0].find_data('positive_int_const'))
size = get_positive_int_const(positive_int_const)
member_abstract_type: Union[Array, AbstractNestableType] = \
member_abstract_type: Union[Array, AbstractTypeAlias] = \
Array(abstract_type, size)
else:
member_abstract_type = abstract_type
Expand Down

0 comments on commit d90aa1a

Please sign in to comment.