transitions
transitions copied to clipboard
mypy support?
Hi, great library!!!!
Any plans to add support for mypy?
I'm using the library but missing types trigger this error
error: Skipping analyzing "transitions": module is installed, but missing library stubs or py.typed marker [import]
Same for us, but with asyncio
extension. Really looking forward to mypy support
transitions
0.9.0 has been published to PyPI and include typing stub files. Since transitions
allows rather arbitrary argument types in functions and constructors there might be some false positive typing warnings. I personally would expect false negatives though. My goal for 0.9.0 was to satisfy mypy
in 'common' usage scenarios without extensive typing of state and transition definitions. Since nested configurations are often not accurately typed by mypy
I opted for rather generic fallback types. Depending on your IDE this might lead to a vast amount of suggested type options. I am looking forward to community feedback to adjust this in upcoming releases.
For now I hope this makes your work slightly easier.
Thank you @aleneum
Will have to update to 0.9.0 and see how it plays out.
I am using 0.9.0 but cant seem to have type definitions work for trigger methods that are generated at run time
Hello @vaidik,
cant seem to have type definitions work for trigger methods that are generated at run time
as far as I know this cannot be done with a static code analysis and type annotation. DocMachine might be useful. Alternatively, you could define your trigger methods on your model in advance for IDEs and code checkers to pick up and use OverrideMachine to allow transitions
to override these methods during runtime. If you have a more elegant solution to deal with type checking and dynamic methods/attributes let me know.