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

Pylint says 'string' module is deprecated. What's the new way to get range of lowercase characters?

I was just pylinting some code and noticed a colleague had imported the old Python 'string' module, not to use any functions from it but simply to have access to the constant 'string.lowercase'. I removed the deprecated import and substituted…
mikemaccana
  • 110,530
  • 99
  • 389
  • 494
21
votes
1 answer

Disable specific Pylance linting messages in VS Code settings.json like with "python.linting.pylintArgs"

When Pylance was introduced, I filed a question on how to generally customize Pylance linting. Here, one can find a few ways to customize Pylance, but there is nothing about how to suppress, mute or actually disable certain warnings and errors. As a…
Andreas L.
  • 3,239
  • 5
  • 26
  • 65
21
votes
6 answers

How to enable Pylint in VSCode?

I can't get pylint errors to show up in VSCode. I installed pylint globally (sudo apt install pylint), I created venv and installed it there with pip, I selected pylint as linter in VSCode, enabled it, ran it, and it doesnt show any errors in my…
atlau
  • 881
  • 1
  • 7
  • 16
21
votes
4 answers

How to change the .pylintrc file that VS Code is using for linting?

We have a .pylintrc file committed to git in our project root that is used by our team which has many useful errors disabled. So VS Code doesn't show those. I want to know if I can use my own pylint rules only on my local machine without having to…
Garry Mccarthy
  • 311
  • 1
  • 2
  • 5
21
votes
5 answers

Pylint badge in gitlab

Gitlab has functionality to generade badges about build status and coverage percentage. Is it possible to create custom badge to display Pylint results? Or just display this results in README.md? I already have CI job for Pylint
Djent
  • 2,877
  • 10
  • 41
  • 66
21
votes
2 answers

Suppress warning for both pycharm and pylint

I use PyCharm to write code and I also have CI server configured to run PyLint on every PR. The problem is PyCharm and PyLint use different comments for warning suppression: # noinspection PyMethodMayBeStatic # pylint: disable=no-self-use I don't…
Zelta
  • 754
  • 5
  • 14
20
votes
1 answer

pylint protection against self-assignment

I have this test file: """module docstring""" class Aclass: """class docstring""" def __init__(self, attr=None, attr2=None): self.attr = attr self.attr2 = attr2 def __repr__(self): return 'instance_of the…
Brown Bear
  • 19,655
  • 10
  • 58
  • 76
20
votes
4 answers

How to set a pylint score threshold?

I'd like to extract my pylint rating and set a threshold. Let me explain, for example, if the score is under 5, I want exit 1; And if my code is rated higher than 5, I want exit 0 and continue my Jenkins procedure.
Axel Bayle
  • 205
  • 1
  • 2
  • 8
20
votes
3 answers

Pylint W0223: Method ... is abstract in class ... but is not overridden

Pylint generates this error for subclasses of an abstract class, even when those subclasses are not themselves instantiated and the methods are overridden in the concrete subclasses. Why does Pylint think my abstract subclasses are intended to be…
AdamC
  • 457
  • 1
  • 4
  • 14
20
votes
8 answers

How to disable pylint 'Undefined variable' error for a specific variable in a file?

I am hosting IronPython inside a C# application and injecting an API for the host into the global scope. I have just started to love syntastic for vim with pylint for checking my scripts. But I am getting annoyed by all the [E0602, method_name]…
Daren Thomas
  • 67,947
  • 40
  • 154
  • 200
20
votes
4 answers

Pylint: Relative import should be

I'm checking a module with Pylint. The project has this structure: /builder __init__.py entity.py product.py Within product I import entity like this: from entity import Entity but Pylint laments that: ************* Module…
pistacchio
  • 56,889
  • 107
  • 278
  • 420
19
votes
2 answers

pylint and pre-commit hook unable to import

My project structure looks like this: project/ app/ main.py venv/ .pylintrc .pre-commit-config.yaml When I am trying to edit project/app/main.py and it fails with Unable to import 'psycopg2' (import-error) But when I am trying to…
palkan
  • 321
  • 2
  • 5
19
votes
2 answers

Python: unused argument needed for compatibility. How to avoid Pylint complaining about it

For my code in Python, I would like to call many functions with a specific argument. However, for some functions, that argument does not do anything. Still, I would like to add the argument for compatibility reasons. For example, consider the…
EdG
  • 328
  • 1
  • 2
  • 8
19
votes
2 answers

"pylint (import error)" while import a module in the same folder with VSCode

I'm building my code in VSCode using python 3.7.3. The folder structure: project ├── main.py └── modules ├── __init__.py ├── foo.py └── boo.py In foo.py: import boo boo.printBoo() When I run foo.py it works. I can get the result I…
19
votes
5 answers

Pylint false positive for Flask's "app.logger": E1101: Method 'logger' has no 'debug' member (no-member)

Using flask's app.logger member functions (such as app.logger.error) causes pylint to report E1101 (no-member) errors, even though these members of app.logger are defined at runtime. This can be reproduced by using the following files: app.py import…
Odysseas
  • 995
  • 9
  • 21