Wikidata / soweego

Link Wikidata items to large catalogs
https://meta.wikimedia.org/wiki/Grants:Project/Hjfocs/soweego_2
GNU General Public License v3.0
95 stars 8 forks source link

Introduce static type analysis #382

Open MaxFrax opened 4 years ago

MaxFrax commented 4 years ago

As we all know, a full soweego execution takes weeks. Therefore, it's crucial not to waste any of it. In my experience, happened more than once the execution stopped after days, all due to a change of some function signature.

There are many other easily avoidable issues like that one. I propose to introduce mypy to do some static type checking.

The idea is to set it up in travis and let it decline the PRs in which the number of errors it finds goes up (in comparison with the number of errors in the merge target branch). In this way, PR by PR the code quality and readability will increase.

marfox commented 4 years ago

I introduced a shell script in 23afc3ef5399eae5a4c5f25081424731d04e931c that also runs mypy. We can tell travis to execute it and fail the build as appropriate.

Note that mypy only checks functions with type hints declared, and ignores the others, so it's not a complete solution.

MaxFrax commented 4 years ago

I introduced a shell script in 23afc3e that also runs mypy. We can tell travis to execute it and fail the build as appropriate.

Note that mypy only checks functions with type hints declared, and ignores the others, so it's not a complete solution.

I think it can be set to complain if the types are not declared. A setting like this one, would encourage us to increase the type declarations coverage.

EDIT: I would like to dig deeper in the matter and get the most we can from this tool.