sqlflow icon indicating copy to clipboard operation
sqlflow copied to clipboard

Support pytype to do static type checking for python code

Open shendiaomo opened this issue 5 years ago • 2 comments

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

shendiaomo avatar May 11 '20 07:05 shendiaomo

I believe pytype and other similar tools are prerequisites for improving the python development process and migrating core code from golang to python.

shendiaomo avatar May 13 '20 17:05 shendiaomo

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.

shendiaomo avatar Jul 09 '20 15:07 shendiaomo