Closed nsmith- closed 4 years ago
I don't know if a linter would have caught these, but a type check would have.
I don't know if a linter would have caught these, but a type check would have.
It would have. Personally I use flake8
editor integration to catch these as I type them but there are others.
Wow, that's more powerful than I thought. I guess I should learn how to use linters, starting with flake8.
As I mentioned in the commit message, "I found one, and flake8 found the rest"
You can create a .flake8
file in the root directory and turn off some of the more zealous options, see e.g. https://github.com/CoffeaTeam/coffea/blob/master/.flake8
Sorry, missed that (have to click on the "...").
I had been under the impression that linters like flake8 were for enforcing proper formatting. If it can identify misspelled variable names, it must have some model for what attributes the classes have. (In principle, that's not possible due to Python's dynamism—what if I create the variable with eval
? But it must be capable of doing some reasonable things for reasonably defined classes.) Misspelled variables, particularly in error cases that are less often tested, is one of the biggest benefits of a statically typed language, but I guess the Python community has got this figured out!
I'll use your .flake8
as a starting point, and it's on my to-do list to learn how to run it. I need to allot some time because it will probably find a long list of issues that I'll need to fix (or learn how to ignore).
Of course since you can do anything in python, there are some situations where flake8 will flag a false positive. However, on an individual line level you can tell it to ignore certain problems with the syntax (some code) # noqa: Exxx
where Exxx
is the error or warning that was raised.
Also more propagation of docstrings. Although 0.x is dying, maybe worth running some linter on this repo anyway.