-
Notifications
You must be signed in to change notification settings - Fork 525
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
pylint complains that transition methods don't exist #426
Comments
Looking through closed issues I see that fundamentally this is related to Issue #383 |
So did you came up with the solution for your example without using docstrings? |
I have not made any attempt yet to prevent the issue. So far my "solution" is to say to myself "It's not really a problem" when pylint highlights one of these items. |
Perhaps we can just tell Pylint that these are generated members if we want the false positive warning will go away? More about why this happens here: https://www.lesinskis.com/pylint-false-positives.html |
If silencing E1101 is all that is needed, """a test"""
import transitions
class MyStateMachine:
"""A machine"""
# Define states
states = ['State_A', 'State_B']
def __init__(self):
# Initialize the state machine
self.state = None # prevents the linter from complaining that there is no state member
self.machine = transitions.Machine(model=self, states=self.states, initial='State_A',
auto_transitions=False)
# Define Transitions
self.machine.add_transition('run', 'State_A', 'State_B')
self.machine.add_transition('go', 'State_B', 'State_A')
def processing(self):
"""processes things"""
def rapid_processing(self):
"""processes things... but faster!"""
def main():
"""where the action is"""
example = MyStateMachine()
example.run()
if __name__ == "__main__":
main() However, I am not sure how this should be automatized though. Adding all potential triggers manually is quite cumbersome. For print(", ". join(example.machine.events.keys())) This will not include OTHER convenience functions such as whitelist = ['trigger', 'state']
whitelist.extend(example.machine.events.keys())
for s in example.machine.states:
whitelist.append(f'is_{s}')
print(",".join(whitelist)) # >>> trigger,state,run,go,is_State_A,is_State_B |
Closing this due to the lack of feedback. If you have more to add to that issue, feel free to comment. I will reopen the issue if necessary. |
From readme.md
example to reproduce:
pylint complains
How to prevent these errors?
The text was updated successfully, but these errors were encountered: