pytransitions / transitions

A lightweight, object-oriented finite state machine implementation in Python with many extensions
MIT License
5.49k stars 525 forks source link

In a class ABCD inside the init method I have variable state consisting of OrderedDict containing list of dictionaries. Basically the state is of module 'transitions' which are imported from class 'machine' and inside state I have orderedDict consisting of list of dictionaries. #603

Closed msdian-hub closed 1 year ago

msdian-hub commented 1 year ago

State as variable in init method containing OrderedDict consiting of list of dictionaries not working as intended.

class ABCD(Machine) def init(self,args): self.a=opts['a'] self.a=opts['b'] self.states=orderedDict([{'name':'start'},{'name':'connection','on_enter':'go'}])

Error: Argument of type "list[dict[str, str]]" cannot be assigned to parameter "iterable" of type "Iterable[list[str]]" in function "init__"

Is the orderedDict not allowed inside init method. How can I deal with that?

Thanks in advance.

Originally posted by @anirudhsuri in https://github.com/pytransitions/transitions/discussions/602

aleneum commented 1 year ago

Hello @msdian-hub,

as you initially guessed, this is more suitable for a discussion. I will answer your question there.