datnguye/dbterd

[FEAT] Add more types with mypy

Closed this issue · 3 comments

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.

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

@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.

@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)