Questions tagged [pylint]
Pylint is a Python source code analyzer looking for bugs and signs of poor quality.
1,718
questions
-1
votes
0
answers
19
views
What is the option of Python linter (ex. flake8, Pylint) to forbid implicit booleaness in if statement when type is Optional?
I would like to know Python linter and its options to warn about Type guard by if statement like the following for values of type Optional[int] and Optional[str].
Do you know of a linter and its ...
0
votes
0
answers
16
views
Pylint detecting entry point script as module
I have a package which contains a module and an entry-point script with the same name. I'd like to run pylint on all of the files (the entry-point script has more code in it than it should) however ...
0
votes
0
answers
30
views
Unable to import 'cocotb' pyLint
I am running cocotb from ubuntu terminal but I am getting some errors, which I am not able to track.
therefore, i want to use the code in VS code to check my errors,
However, I am getting this errors ...
0
votes
0
answers
32
views
Pylint issue in Python 3.11
I am getting import error when running lint
I am using pylint version 3.0.2 and python version 3.11
Getting the below error
from pylint.interfaces import IAstroidChecker, ITokenChecker
ImportError: ...
0
votes
0
answers
11
views
Pylint throws E1120 error in dependency injection
I've implemented a custom decorator which injects arguments to a function when necessary. Code works as expected, but pylint throws a E1120 error because it expects the injected instance as an ...
0
votes
1
answer
30
views
Pylint Report Generation [closed]
How can you get pylint to print a report? My response only tells the errors and the score.
This is my response,
************* Module main
PycharmProjects\turtle_race\main.py:1:0: C0114: Missing ...
-1
votes
1
answer
37
views
Can you disable Pylint inline messages in Visual Studio Code?
Is there a way to disable inline Pylint (v2023.10.1) messages in Visual Studio Code (version 1.84.2 on Windows 11)? For example, I'm referring to "Formatting a regular string which could be an f-...
0
votes
1
answer
77
views
Python linter does not work in VSCode since update causing settings deprecation
I am having an issue with pylint in VSCode (and any python linter actually). Some update caused the settings I had in settings.json to deprecate and now linting won't work in my environment while it ...
1
vote
1
answer
18
views
How do I do a type ignore on a multi-line piece of code in python?
I've recently started using pylint to catch errors and bad styling in my code. I've found that there are some things I need to get pylint to ignore as it complains when it shouldn't. I know that # ...
0
votes
0
answers
21
views
Pylint not visible in VisualStudioCode extensions, even if installed in ActiveState "Python 3.8.18" project
I use VisualStudioCode v1.84.2 with ActiveState Python 3.8.18 interpreter. The ActiveState package incudes Pylint.
However Pylint is not visible in the VisualStudioCode extensions.
How can I proceed?
...
0
votes
0
answers
15
views
vscode pylint extension -rcfile arg must be set to an absolute path?
I've been trying to set a different .pylintrc file per project, as I work with 10s of repositories, each might have different settings.
Since pylint is not an extension, this seems impossible.
When I'...
0
votes
0
answers
69
views
pydantic and pylint conflict E1137
I am using pydantic in my code along with pylint for code validation. The following code appears to be valid to me, but pylint is displaying an E1137 error message. Can you help me identify what might ...
2
votes
1
answer
124
views
Pylint extension disables Pylance extension in VS Code
I have been using Pylance for auto suggestions and completions.
Recently i added Pylint to help me lint my code but the moment i installed Pylint my Pylance stopped working (its not giving any auto ...
-3
votes
0
answers
30
views
pylint --py3k flagged the following code snippet as an error: Parameter unpacking specified (parameter-unpacking) [duplicate]
for tPA in sorted(PAtimelist, key=lambda (k,v): (v[0],v[1],k)):
How can I rewrite this code so it's compatible with Python 3.x?
I haven't tried anything to fix it.
0
votes
2
answers
80
views
PyLint Django: django.core.exceptions.ImproperlyConfigured: Requested setting LOGGING_CONFIG, but settings are not configured
My Django app works fine when I am just launching my application through python src/manage.py runserver But I would like to integrate pylint here, and when i launch the command pylint src --load-...
0
votes
1
answer
75
views
Github workflow pylint: How do I disable all docstring errors warnings? [closed]
I've setup the pylint workflow on GitHub.
The is the path:
myRepo/.github/workflows/pylint.yml
I added a pylintrc file in the workflows directory with the following options:
[MESSAGES CONTROL]
...
0
votes
1
answer
23
views
How to resolve incompatible type Optional type conflict?
Hi anyone know how to resolve this error in py3? Getting error message like:
"int" has incompatible type "Union[float, int, str, None]"; expected
"Union[str, bytes, ...
1
vote
2
answers
39
views
Import order in python for specific packages
I ran pylint on my codebase and it complained that from config import ConfigParser was defined before from pathlib import Path Why is this the case?
When I ran isort of the file, it agreed with pylint....
0
votes
2
answers
267
views
Visual Studio Code - missing "Select Linter"
I just installed the latest version (1.83.1) of VSC on Ubuntu. I plan to develop in Python, and am just getting started using Linters.
I have installed the VSC extensions for Python, including the ...
0
votes
1
answer
100
views
Pylint recursive bug when directory is prefix of another directory
I am observing weird behavior for pylint when I have a directory name being a prefix of another directory. Here is minimal setup to reproduce:
mkdir pylint_test
cd pylint_test
mkdir dataset
touch ...
0
votes
0
answers
20
views
Auto run QA tools over jupyter notebook when saving
I want to run some tools like isort, black, pylint, pydocstyle etc. when I press ctrl+s on my jupyter notebook
I already have this independently as a terminal command using the nbqa library and will ...
0
votes
0
answers
38
views
pylint_django "Instance of 'ForeignKey' has no ... member"
I'm working on a project in python with django and recently I decided to modify the way the models were stored in one of the apps. With the help of django documentation, I deleted the models.py file ...
2
votes
1
answer
49
views
Is there a lint rule for python that automatically detects list +operator concatenation and suggests using spread
For me the following
extras = ["extra0", "extra1"]
func_with_list_arg([
"base0",
"base1",
] + extras)
is nicer to read with a spread operator like the ...
1
vote
0
answers
94
views
pre commit raises pylint errors on push but not when executing
So i have this pre-commit file:
repos:
- hooks:
- args:
- -rn
- -sn
- --rcfile=.pylintrc
entry: poetry run pylint
id: pylint
language: system
stages:
- pre-commit
...
0
votes
0
answers
68
views
How to run lint only on the files in PR
I am running pylint in GitHub but it is running on all the files in repo for every PR as I am using pylint $(git ls-files '*.py'). How can I run it only for the files present in the pull request? ...
2
votes
2
answers
44
views
ignore path in pylint config raises regex error
I have the pylint config:
[MAIN]
load-plugins=pylint_django
django-settings-module=kernel.settings
ignore-paths=^kernel/**$ , ^migrations/*$
But whenever i want to run i get this error for kernel ...
0
votes
1
answer
30
views
How to resolve E0611: No name 'Test_HC' in module 'test' (no-name-in-module)?
Context
I have a pip package called something with tree structure:
src/something/__main__.py
src/something/__init__.py
src/something/hardcoded.py
src/something/bike/ride.py
test/__init__.py
test/bike/...
0
votes
0
answers
24
views
pylint.lint Run sometimes writing and closing json file, and sometimes not
Trying to write a basic script to generate pylint scores on a repository, record the pylint messages to a json file, and then subsequently read the json file for some post-processing.
This basic ...
1
vote
0
answers
125
views
Pydantic dataclass with Field alias triggers pylint E1123 unexpected-keyword-arg
I'm using the dataclasses feature in Pydantic v2.3.0 and I have a dataclass with an aliased field, like so:
from pydantic import Field
from pydantic.dataclasses import dataclass
@dataclass
class ...
0
votes
0
answers
36
views
pylint plugin config in Code Climate configuration for GitlabCI code_quality job
If someone already used some custom Code Climate configuration for GitlabCI code_quality job, Especially implementing pylint scanner.
I would be grateful if you could share how you work around the ...
3
votes
1
answer
107
views
Pylint is not suggesting the walrus operator. Why?
I was going to ask if there is a pylint-style code analyzer capable of suggesting the use of the := operator in places were it might improve the code. However, it looks like such test has been added ...
0
votes
0
answers
30
views
Command run 'pylint' on github action does not recognize Django setup
I have been trying to refactor my pylint workflow to comply with results of my local machine. After some wrestling, I am unable to make it understand the Django structure and apply environment ...
1
vote
1
answer
58
views
Marking unused parameters in functions passed as arguments
I have a higher order function:
def mymap(f,...):
...
x = f(a, logger)
...
and I need to pass to it f that needs only one argument:
def bigfun(...):
...
def f(a, logger):
...
1
vote
1
answer
33
views
How to fix wrong pylint warning in JupyterLab about CRLF line ending (or how to fix line ending if the warning should be true)?
I use pylint for JupyterLab via jupyterlab-lsp on Windows and get warnings about the line ending format:
There is 'CRLF' while it should be 'LF'
I opened the notebook file in a text editor ensured ...
0
votes
0
answers
142
views
Pylint and flake8: quality score
I was wondering if it was possible to get a code quality score using flake8 like pylint do by default. I cannot find the flake8 configuration for it, if it exists.
I want to be able to compare my file ...
0
votes
1
answer
133
views
Pylint import errors on Bitbucket pipeline
I am trying to setup a Bitbucket pipeline for my python project, but getting errors that do not appear on my local machine.
E0401: Unable to import 'PyQt5.QtWidgets' (import-error)
E0611: No name '...
0
votes
1
answer
64
views
Creating a dataclass that generates an instance of another class as a default attribute. How can I satisfy this Pylint warning?
Consider this python script
from dataclasses import dataclass, field
class ClassA:
def __init__(self):
pass
@dataclass
class ClassB:
class_a: ClassA = field(default_factory=lambda: ...
2
votes
1
answer
233
views
pylint: unable to import 'requests' using nvim with pylsp and pylint enabled
I'm having a weird problem with pylint complaining about an import problem:
pylint: [import-error] Unable to import 'requests' [E0401]
This makes no sense since requests is a standard library. Also, ...
4
votes
0
answers
297
views
pydantic v2.0.0 with pylint no-member warning
Questuion
in pydantic doc,pydantic ^2.0.0 not support like this a:Optional[str],but rather support a:Optional[str] = Field(default=None)
however,pylint check my code raise warning[E1101(no-member), ...
0
votes
0
answers
45
views
Pylint complains about imports
When I try to import Protocol from the typing module, I get the error "unable to import typing (import-error)" It's error 0401. E.g. I have a file test_import with the single line
from ...
0
votes
0
answers
32
views
Alternatives to pylint-protobuf
I use pylint with the plugin pylint-protobuf to typecheck the proto code. However, pylint does not support protobuf >= 3.20. (Source) Going back to an older version of protobuf is not an option.
...
1
vote
1
answer
73
views
How to resolve -W0104: Statement seems to have no effect (pointless-statement)
I am trying to test the error from __getitem__() function and getting the Pylint findings against it.
def test_check_error():
with pytest.raises(Exception) as error_i:
obj["output&...
2
votes
3
answers
125
views
How to get the list of errors from pylint?
I have a Python script called my_code.py. I am using:
import pylint
pylint.run_pylint(argv=["my_code.py"])
How to get all errors and store them in a list in the above snippet?
-1
votes
1
answer
37
views
Create new variable inside of pylintrc file
I'm coming from a world where we program mostly in C++ and our minimal Python code often uses a mix of Pythonic methods and C++ best practices.
As such I'd like to create some custom regexes for ...
0
votes
1
answer
38
views
Pylint fails due to UnicodeError
I'm using Pylint to check my code when I do commits. Recently, I've had a commit fail because of the following error:
UnicodeEncodeError: 'charmap' codec can't encode characters in position 1699-1713:...
1
vote
1
answer
89
views
Locally importing files in a python package
In the file __main__.py, I am trying to import the function print_logo() from the module print.py.
I have noticed that the function print_logo() is actually being used from the package wpdetect ...
1
vote
0
answers
1k
views
How to install python3.11 and update Pylint on Amazon Cloud9 IDE?
How to install python3.11 on Amazon Cloud9 IDE? and make the IDE's Pylint module recognize Python's new feature/keywords, such as "match"?
Is there any simpler solutions?
I have found a ...
1
vote
1
answer
20k
views
how to configure pylint for E0611: No name 'xxxx' in module 'xxx' (no-name-in-module)?
├── src
├──── events
├────── foo_bar
├──────── pop_bou
├────────── app.py
def handler() -> Optional[dict]:
return None
and my pytest file is:
def test_foo():
from events.foo_bar.pop_bou....
0
votes
0
answers
200
views
In VS Code, see dependencies from virtual environment using python and poetry Pylint(E0401:import-error)
For my project I use poetry to install all python 3.10 dependencies. It works.
$ poetry env list
## .venv (Activated)
But in VS Code, Pylint do not recognise any installed library via poetry and the ...
0
votes
0
answers
27
views
How do I resolve the "no-name-in-module" error in Pylint when using Parler's TranslatedFields?
I have the following class in models.py:
class Family(models.Model):
code = models.CharField(max_length=50, unique=True)
translations = TranslatedFields(name=models.CharField(max_length=255))
...