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

Skip to content

Python generated class doesn't call the base class constructor. #429

@alexis-boisserand

Description

@alexis-boisserand

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

It could be rewritten like this, so that all potential arguments get passed to the base class constructor:

    # 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

Here is my attempt to implement it that way:
main...alexis-boisserand:StateSmith:main

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions