0

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?

freezed
  • 1,269
  • 1
  • 17
  • 34
  • you mean this https://pylint.readthedocs.io/en/latest/technical_reference/features.html#messages-control-options ??? if yes it took me about two and half minutes to find, which is very probably less than it took you to write the above question... – bruno desthuilliers Mar 12 '18 at 14:55
  • 1
    Of course not… I want to go further these single phrases! My IDE gives it already… When I have some refactor 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](https://www.python.org/dev/peps/pep-0008/), 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. ? If python accept to run the code what is the point…? – freezed Mar 12 '18 at 15:14
  • 1
    You should edit your question to make it more explicit then - but I'm afraid it's going to be closed as either too broad and/or primarily opinion based... – bruno desthuilliers Mar 13 '18 at 08:19
  • I think you're asking what the severity of each warning is, and for an authoritative reference for each, and also the significance of the default values of each [options in the Design checker](https://pylint.readthedocs.io/en/latest/technical_reference/features.html#id4). But that's probably not good question material for SO, since it's subjective. Try blogs or tutorials about Python linting. – smci Mar 13 '18 at 08:58
  • I edited my question, is it clearer now? – freezed Mar 13 '18 at 10:07

3 Answers3

2

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.

freezed
  • 1,269
  • 1
  • 17
  • 34
  • It seems that the official documentation is more complete than this wikidot thing about pylint messages: https://pylint.readthedocs.io/en/latest/technical_reference/features.html#pylint-checkers-options-and-switches – bli Oct 03 '19 at 11:47
0

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.

bruno desthuilliers
  • 75,974
  • 6
  • 88
  • 118
-1

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.

Terry Jan Reedy
  • 18,414
  • 3
  • 40
  • 52
  • Maybe I do not find the good words to explain what I'm looking for, see my [comment below](https://stackoverflow.com/questions/49238036/where-are-the-references-of-all-the-pylints-warning/49238260#comment85480553_49238036). [PyLint Messages](http://pylint-messages.wikidot.com/all-codes) should be interesting… if the code page exist… if the explanation is filled and… if the subject is not trivial. Anyway, thank you for this original _google tip_ ;-) – freezed Mar 12 '18 at 15:42
  • 1
    I understood, at least partly, and it is the pages linked on that page that give more than the sometimes cryptic phrases. – Terry Jan Reedy Mar 12 '18 at 17:08
  • This page does not seem to explain more about the pylint warning messages than what is already in the official documentation. Message R1722 isn't even present in that page. – bli Oct 03 '19 at 11:43