I am still discovering Pylint and I understand why many Pythonists deactivate some (or many) warnings to lower Pylint
's voice, but for the moment, as a Python newbie I want to use pylint
to improve my Pythonic comprehension and my code quality, in order to help me to:
- learning more from a statement/instruction
- deepen some concepts
- evaluate the benefits / drawback of a refactoring
- etc.
So is there a place where all the warning are discussed, justified, explained or they simply came from the great minds of the pylint
team?
Ok, thanks for answers.
I like using
pylint
to help me coding better and I was hoping that thepylint
project explains and arguments somewhere the warnings with details useful for beginners like me: helping to:It looks like it is not the case.
Anyway, although it is really not filled-in/detailed enough, Pylint messages (which I found before asking my question) remain the least bad answer to my question.
When I enter
pylint warnings
into a web (google) search bar, the first hit is PyLint Messages, with a link to a page explaining each message.Answering to your comment:
Those are mostly based on "best practices" - "golden rules" which are mostly derived from experience but can err a bit on the arbitrary side sometimes - and actually the numbers you mention are indeed arbitrary but you do have to set an arbitrary limit here, at least until pylint grows and IA.
Because code has to be maintained - you typically spend hundreds more time maintaining code (fixing bugs, improving performances and adding features) than writing the first version -, and small, well decoupled, simple functions doing one single thing are easier to read, understand, reason about and test than overly long functions doing three different things at once and implemented with deeply nested branches and lots of side effects.
Now as I mentionned the numbers you mention are indeed arbitrary and may or not be appropriate for a given part of your code. Some functions are intrisincally complex and require more complex code, and you need both programming experience and a good enough knowledge of the problem to assess your code quality.
Pylint can only warn you about things that might be code smells, it's up to you to decide if the code can be improved or if it's ok (and then possibly turn off some warnings for a given statemement or function or module etc). Also there are code smells that pylint can't really detect - like a function doing too many different things - so you still have to re-read your code and ask yourself if it's ok or not. Testability is a good indicator here, if you cannot easily unittest a function then chances are it's doing too many things - but here again some parts of the code (the ones that bridges UI and domain for example) are by definition harder to unittest so here again you do have to use your own judgment.