Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected YAML parsing with get_attr and List[Entity] type #762

Open
baconbrot opened this issue Mar 4, 2024 · 1 comment
Open

Unexpected YAML parsing with get_attr and List[Entity] type #762

baconbrot opened this issue Mar 4, 2024 · 1 comment

Comments

@baconbrot
Copy link

Bug report

The get_attr method from the YAML entity looks wrong to me when using data_type=List[Entity].

The names of the entities returned by following section

        if check_is_list_entity(data_type):
            if isinstance(data, list) and isinstance(data[0], dict):
                return [Entity(child, name) for child in data]
            raise TypeError(
                "Attribute '{}' of Entity '{}' expected to be a list of dictionaries.".format(
                    name, self.type_name
                )
            )

are all set to the name of the parent attribute.

Example

Changing the timer event parse method to accept an actions attribute of data_type=List[Entity] then the above code using following launch.yaml

launch:
  - timer:
      period: 3.0
      actions:
        - log:
            message: 'Timer msg 1!'
        - log:
            message: 'Timer msg 2!'

creates for each log entity an entity with type_name=actions instead of type_name=log.

The children property inside this entity class implements the correct (expected) logic.

Is this logic intended or a bug?

baconbrot added a commit to baconbrot/launch that referenced this issue Mar 4, 2024
Signed-off-by: Christian Ruf <[email protected]>
@baconbrot
Copy link
Author

Actually I am wrong!
This is not a bug but intended behavior.
An example use case is the parsing of node params.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant