pylint

How do I tell pylint about a descriptor providing access to iterables, subscriptables?

How do I tell pylint about a descriptor providing access to iterables, subscriptables? Question: I have a decorator that I can use to mark a read-only class property: class class_ro_property(property): def __init__(self, getter:Callable): self._getter = getter def __get__(self, _, cls): return self._getter(cls) class MyClass: @class_ro_property def my_property(cls): return [1, 2, 3] The problem is that …

Total answers: 2

Pylint: warn of redundant `pylint: disable` comments?

Pylint: warn of redundant `pylint: disable` comments? Question: I created a class: class Blahaj: def swim(self): … # todo: consider other modes of transport Pylint warned there were too few public methods, which I acknowledged by adding a # pylint: disable=too-few-public-methods comment. Now I’ve added more methods, is there a way to get Pylint to …

Total answers: 2

SQL injection , use parameter

SQL injection , use parameter Question: i have this SQL default code is a string cr.execute( ”’SELECT product FROM product_product WHERE default_code = ‘%s’ limit 1”’ % (default_code,) ) and linter gets me an erro E8103: SQL injection risk. Use parameters if you can. same with other SQL cr.execute( f"SELECT id FROM product_supplierinfo" f" WHERE …

Total answers: 1

Pylint `–good-names` syntax on Linux

Pylint `–good-names` syntax on Linux Question: I’ve been using PyLint in Windows with such configuration: pylint –good-names (‘i’,’el’,’of’,’df’,’pd’,’Entity’) –bad-names (‘foo’,’bar’,’kek’,’KEK’) module but on Ubuntu, I get an exception while trying to parse good-names arguments (‘i’,’el’, …): /bin/bash: -c: line 6: syntax error near unexpected token `(‘ What is the correct way to provide such uncommon …

Total answers: 1

Visual Studio Code is not showing alert for undefined class methods

Visual Studio Code is not showing alert for undefined class methods Question: I am using vscode with Pylance and Pylint, and it does not show an alert for undefined class methods as Pycharm does. Example: Pycharm Visual Studio Code What I tried: Used a different linter (Flake 8) Made sure there are no settings that …

Total answers: 1

Pylint fail under does not fail my Github action job

Pylint fail under does not fail my Github action job Question: I am trying to implement a python linter using pylint. But i am getting the score of each python file and also displaying the suggestion to improve the score but I am also looking to terminate the GitHub action job if my pylint score …

Total answers: 3

Pylint R1732 ("Consider using 'with'") for one-liner: is it really good advice?

Pylint R1732 ("Consider using 'with'") for one-liner: is it really good advice? Question: On a line such as r = open(path, encoding="utf-8").read() (actual line here), Pylint 2.14.5 provides the following advise: submodules-dedup.py:71:32: R1732: Consider using ‘with’ for resource-allocating operations (consider-using-with) If I understand correctly, the suggestion is to change it to with open(path, encoding="utf-8") as …

Total answers: 2

Ignoring a line for pylint and Flake8 at the same time

How to suppress a warning in one line for pylint and Flake8 at the same time Question: I would like to ignore a specific line in static code analysis. For Flake8, I’d use the syntax # noqa: F401. For pylint, I’d use the syntax # pylint: disable=unused-import. As I am working on a code generation …

Total answers: 2

How to add custom pylint warning?

How to add custom pylint warning? Question: I want to add a warning message to my pylint for all print statements reminding myself I have them in case I print sensitive information. Is this possible? I can only find answers about disabling pylint errors, not enabling new ones. Asked By: bnykpp || Source Answers: I …

Total answers: 3