dffml icon indicating copy to clipboard operation
dffml copied to clipboard

ci: Static type checking

Open johnandersen777 opened this issue 6 years ago • 11 comments

https://github.com/Microsoft/pyright

or

https://google.github.io/pytype/user_guide.html

or

https://pyre-check.org/

johnandersen777 avatar Mar 24 '19 16:03 johnandersen777

Hey I can work on this. Do we have to use pyright or can we use mypy too?

yashlamba avatar Apr 03 '19 20:04 yashlamba

mypy is weird that's why everything is borked right now. I think google's verion of things might be better: https://google.github.io/pytype/user_guide.html because it can make type annotations for functions that don't have them. I guess just mess with both and let me know what you think. I think we'll end up running google's and microsofts at the end of the day, and pylint to catch the most issue.

So, if you want to do this, id say probably start with google's, In some of the smaller more self contained files first, then let me know how its going and we'll move from there. Thanks!

johnandersen777 avatar Apr 03 '19 20:04 johnandersen777

I tried Pytype and I guess it's great. I saw a few repos that used mypy and are having troubles. It is quite easy to add to travis, should I do it or wait?

yashlamba avatar Apr 03 '19 21:04 yashlamba

Well, travis is going to stop any pull requests with issues, so we need to fix all the issues before adding to travis

johnandersen777 avatar Apr 03 '19 21:04 johnandersen777

So ya, start a new PR, enable it in travis, and then start fixing the issues I think it the best way to move forward. Add it by creating a new function in .ci/run.sh and then adding a new environment variable to the build matrix in travis, TYPE_CHECK=1

johnandersen777 avatar Apr 03 '19 21:04 johnandersen777

Issues related to type checking, right? I can run pytype locally now, to fix them if it finds any.

yashlamba avatar Apr 03 '19 21:04 yashlamba

Yes just type checking for now so we keep the PR to only about this. Thanks!!

johnandersen777 avatar Apr 03 '19 21:04 johnandersen777

Last thing, is it necessary to create a function? Would this work (https://github.com/google/importlab/blob/master/.travis.yml). This was provided in the documentation as an example to integrate pytype.

yashlamba avatar Apr 03 '19 21:04 yashlamba

mypy plugin docs might be useful whenever we get to this: https://mypy.readthedocs.io/en/stable/extending_mypy.html?highlight=plugin#extending-mypy-using-plugins

johnandersen777 avatar May 07 '21 21:05 johnandersen777

Might be able to use this to validate type hints at runtime: https://pydantic-docs.helpmanual.io/

johnandersen777 avatar Jun 15 '21 16:06 johnandersen777

https://docs.python.org/3/library/typing.html#typing.Annotated For definitions

johnandersen777 avatar Feb 19 '22 12:02 johnandersen777