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
12
votes
9 answers

Jenkins with pylint gives build failure

I added a build step to execute a Python script. In this script pylint is called with the lint.Run(..args) to check the code. The script works but in the end, the build fails with the only error message: Build step 'Execute Python script' marked…
Gobliins
  • 3,848
  • 16
  • 67
  • 122
12
votes
1 answer

Unnecessary pass in defining exceptions

Often I will write a generic exception such as the following: class MyException(Exception): "My custom exception." pass This way I can check if that exception is the one I want in something like a try/except block. Yet pylint complains…
samuelbrody1249
  • 4,379
  • 1
  • 15
  • 58
12
votes
5 answers

VS Code / Pylance / Pylint Cannot resolve import

The Summary I have a python import that works when run from the VS Code terminal, but that VS Code's editor is giving warnings about. Also, "Go to Definition" doesn't work. The Problem I have created a docker container from the image…
xdhmoore
  • 8,935
  • 11
  • 47
  • 90
12
votes
1 answer

Cyclic Imports to fix R0401 from pylint

Pylint complains about cyclic import with R0401 error code for a specific file of the NLTK package, e.g. nltk/nltk/ccg/lexicon.py:1: [R0401(cyclic-import), ] Cyclic import (nltk -> nltk.internals) nltk/nltk/ccg/lexicon.py:1: [R0401(cyclic-import),…
alvas
  • 115,346
  • 109
  • 446
  • 738
12
votes
1 answer

Unintentional trailing comma that creates a tuple

In Python, leaving a trailing comma like this is, of course, not a SyntaxError: In [1]: x = 1 , In [2]: x Out[2]: (1,) In [3]: type(x) Out[3]: tuple But, at the same time, if the trailing comma was put accidentally, it may be difficult to catch…
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
12
votes
2 answers

What is the point of calling super in custom error classes in python?

So I have a simple custom error class in Python that I created based on the Python 2.7 documentation: class InvalidTeamError(Exception): def __init__(self, message='This user belongs to a different team'): self.message = message This…
12
votes
3 answers

Quieting pylint false-positives when using django

I'd like to sanely quiet a few pylint errors when using Django. The two that are causing the greatest irritation are when deriving from django.db.models.Model and accessing objects, and django.test.TestCase. In the first, pylint complains about…
JivanAmara
  • 1,065
  • 2
  • 10
  • 20
12
votes
1 answer

Phabricator linter can't find any lintable paths

How can I configure phabricator to lint only files that match *py? The following is my .arclint file: { "linters": { "pylint": { "type": "pylint", "include": "(\\.py$)" } } } which is based heavily on the examples found…
Brendan W
  • 3,303
  • 3
  • 18
  • 37
12
votes
3 answers

why does Python lint want me to use different local variable name, than a global, for the same purpose

Given Python code such as def func(): for i in range(10): pass for i in range(10): pass pylint complains Redefining name 'i' from outer scope What is the Pythonic way to write the above? Use a different variable locally, say…
Mark Galeck
  • 6,155
  • 1
  • 28
  • 55
11
votes
5 answers

How to get pylint warnings to be marked in the Pydev Eclipse editor margin?

I have pylint installed (works fine on the command line) and set up within Pydev in Eclipse. Pylint is being triggered OK when I edit files, and is outputting to the Eclipse console. But, the pylint warnings don't appear as marks in the editor…
DNA
  • 42,007
  • 12
  • 107
  • 146
11
votes
2 answers

Pylint with pre-commit and EsLlint with husky

I have a project with a frontend in JS and backend in Python. Frontend had been configured with husky pre-commit hook. Today I've configured Pylint with pre-commit library but husky hooks had been overwritten by that move. Is it possible to combine…
Aleksandr Zakharov
  • 334
  • 1
  • 4
  • 16
11
votes
1 answer

What is pylint "Too many local variables" trying to tell me and what do I do with that?

I'm working on a python function that reads in Excel or CSV files with various measuring data and spits out a dict, containing strings with the metadata and a pandas dataframe with the data. def reader(file): """ blablaba """ #500 lines of…
JC_CL
  • 2,346
  • 6
  • 23
  • 36
11
votes
1 answer

Pylint complains about wxPython - 'Too many public methods'

For the following simple wxPython snippets: import sys import wx class MyApp(wx.App): def OnInit(self): self.frame = wx.Frame(None, title="Simple wxPython App") self.frame.Show() self.SetTopWindow(self.frame) …
Drake Guan
  • 14,514
  • 15
  • 67
  • 94
11
votes
1 answer

pylint R1720: Unnecessary "elif" after "raise" (no-else-raise)

I have the following code if self.download_format == 'mp3': raise NotImplementedError elif self.download_format == 'wav': with NamedTemporaryFile(suffix='.wav') as wavfile: self.download_wav_recording(call,…
Ryabchenko Alexander
  • 10,057
  • 7
  • 56
  • 88
11
votes
2 answers

What is the real benefit of obeying R1705 in pylint? Is the code really safer?

With pylint, I know that R1705 warning gets triggered when you put a 'return' inside an 'else'. This is the warning: R1705: Unnecessary "else" after "return" (no-else-return) This is what the docs says about it: Unnecessary “else” after “return”…
Alex M.M.
  • 501
  • 1
  • 7
  • 18