tuttle-dev / tuttle

🪰 Tuttle - time and money management for freelancers
GNU General Public License v3.0
62 stars 12 forks source link

Add type checking #161

Closed iron3oxide closed 1 year ago

iron3oxide commented 1 year ago

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.

clstaudt commented 1 year ago

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?

iron3oxide commented 1 year ago

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.

clstaudt commented 1 year ago

It seems to me that you are proposing an addition to the Development Guide. Please go ahead.