lint appeasement (was: @staticmethod or def function()?)

Cameron Simpson cs at cskk.id.au
Wed Oct 31 17:46:32 EDT 2018


On 31Oct2018 21:23, Marko Rauhamaa <marko at pacujo.net> wrote:
>Peter Otten <__peter__ at web.de>:
>> Do not make changes to your code only to apeace a linter.
>
>Precisely. Don't let a tool drive a show.

While this is sound for semantic changes (and a function versus a 
@staticmethod is verging on that), I would point out that cleaning lint 
is often useful in order to make the linter useful.

If the useful lint warnings are buried in a sea of dross, and you want 
to lint things, then it can be well worth making some changes to clean 
up noise.

Ideally of course the linter should recognise some hooks (typically 
special comments) to mark particular pieces of code as deliberately not 
matching the linter's opinions. And certainly I run some linters with 
various checks tuned or disabled.

I'm doing this on an ongoing basis in my libraries as I work on other 
changes: make the change, debug, then lint, with the linting in distinct 
commits unless it is tiny. This is gardually bringing consistency to the 
code and catching the odd bug or rough edge such as "variable set but 
not used".

The end game here is that your lint output should be empty so that when 
it isn't empty the messages are useful.

Cheers,
Cameron Simpson <cs at cskk.id.au>



More information about the Python-list mailing list