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.

1691 questions
406
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.
Bite code
  • 578,959
  • 113
  • 301
  • 329
402
votes
14 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
  • 38,128
  • 22
  • 77
  • 87
321
votes
8 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
  • 14,093
  • 14
  • 58
  • 71
319
votes
34 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
  • 59,148
  • 53
  • 164
  • 220
301
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
  • 29,987
  • 31
  • 114
  • 156
240
votes
40 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
  • 3,155
  • 3
  • 18
  • 29
239
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…
E_net4
  • 27,810
  • 13
  • 101
  • 139
231
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
  • 11,191
  • 15
  • 54
  • 88
217
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,577
  • 3
  • 19
  • 25
196
votes
3 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
  • 2,179
  • 2
  • 12
  • 9
191
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,854
  • 3
  • 16
  • 19
184
votes
14 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
  • 43,201
  • 71
  • 221
  • 382
161
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
  • 45,581
  • 16
  • 101
  • 95
151
votes
13 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
  • 16,483
  • 15
  • 59
  • 70
145
votes
7 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
  • 12,099
  • 17
  • 63
  • 91
1
2 3
99 100