Add type checking
iron3oxide opened this issue · 3 comments
Right now, running a type checker like pyright on the project reveals that many parts of the code are not type safe while others are only safe at runtime and should be marked as such with a #type: ignore
comment. While I recognize that this is a bit of extra work, it has been my experience that it prevents a lot of bugs from making it into production code.
100% sure that type safety could be improved since it has not been the top priority at this point.
There may be patterns that work against type safety / automatic type checking (e.g. IntentResult without type hint for data) and we are in the process of refactoring them.
@iron3oxide could you provide an example of your type checker workflow?
All I typically do is set Python > Analysis > Type Checking Mode to "basic" in Pylance, which uses pyright under the hood. If that highlights an error in my code, I either mitigate that (there are several possible ways to do that, flet seems to use assert
statements a lot) or add the aforementioned comment to make it go away if it cannot be mitigated and e.g. the variable will never be None at runtime.
It seems to me that you are proposing an addition to the Development Guide. Please go ahead.