Run Pylint for all Python files in a directory and all subdirectories
Just pass the directory name to the pylint command. To lint all files in ./server: pylint ./server Note that this requires the __init__.py file to exist in the target directory.
Just pass the directory name to the pylint command. To lint all files in ./server: pylint ./server Note that this requires the __init__.py file to exist in the target directory.
From the Pylint FAQ: With Pylint < 0.25, add # pylint: disable-all at the beginning of the module. Pylint 0.26.1 and up have renamed that directive to # pylint: skip-file (but the first version will be kept for backward compatibility). In order to ease finding which modules are ignored a information-level message I0013 is emitted. … Read more
Check your Python formatting provider. “python.formatting.provider”: “autopep8” I guess in your case it is not Pylint which keeps wrapping the long lines, but autopep8. Try setting –max-line-length for autopep8 instead. “python.formatting.autopep8Args”: [ “–max-line-length=200” ]
A little more detail on what gurney alex noted: you can tell Pylint to make exceptions for variable names which (you pinky swear) are perfectly clear even though less than three characters. Find in or add to your pylintrc file, under the [FORMAT] header: # Good variable names which should always be accepted, separated by … Read more
The error basically says that classes aren’t meant to just store data, as you’re basically treating the class as a dictionary. Classes should have at least a few methods to operate on the data that they hold. If your class looks like this: class MyClass(object): def __init__(self, foo, bar): self.foo = foo self.bar = bar … Read more
Do not disable or weaken Pylint functionality by adding ignores or generated-members. Use an actively developed Pylint plugin that understands Django. This Pylint plugin for Django works quite well: pip install pylint-django and when running pylint add the following flag to the command: –load-plugins pylint_django Detailed blog post here.
It is nice for a Python module to have a docstring, explaining what the module does, what it provides, examples of how to use the classes. This is different from the comments that you often see at the beginning of a file giving the copyright and license information, which IMO should not go in the … Read more
You may put it in: /etc/pylintrc for default global configuration ~/.pylintrc for default user configuration <your project>/pylintrc for default project configuration (used when you’ll run pylint <your project>) wherever you want, then use pylint –rcfile=<wherever I want> Also notice when generating the rc file, you may add option on the command line before the –generate-rcfile, … Read more
If using Visual Studio Code with Don Jayamanne’s excellent Python extension, add a user setting to whitelist NumPy: { // Whitelist NumPy to remove lint errors “python.linting.pylintArgs”: [ “–extension-pkg-whitelist=numpy” ] }
Let’s look at an example: def f(value, key, hash={}): hash[value] = key return hash print(f(‘a’, 1)) print(f(‘b’, 2)) Which you probably expect to output: {‘a’: 1} {‘b’: 2} But actually outputs: {‘a’: 1} {‘a’: 1, ‘b’: 2}