Coder Social home page Coder Social logo

pylint-plugin-utils's People

Contributors

aerostitch avatar atodorov avatar carl-tstpd avatar carlio avatar dependabot[bot] avatar dineshtrivedi avatar federicobond avatar jakirkham avatar michael-k avatar moylop260 avatar pre-commit-ci[bot] avatar shepilov-vladislav avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pylint-plugin-utils's Issues

Pylint 2.6.1 causes AttributeError: module 'pylint.checkers.utils' has no attribute 'is_call_of_name'

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.

ImportError: cannot import name 'UnknownMessageError'

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

Exception with python3 proir to python3.3 (e.g. python3.2 used in Debian Wheezy, Ubuntu 12.04 LTS, ...)

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__'

Move this repo as well to PyCQA?

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

Does not work with python3

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__))
....

Do not pollute site-packages

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"

test_linter_should_be_pickable fails

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

Failure with pylint-2.15.0: pylint_plugin_utils.NoSuchChecker: <class 'pylint.checkers.typecheck.TypeChecker'>

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

  • pylint-2.15.0
  • pylint-django-2.5.3
  • pylint-plugin-utils-0.7

Previous PASSING execution in my CI, https://github.com/kiwitcms/trackers-integration/runs/7983170188?check_suite_focus=true, was with

  • pylint-2.14.5
  • pylint-django-2.5.3
  • pylint-plugin-utils-0.7

@carlio I'm not sure if I will be able to take a look at this over the weekend. I will try.

Release package on PyPI automatically when a Git tag is pushed

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:

  • You don't need to install and configure software locally to trigger releases
  • You don't accidentally release from the wrong branch (:hankey: happens!)
  • Everyone who has permissions to push a tag on the repository directly can effortlessly trigger a release
  • Releases, since they are tagged commits, automatically show up in the "releases" tab of the GitHub repo

Pylint 2.3 causes AttributeError: 'MessagesStore' object has no attribute 'get_message_definition'

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'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.