Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@alexis-boisserand
Copy link

In Python, if a constructor is declared, it has to explicitly call the base class constructor, otherwise it's never called.
Currently the generated class constructor looks something like this:

    # State machine constructor. Must be called before start or dispatch event functions. Not thread safe.
    def __init__(self):
        # Used internally by state machine. Feel free to inspect, but don't modify.
        self.stateId = None

This PR modifies the inherited class constructor, so that the base class constructor gets called with any parameter it needs.

    # State machine constructor. Must be called before start or dispatch event functions. Not thread safe.
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        # Used internally by state machine. Feel free to inspect, but don't modify.
        self.stateId = None

@alexis-boisserand alexis-boisserand changed the title Calls base class constructor. Calls base class constructor when generating python code. Jan 7, 2025
Copy link
Contributor

@adamfk adamfk left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! It might be a few days before I have to time to properly release it.

@adamfk adamfk merged commit 56e18de into StateSmith:main Jan 8, 2025
4 checks passed
@adamfk
Copy link
Contributor

adamfk commented Jan 8, 2025

I added you to the changelog. Thanks again! https://github.com/StateSmith/StateSmith/blob/main/CHANGELOG.md?plain=1#L35-L41

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