Skip to content

[ports] Support ports that are types and treat string ports conversion properly. - #507

Merged
sea-bass merged 3 commits into
splintered-reality:develfrom
fgrcar:improve_port_type_conversions
Aug 21, 2026
Merged

sea-bass merged 3 commits into
splintered-reality:develfrom
fgrcar:improve_port_type_conversions

Conversation

@fgrcar

@fgrcar fgrcar commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

This PR addresses a couple of things related to the newly added ports and their type application when parsing from XML:

  1. Port's type can also be a type itself, so convert_str_to_type in ports_utils.py handles that.
  2. apply_type_hints method in ports_utils.py defined success based on comparison of the value before vs. after which makes sense for most of the types, but not for the string that remains the same even in case of a success. I addressed that by explicit return of success in all the helper methods.
  3. Some BT nodes can be a bit more generic and define type hints for the kwargs directly, so apply_type_hints fallbacks to that type in case of specific attribute type hint is not present.

I added also some tests that cover the port conversions.

Best regards,
fgrcar

@JenniferBuehler JenniferBuehler left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the fixes and for adding the new test!

Instead of lenghty comments to suggest changes, I made a PR on your PR: fgrcar#1

Other than this minor things, it looks good to me!

@sea-bass sea-bass left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice change, and thank you for adding tests!

I mostly just have some Python style things to consider.

Comment thread py_trees/ports_utils.py Outdated
Comment thread py_trees/ports_utils.py
Comment thread py_trees/ports_utils.py Outdated
Comment thread py_trees/ports_utils.py
Comment thread tests/test_ports_utils_conversions.py Outdated
JenniferBuehler and others added 2 commits August 20, 2026 18:07
* suggested improvements

* address feedback

@sea-bass sea-bass left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @fgrcar!

@sea-bass sea-bass changed the title Support ports that are types and treat string ports conversion properly. [ports] Support ports that are types and treat string ports conversion properly. Aug 21, 2026
@sea-bass
sea-bass merged commit fb97879 into splintered-reality:devel Aug 21, 2026
5 checks passed
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 this pull request may close these issues.

3 participants