Skip to content Skip to sidebar Skip to footer

Where Are Detailed The Rules, Concepts And Usages Behind Each Pylint's Warnings?

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

Solution 1:

Ok, thanks for answers.

I like using pylint to help me coding better and I was hoping that the pylint project explains and arguments somewhere the warnings with details useful for beginners like me: helping to:

  • understand why it is important to consider these warnings
  • when a certain context can moderate the point of view
  • when it came from a PEP
  • etc.

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.

Solution 2:

Answering to your comment:

When I have some warnings I'd like to know a bit more than "too many 'whatever'", "invalid 'something'", etc. If my code work fine I assume these warnings are kind of guide lines and mays be studied with the context. For syntax, I refer on PEP8, but for the other warnings? OK all warning do not have a PEP. Why the max branch is set to 15, statements is set to 50, variables set to 15, etc. ?

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.

If python accept to run the code what is the point…?

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.

Solution 3:

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.

Post a Comment for "Where Are Detailed The Rules, Concepts And Usages Behind Each Pylint's Warnings?"