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
17
votes
1 answer

R1732: Consider using 'with' for resource-allocating operations (consider-using-with)

I am running pylint for bug detection in my project and stumble on this warning. How can I fix this warning?
Thinh Le
  • 603
  • 1
  • 7
  • 14
17
votes
5 answers

pylint no member issue but code still works vscode

I have a very simple code here import torch l = torch.nn.Linear(2,5) v = torch.FloatTensor([1, 2]) print(l(v)) under torch.FloatTensor, pylint in visual studio code claims that 'Module torch has no 'FloatTensor' member pylint(no-member). However,…
Evan Kim
  • 769
  • 2
  • 8
  • 26
17
votes
2 answers

Using Python linters with Docker in VS Code

I'm trying to make Python linters to work in VS Code when Python and all packages are installed in a Docker container. I didn't use linters before. But as far as I understand how linters work (at least in VS Code), I need to point VS Code to Python…
Den Kasyanov
  • 870
  • 2
  • 11
  • 27
17
votes
1 answer

Disable pylint warning E1101 when using enums

I recently came across this article by Anthony Fox which shows how to use enums to create the choice set in django CharFields, which I thought was pretty neat. Basically, you create a subclass of Enum: from enum import Enum class ChoiceEnum(Enum): …
cmasri
  • 461
  • 1
  • 5
  • 12
17
votes
4 answers

How to indicate multiple unused values in Python?

Normally in Python, one should use an _ to indicate an argument is unused. def example_basic(unused): pass becomes def example_basic(_): pass Then if there are multiple unused arguments, multiple _s can't be used since they will conflict,…
TinyTheBrontosaurus
  • 4,010
  • 6
  • 21
  • 34
17
votes
3 answers

-bash: pylint: command not found

I have been trying to install pylint to be used on terminal, but have been unsuccessful in using it. The installation gets successful, but whenever I try to run pylint command, it returns the following error - -bash: pylint: command not found I…
0xC0DED00D
  • 19,522
  • 20
  • 117
  • 184
17
votes
2 answers

vscode pylint on all project files without opening them

I'm looking for a solution to run pylint in vscode on all files of my project without need to open them (like checkstyle in eclipse on Java). Thank you.
MilacH
  • 280
  • 2
  • 12
17
votes
1 answer

Running pylint against only changed lines/files with jenkins

At this time, I am using the violations plugin with Jenkins to generate a report of PEP8 violations. Since I am only beginning to use this check, there are an insane number of violations. So I'd like to start with only checking what changed in a…
nbb
  • 295
  • 3
  • 10
17
votes
3 answers

Disable invalid name arguments pylint

I have code like this: def func(df): return df.column[0] I am running pylint and it gives me this message all the time because it flags df as an invalid name despite it's convention. C:210, 9: Invalid variable name "df" (invalid-name) Where…
Chris
  • 12,900
  • 12
  • 43
  • 65
17
votes
2 answers

Pylint message: Invalid constant name (invalid-name)

Pylint complains about Invalid constant name "myprint" (invalid-name) in the case of a shorthand for a logger function. # import from utils import get_logger LOGFILE = '6_evaluator.log' myprint = get_logger(LOGFILE) def main(): # some stuff …
user3313834
  • 7,327
  • 12
  • 56
  • 99
17
votes
3 answers

Pylint - Pylint unable to import flask.ext.wtf?

I've got my Pylint install importing flask just fine. And with that same installation of flask, I have wtforms running just fine in my application. However, when I run Pylint on a file importing wtforms: from flask.ext import wtf from flask.ext.wtf…
golmschenk
  • 11,736
  • 20
  • 78
  • 137
16
votes
3 answers

Why pylint returns `unsubscriptable-object` for numpy.ndarray.shape?

I just put together the following "minimum" repro case (minimum in quotes because I wanted to ensure pylint threw no other errors, warnings, hints, or suggestions - meaning there's a bit of boilerplate): pylint_error.py: """ Docstring """ import…
stevendesu
  • 15,753
  • 22
  • 105
  • 182
16
votes
3 answers

How to make pylint, flake8 or pycodestyle to automatically correct errors?

I have properly installed all of the aforementioned modules on a VM I use on Ubuntu 18.04. When running either of them on a specific script or folder, they do correctly identify style errors and output them in the console. E.g.: (venv) .../src$…
Jan
  • 264
  • 1
  • 5
  • 14
16
votes
2 answers

Why does pylint require capitalized variable names when outside a function?

Why does pylint accept capitalized variables when outside a function and reject them inside a function? Conversely, why does pylint reject camelCase ouside a function and accept it inside a function? I just installed pylint (version 2.2.2) to check…
dputhier
  • 734
  • 1
  • 7
  • 23
16
votes
1 answer

How do you tell pylint what the members of a protobuf-generated object are?

I would like to release a python package for a set of protobuf messages. The protobuf compiler (protoc) generates a python library that does not actually define types/classes the typical sense, but rather dynamically constructs them. Is there any…
Arun Chaganty
  • 341
  • 3
  • 13