datnguye / dbterd

Generate the ERD as a code from dbt artifacts
https://dbterd.datnguyen.de/
MIT License
208 stars 30 forks source link

[FEAT] Add more types with mypy #79

Closed syou6162 closed 8 months ago

syou6162 commented 8 months ago

Is your feature request related to a problem? Please describe. Recently added or modified functions are typed by mypy, but many of the older functions are not typed by mypy (although it helps that docstrings are listed!).

We would like to have more functions and arguments typed by mypy for code readability and to get more assistance from the IDE.

Describe the solution you'd like Assigning types by mypy to the arguments and return values of untyped functions!

Describe alternatives you've considered N/A

Additional context I will send a pull request over the weekend or whenever I have free time.

datnguye commented 8 months ago

Thanks @syou6162 again 🚀

What do you recommend for adding a mypy command to check in PR CI? I think it's good to add this check into poe lint command

syou6162 commented 8 months ago

@datnguye Unfortunately, I was unaware of any tools suitable for such a purpose. I'll ask my colleagues and friends if they know of any that might be good.

syou6162 commented 8 months ago

@datnguye After a little research, it seems that mypy itself does type checking. However, when I ran this against dbterd's existing code, I got a lot of errors, so I guess we should fix these before introducing it to CI.

Example.

% mypy dbterd/adapters/meta.py
dbterd/adapters/meta.py:26: error: Incompatible types in assignment (expression has type "None", variable has type "str") [assignment].
Found 1 error in 1 file (checked 1 source file)