Questions tagged [pylint]

Pylint is a Python source code analyzer looking for bugs and signs of poor quality.

Pylint is a Python tool that checks if a module satisfies a coding standard.

1358 questions
399
votes
2 answers

Pylint, PyChecker or PyFlakes?

I would like to get some feedback on these tools on: features; adaptability; ease of use and learning curve.
e-satis
  • 515,820
  • 103
  • 283
  • 322
307
votes
13 answers

How do I disable a Pylint warning?

I'm trying to disable warning C0321 ("more than one statement on a single line" -- I often put if statements with short single-line results on the same line), in Pylint 0.21.1 (if it matters: astng 0.20.1, common 0.50.3, and Python 2.6.6…
Head Geek
  • 33,955
  • 20
  • 72
  • 83
237
votes
27 answers

PyLint "Unable to import" error - how to set PYTHONPATH?

I'm running PyLint from inside Wing IDE on Windows. I have a sub-directory (package) in my project and inside the package I import a module from the top level, ie. __init__.py myapp.py one.py subdir\ __init__.py two.py Inside two.py I have…
EMP
  • 51,372
  • 47
  • 157
  • 214
226
votes
4 answers

Why is the use of len(SEQUENCE) in condition values considered incorrect by Pylint?

Considering this code snippet: from os import walk files = [] for (dirpath, _, filenames) in walk(mydir): # More code that modifies files if len(files) == 0: # <-- C1801 return None I was alarmed by Pylint with this message regarding the…
SE_net4 the downvoter
  • 21,043
  • 11
  • 69
  • 107
211
votes
5 answers

Is it possible to ignore one single specific line with Pylint?

I have the following line in my header: import config.logging_settings This actually changes my Python logging settings, but Pylint thinks it is an unused import. I do not want to remove unused-import warnings in general, so is it possible to just…
The Unfun Cat
  • 23,164
  • 22
  • 90
  • 133
209
votes
3 answers

PyLint message: logging-format-interpolation

For the following code: logger.debug('message: {}'.format('test')) pylint produces the following warning: logging-format-interpolation (W1202): Use % formatting in logging functions and pass the % parameters as arguments Used when a logging…
pfnuesel
  • 10,855
  • 11
  • 51
  • 63
183
votes
23 answers

How do I get Pylint to recognize NumPy members?

I am running Pylint on a Python project. Pylint makes many complaints about being unable to find NumPy members. How can I avoid this while avoiding skipping membership checks? From the code: import numpy as np print np.zeros([1, 4]) Which, when…
Alphadelta14
  • 2,512
  • 3
  • 13
  • 16
175
votes
37 answers

Pylint "unresolved import" error in Visual Studio Code

I am using the following setup macOS v10.14 (Mojave) Python 3.7.1 Visual Studio Code 1.30 Pylint 2.2.2 Django 2.1.4 I want to use linting to make my life a bit easier in Visual Studio Code. However, for every import I have states "unresolved…
jAC
  • 2,202
  • 3
  • 14
  • 20
173
votes
6 answers

Instance attribute attribute_name defined outside __init__

I split up my class constructor by letting it call multiple functions, like this: class Wizard: def __init__(self, argv): self.parse_arguments(argv) self.wave_wand() # declaration omitted def parse_arguments(self, argv): …
Steven Liao
  • 3,117
  • 3
  • 15
  • 25
146
votes
2 answers

How do I create a pylintrc file

I am running linux. Can I do something like pylint --generate-rcfile > .pylintrc and then make changes to the resulting .pylintrc file to override the default settings? And if so should it be in my ~/ directory or should I put it in .pylint.d?
user3330833
  • 1,669
  • 2
  • 9
  • 9
146
votes
12 answers

Using Pylint with Django

I would very much like to integrate pylint into the build process for my python projects, but I have run into one show-stopper: One of the error types that I find extremely useful--:E1101: *%s %r has no %r member*--constantly reports errors when…
rcreswick
  • 15,505
  • 15
  • 56
  • 69
137
votes
2 answers

Why is the empty dictionary a dangerous default value in Python?

I put a dict as the default value for an optional argument to a Python function, and pylint (using Sublime package) told me it was dangerous. Can someone explain why this is the case? And is a better alternative to use None instead?
tscizzle
  • 7,911
  • 12
  • 48
  • 75
123
votes
4 answers

What does Pylint's "Too few public methods" message mean?

I'm running Pylint on some code, and receiving the error "Too few public methods (0/2)". What does this message mean? The Pylint documentation is not helpful: Used when a class has too few public methods, so be sure it's really worth it.
monsur
  • 39,509
  • 15
  • 93
  • 91
112
votes
11 answers

How do I disable "missing docstring" warnings at a file-level in Pylint?

Pylint throws errors that some of the files are missing docstrings. I try and add docstrings to each class, method and function, but it seems that Pylint also checks that files should have a docstring at the beginning of them. Can I disable this…
Mridang Agarwalla
  • 38,521
  • 65
  • 199
  • 353
105
votes
5 answers

Why does Pylint object to single-character variable names?

I'm still getting used to Python conventions and using Pylint to make my code more Pythonic, but I'm puzzled by the fact that Pylint doesn't like single character variable names. I have a few loops like this: for x in x_values: …
Amanda
  • 9,419
  • 16
  • 54
  • 84
1
2 3
90 91