pylint-dev / pylint-plugin-utils Goto Github PK
View Code? Open in Web Editor NEWUtilities and helpers for writing Pylint plugins
License: GNU General Public License v2.0
Utilities and helpers for writing Pylint plugins
License: GNU General Public License v2.0
It appears that the recently released Pylint 2.6.1 may have broken compatibility with this package.
$ pylint
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.9.1/x64/lib/python3.9/multiprocessing/pool.py", line 125, in worker
result = (True, func(*args, **kwds))
File "/home/runner/work/python-airslate/python-airslate/.venv/lib/python3.9/site-packages/pylint/lint/check_parallel.py", line 69, in _worker_check_single_file
_worker_linter.check_single_file(name, filepath, modname)
File "/home/runner/work/python-airslate/python-airslate/.venv/lib/python3.9/site-packages/pylint/lint/pylinter.py", line 881, in check_single_file
self._check_file(
File "/home/runner/work/python-airslate/python-airslate/.venv/lib/python3.9/site-packages/pylint/lint/pylinter.py", line 922, in _check_file
check_astroid_module(ast_node)
File "/home/runner/work/python-airslate/python-airslate/.venv/lib/python3.9/site-packages/pylint/lint/pylinter.py", line 1054, in check_astroid_module
retval = self._check_astroid_module(
File "/home/runner/work/python-airslate/python-airslate/.venv/lib/python3.9/site-packages/pylint/lint/pylinter.py", line 1099, in _check_astroid_module
walker.walk(ast_node)
File "/home/runner/work/python-airslate/python-airslate/.venv/lib/python3.9/site-packages/pylint/utils/ast_walker.py", line 75, in walk
self.walk(child)
File "/home/runner/work/python-airslate/python-airslate/.venv/lib/python3.9/site-packages/pylint/utils/ast_walker.py", line 75, in walk
self.walk(child)
File "/home/runner/work/python-airslate/python-airslate/.venv/lib/python3.9/site-packages/pylint/utils/ast_walker.py", line 75, in walk
self.walk(child)
[Previous line repeated 2 more times]
File "/home/runner/work/python-airslate/python-airslate/.venv/lib/python3.9/site-packages/pylint/utils/ast_walker.py", line 72, in walk
callback(astroid)
File "/home/runner/work/python-airslate/python-airslate/.venv/lib/python3.9/site-packages/pylint/checkers/refactoring/len_checker.py", line 61, in visit_call
if not utils.is_call_of_name(node, "len"):
AttributeError: module 'pylint.checkers.utils' has no attribute 'is_call_of_name'
"""
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/runner/work/python-airslate/python-airslate/.venv/bin/pylint", line 8, in <module>
sys.exit(run_pylint())
File "/home/runner/work/python-airslate/python-airslate/.venv/lib/python3.9/site-packages/pylint/__init__.py", line 22, in run_pylint
PylintRun(sys.argv[1:])
File "/home/runner/work/python-airslate/python-airslate/.venv/lib/python3.9/site-packages/pylint/lint/run.py", line 349, in __init__
linter.check(args)
File "/home/runner/work/python-airslate/python-airslate/.venv/lib/python3.9/site-packages/pylint/lint/pylinter.py", line 866, in check
check_parallel(
File "/home/runner/work/python-airslate/python-airslate/.venv/lib/python3.9/site-packages/pylint/lint/check_parallel.py", line 102, in check_parallel
for (
File "/opt/hostedtoolcache/Python/3.9.1/x64/lib/python3.9/multiprocessing/pool.py", line 870, in next
raise value
AttributeError: module 'pylint.checkers.utils' has no attribute 'is_call_of_name'
make: *** [Makefile:139: lint] Error
Error: Process completed with exit code 2.
According to pylint-dev/pylint-django#276 we need to change the code so the PyLinter remains pickleable after the usage of augment_visit
and suppress_message
Hello, seems the new pylint-2.4.0
release is not compatible with the latest version of pylint-plugin-utils
.
I started seeing the following error:
File "xxx/.pyenv/versions/3.6.9/lib/python3.6/site-packages/pylint_django/__init__.py", line 6, in <module>
from pylint_django import plugin
File "xxx/.pyenv/versions/3.6.9/lib/python3.6/site-packages/pylint_django/plugin.py", line 3, in <module>
from pylint_plugin_utils import get_checker
File "xxx/.pyenv/versions/3.6.9/lib/python3.6/site-packages/pylint_plugin_utils/__init__.py", line 5, in <module>
from pylint.utils import UnknownMessageError as UnknownMessage
ImportError: cannot import name 'UnknownMessageError'
It happened after pylint.utils
was split into a package (so, no longer contains a reference to UnknownMessageError
exception):
The diff between 2.3.1 and 2.4.0 - https://github.com/PyCQA/pylint/compare/4612b66..fce8bff
Prior to python3.3 function objects do not have a __qualname__
attribute. This let's augment_visit
crash with an AttributeError
. You can reproduce this with pylint-django:
$ python3.2 /usr/local/bin/pylint --load-plugins pylint_django
Traceback (most recent call last):
File "/usr/local/lib/python3.2/dist-packages/pylint_plugin_utils/__init__.py", line 45, in augment_visit
checker = get_checker(linter, checker_method.__self__.__class__)
AttributeError: 'function' object has no attribute '__self__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/pylint", line 9, in <module>
load_entry_point('pylint==1.3.1', 'console_scripts', 'pylint')()
File "/usr/local/lib/python3.2/dist-packages/pylint/__init__.py", line 21, in run_pylint
Run(sys.argv[1:])
File "/usr/local/lib/python3.2/dist-packages/pylint/lint.py", line 917, in __init__
linter.load_plugin_modules(self._plugins)
File "/usr/local/lib/python3.2/dist-packages/pylint/lint.py", line 361, in load_plugin_modules
module.register(self)
File "/usr/local/lib/python3.2/dist-packages/pylint_django/common.py", line 29, in register
apply_augmentations(linter)
File "/usr/local/lib/python3.2/dist-packages/pylint_django/augmentations/__init__.py", line 96, in apply_augmentations
augment_visit(linter, TypeChecker.visit_getattr, foreign_key_sets)
File "/usr/local/lib/python3.2/dist-packages/pylint_plugin_utils/__init__.py", line 47, in augment_visit
checker = get_checker(linter, get_class(checker_method.__module__, checker_method.__qualname__))
AttributeError: 'function' object has no attribute '__qualname__'
Hi,
With the move of pylint-django to PyCQA, would it make sense to move this one as well there or are you still maintaining it?
Thanks
Joseph
Hi,
Python3 does not have the im_class attribute.
I've implemented a (backwards compatible) fix to make it work with python3. I tried it with the pylint_django plugin.
---- init.py ---
... def get_class(module_name, kls): parts = kls.split('.') m = __import__(module_name) for mp in module_name.split('.')[1:]: m = getattr(m, mp) klass = getattr(m, parts[0]) return klass def augment_visit(linter, checker_method, augmentation): ... try: checker = get_checker(linter, checker_method.im_class) except AttributeError: try: checker = get_checker(linter, checker_method.__self__.__class__) except AttributeError: checker = get_checker(linter, get_class(checker_method.__module__, checker_method.__qualname__)) ....
Currently, LICENSE
and README.md
get installed into site-packages directory. This is bad, for obvious reasons.
I used this patch to fix the problem:
--- pyproject.toml.orig 2023-05-19 20:37:05.000000000 +0000
+++ pyproject.toml
@@ -24,11 +24,6 @@ keywords=["pylint","plugin","helpers"]
packages = [
{include = "pylint_plugin_utils/"}
]
-include = [
- "LICENSE",
- "*.rst",
- "*.md"
-]
[tool.poetry.dependencies]
python = ">=3.7,<4.0"
We are seeing the following test failure on 0.7 with python 3.9.12 and pylint 2.13.5.
_______________________ test_linter_should_be_pickleable _______________________
linter = Checker 'master' (responsible for 'F0001', 'F0002', 'F0010', 'F0011', 'I0001', 'I0010', 'I0011', 'I0013', 'I0020', 'I0021', 'I0022', 'E0001', 'E0011', 'E0012', 'E0013', 'E0014')
def test_linter_should_be_pickleable(linter):
# Setup
linter.register_checker(TypeChecker())
augment_visit(linter, TypeChecker.visit_attribute, fake_augmentation_func)
suppress_message(
linter, TypeChecker.visit_attribute, "no-member", fake_suppress_func
)
# Act and Assert
> pickle.dumps(linter)
E TypeError: cannot pickle 'EncodedFile' object
tests/test_linter_pickle.py:25: TypeError
PYTHONPATH=.:"../Kiwi/" pylint \
--load-plugins=pylint.extensions.no_self_use \
--load-plugins=pylint_django --django-settings-module=test_project.settings \
--load-plugins=kiwi_lint -d similar-string \
-d missing-docstring -d duplicate-code -d module-in-directory-without-init \
--ignore migrations \
*.py tcms_settings_dir/ trackers_integration/ test_project/
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/pylint_plugin_utils/__init__.py", line 44, in augment_visit
checker = get_checker(linter, checker_method.__self__.__class__)
AttributeError: 'function' object has no attribute '__self__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.8.13/x64/bin/pylint", line 8, in <module>
sys.exit(run_pylint())
File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/pylint/__init__.py", line 35, in run_pylint
PylintRun(argv or sys.argv[1:])
File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/pylint/lint/run.py", line 151, in __init__
linter.load_plugin_modules(self._plugins)
File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 371, in load_plugin_modules
module.register(self)
File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/pylint_django/plugin.py", line 44, in register
apply_augmentations(linter)
File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/pylint_django/augmentations/__init__.py", line 840, in apply_augmentations
augment_visit(linter, TypeChecker.visit_attribute, foreign_key_sets)
File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/pylint_plugin_utils/__init__.py", line 46, in augment_visit
checker = get_checker(
File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/pylint_plugin_utils/__init__.py", line 28, in get_checker
raise NoSuchChecker(checker_class)
pylint_plugin_utils.NoSuchChecker: <class 'pylint.checkers.typecheck.TypeChecker'>
make: *** [Makefile:13: pylint] Error 1
https://github.com/kiwitcms/trackers-integration/runs/8037795176?check_suite_focus=true
Previous PASSING execution in my CI, https://github.com/kiwitcms/trackers-integration/runs/7983170188?check_suite_focus=true, was with
@carlio I'm not sure if I will be able to take a look at this over the weekend. I will try.
To remove the burden on the maintainer(s) I'd suggest to make it easier to release a new package version on PyPI. Pushing a Git tag to the repository may trigger an automatic release.
That can be achieved by adding a deploy:
section to the Travis CI configuration, the same way the Pylint project has done it:
deploy:
distributions: sdist bdist_wheel
provider: pypi
user: <maintainer-pypi-username-here>
password:
secure: <maintainer-pypi-password-here>
on:
tags: true
This approach has several advantages:
It appears that the recently released Pylint 2.3 may have broken compatibility with this package.
$ pylint
Traceback (most recent call last):
File "/Users/craiga/.ve/env_mgmt_dashboard/bin/pylint", line 10, in <module>
sys.exit(run_pylint())
File "/Users/craiga/.ve/env_mgmt_dashboard/lib/python3.7/site-packages/pylint/__init__.py", line 20, in run_pylint
Run(sys.argv[1:])
File "/Users/craiga/.ve/env_mgmt_dashboard/lib/python3.7/site-packages/pylint/lint.py", line 1583, in __init__
linter.load_plugin_modules(plugins)
File "/Users/craiga/.ve/env_mgmt_dashboard/lib/python3.7/site-packages/pylint/lint.py", line 637, in load_plugin_modules
module.register(self)
File "/Users/craiga/.ve/env_mgmt_dashboard/lib/python3.7/site-packages/pylint_django/plugin.py", line 30, in register
apply_augmentations(linter)
File "/Users/craiga/.ve/env_mgmt_dashboard/lib/python3.7/site-packages/pylint_django/augmentations/__init__.py", line 763, in apply_augmentations
suppress_message(linter, TypeChecker.visit_attribute, 'no-member', is_model_field_display_method)
File "/Users/craiga/.ve/env_mgmt_dashboard/lib/python3.7/site-packages/pylint_plugin_utils/__init__.py", line 125, in suppress_message
get_message_definition = msgs_store.get_message_definition
AttributeError: 'MessagesStore' object has no attribute 'get_message_definition'
I was wondering if we could link this project to https://results.pre-commit.ci/ in the same way that the pylint project is linked to it.
Check https://results.pre-commit.ci/run/github/47671127/1640674316.F3GsGXIYQOy9K58ggpBsvA
The CI badge is pointing to pylint projects instead of pylint-plugin-utils.
There are small typos in the readme
We have two ci files so we can delete one
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.