Search code examples
whitespacepylint

pylint not generating messages for C0326 whitepace violations


pylint is not producing the expected convention warning messages for whitespace non-conformances.

python 3.6.8

pylint 2.13.5

using this test script :

from __future__ import print_function
import os, sys
import logging
from .. import views

class DoSomething(SomeCommand) : # space before colon !

    def __init__(self):
        for i in range(1,11):   # no space after comma !!
            if self.number == i:
                print("matched")
            else:
                print ('not matched') # space before paren !!!

    def check_user(self):
        if self.user: return True
        else  : return False    # spaces before colon !

results from pylint check :

PS C:\Users\PycharmProjects\coding_standard\src> pylint test_script.py
************* Module test_script
test_script.py:18:0: C0304: Final newline missing (missing-final-newline)
test_script.py:1:0: C0114: Missing module docstring (missing-module-docstring)
test_script.py:3:0: C0410: Multiple imports on one line (os, sys) (multiple-imports)
test_script.py:5:0: E0402: Attempted relative import beyond top-level package (relative-beyond-top-level)
test_script.py:7:0: C0115: Missing class docstring (missing-class-docstring)
test_script.py:7:18: E0602: Undefined variable 'SomeCommand' (undefined-variable)
test_script.py:16:4: C0116: Missing function or method docstring (missing-function-docstring)
test_script.py:17:8: R1703: The if statement can be replaced with 'return bool(test)' (simplifiable-if-statement)
test_script.py:17:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
test_script.py:17:22: C0321: More than one statement on a single line (multiple-statements)
test_script.py:7:0: R0903: Too few public methods (1/2) (too-few-public-methods)
test_script.py:3:0: W0611: Unused import os (unused-import)
test_script.py:3:0: W0611: Unused import sys (unused-import)
test_script.py:4:0: W0611: Unused import logging (unused-import)
test_script.py:5:0: W0611: Unused import views (unused-import)

Based on the docs I would expect to see C0326 messages for the commented lines.

I am using this as the reference for the conditions to be identified by C0326: http://pylint-messages.wikidot.com/messages:c0326

Any suggestions to T/S this ?

Based on comment from @DylanLee ... If I did it is truly by accident. I am not (knowingly) using any kind of config file to disable messages. Based on your comment, I ued the command line option: $pylint --list-msgs-enabled

, which produces a list ...

Enabled messages:
  ...
  multiple-statements (C0321)
  superfluous-parens (C0325)
  mixed-line-endings (C0327)
  unexpected-line-ending-format (C0328)
  wrong-spelling-in-comment (C0401)
   ...

Disabled messages:
  raw-checker-failed (I0001)
  bad-inline-option (I0010)
  locally-disabled (I0011)
  file-ignored (I0013)
  suppressed-message (I0020)
  useless-suppression (I0021)
  deprecated-pragma (I0022)
  use-symbolic-message-instead (I0023)

So, it is not obviously being disable, but is not included in the enabled list ! Maybe some updates to pylint that is suppressing that specific message ?


Solution

  • bad-whitespace has been removed from pylint in 2.6. You should use an autoformatter like black and pre-commit to handle this automatically.

    See : https://pylint.pycqa.org/en/latest/whatsnew/2.6.html?highlight=bad-whitespace#other-changes

    bad-continuation and bad-whitespace have been removed. black or another formatter can help you with this better than Pylint