Skip to content

fix: make nested dataclass public in generated python #271

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MrBlenny
Copy link
Contributor

@MrBlenny MrBlenny commented Jul 24, 2025

Currently dataclasses generated in python look like:

class admittance_controller:

    class Params:
        # for detecting if the parameter struct has been updated
        stamp_ = Time()
        ...
        class __Pid:
            rate = 0.005
            class __MapJoints:
                p = 1.0
                i = None
                d = 1.0
            __map_type = __MapJoints
            def add_entry(self, name):
                if not hasattr(self, name):
                    setattr(self, name, self.__map_type())
                return getattr(self, name)
            def get_entry(self, name):
                return getattr(self, name)
        pid = __Pid()

The problem with this is you cannot access the child classes using admittance_controller.Params.__Pid because of the __. This PR changes this so the classes are no longer private.

class admittance_controller:

    class Params:
        # for detecting if the parameter struct has been updated
        stamp_ = Time()
        ...
        class Pid:
            rate = 0.005
            class MapJoints:
                p = 1.0
                i = None
                d = 1.0
            _map_type = MapJoints
            def add_entry(self, name):
                if not hasattr(self, name):
                    setattr(self, name, self.__map_type())
                return getattr(self, name)
            def get_entry(self, name):
                return getattr(self, name)
        pid = Pid()

Given they were private before I don't expect this will cause any backwards compatbility issues.

@MrBlenny MrBlenny changed the title fix: make dataclasss public fix: make nested dataclass public in generated python Jul 24, 2025
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.

1 participant