christabor / random-ideas

Random project ideas that have not been implemented, for the world to see (and perhaps do, if interested!)
MIT License
2 stars 0 forks source link

Convention linter python #12

Open christabor opened 6 years ago

christabor commented 6 years ago

Linter that assumes certain conventions, and if they match, checks for conditions being met:

decorators.py

I really like to put project specific decorators in a file named this. It's very obvious what the intent is. It also works well in practice. So, if someone does it, then the lint rule is: check for these files. If they exist, check that each one imports functools.wraps and uses it on all functions in that module.

managers.py

Same idea as above. This one is tricky, since the user may do it many ways, but potentially check for contextlib.context manager decorator and.check application on all functions. Or maybe, only of its a function. And if a class, that's not an exception, check for enter and exit magic methods.

constants

Checks that all module level variables are uppercase. I think existing linters already do this.

dependency graphs

Generate dependency graphs based on imports, calling signatures. Then see where complexity is, distribution, median edge number, etc for graph relationship stats and potential linters around that (similar to mcccabes)