Home > database >  Pylint cannot detect the missing space after # sign of comments and missing blank line, Python3
Pylint cannot detect the missing space after # sign of comments and missing blank line, Python3

Time:02-14

I have written a try_pylint.py file to try if pylint can detect some incorrect style with Python 3.10.

"""This is a try for pylint detection.
"""

#hello world!  --> missing a space, and it has only 1 (needs 2) blank line before it.

def print_hello():
    """print it
    """
    print('hello')

If I run the command in terminal pylint try_pylint.py, it gives

Your code has been rated at 10.00/10 (previous run: 10.00/10,  0.00)

However, if I use flake8, it can detect both of them. flake8 try_pylint.py gives

try_pylint.py:4:1: E265 block comment should start with '# '
try_pylint.py:6:1: E302 expected 2 blank lines, found 1

Could you please show me how to configure pylint to detect them? By the way, I am using VS Code for developing Python code. It would be great if you can show me how to configure it on VS Code.

Thanks in advance!

CodePudding user response:

The actual check is done by pycodestyle inside flake8. pylint do not check for this and for formatting in general (as black can format your code automatically, this kind of check are not very useful anymore).

You should use black, flake8 and pylint together, they are not mutually exclusive.

  • Related