sqlflow
sqlflow copied to clipboard
Support pytype to do static type checking for python code
Is your feature request related to a problem? Please describe. Developing in python is lacking protection from type checking now.
Describe the solution you'd like Use pytype to ease developing in python.
import typing
def f(x, y):
# type : (str, int) -> None
pass
f(1, "2")
$ pytype test.py
File "/root/test.py", line 5, in <module>: Function f was called with the wrong arguments [wrong-arg-types]
Expected: (x: str, ...)
Actually passed: (x: int, ...)
For more details, see https://google.github.io/pytype/errors.html#wrong-arg-types.
Describe alternatives (optional) Other similar tools Additional Notes
I believe pytype and other similar tools are prerequisites for improving the python development process and migrating core code from golang to python.
Candidates are: https://github.com/mattseymour/pre-commit-pytype https://github.com/pre-commit/mirrors-mypy and we have to find a way not to break the current (unchecked) code.