Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uses deprecated pylint.__pkginfo__.numversion #23

Closed
kevinoid opened this issue Apr 25, 2021 · 4 comments
Closed

Uses deprecated pylint.__pkginfo__.numversion #23

kevinoid opened this issue Apr 25, 2021 · 4 comments

Comments

@kevinoid
Copy link

pylint-quotes does not work with pylint 2.8.0 due to the removal of numversion from __pkginfo__ in pylint-dev/pylint@fbcb27a. To demonstrate:

pip3 install pylint==2.8.0 pylint-quotes
pylint --load-plugins pylint_quotes example.py 

Produces

Traceback (most recent call last):
  File "/path/to/venv/bin/pylint", line 8, in <module>
    sys.exit(run_pylint())
  File "/path/to/venv/lib/python3.9/site-packages/pylint/__init__.py", line 24, in run_pylint
    PylintRun(sys.argv[1:])
  File "/path/to/venv/lib/python3.9/site-packages/pylint/lint/run.py", line 279, in __init__
    linter.load_plugin_modules(self._plugins)
  File "/path/to/venv/lib/python3.9/site-packages/pylint/lint/pylinter.py", line 503, in load_plugin_modules
    module = astroid.modutils.load_module_from_name(modname)
  File "/path/to/venv/lib/python3.9/site-packages/astroid/modutils.py", line 212, in load_module_from_name
    return importlib.import_module(dotted_name)
  File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/path/to/venv/lib/python3.9/site-packages/pylint_quotes/__init__.py", line 4, in <module>
    from pylint_quotes import plugin, checker  # noqa: F401
  File "/path/to/venv/lib/python3.9/site-packages/pylint_quotes/plugin.py", line 5, in <module>
    from pylint_quotes.checker import StringQuoteChecker
  File "/path/to/venv/lib/python3.9/site-packages/pylint_quotes/checker.py", line 7, in <module>
    from pylint.__pkginfo__ import numversion as pylint_version
ImportError: cannot import name 'numversion' from 'pylint.__pkginfo__' (/path/to/venv/lib/python3.9/site-packages/pylint/__pkginfo__.py)

This change also broke pylama, as reported in pylint-dev/pylint#4399, and was partially reverted by pylint-dev/pylint#4400 for pylint 2.8.1 with plans to remove it permanently in 3.0.

What's New in Pylint 2.8 recommends using:

from importlib import metadata
metadata.metadata('pylint')

Thanks,
Kevin

@edaniszewski
Copy link
Owner

Thanks for filing the issue, and sorry for the delay in response and in addressing it. With the latest 0.2.2 release, I believe this should be fixed. Cllosing this out -- if the issue remains, feel free to reopen this issue or a new one.

@kevinoid
Copy link
Author

No worries. Thanks for looking at it @edaniszewski!

Unfortunately, I don't believe this issue is fixed. #25, which claims to fix it, appears to only change a pylint_version check in StringQuoteChecker.get_offset, which is not related to this issue. pylint_quotes/checker.py still imports numversion from __pkginfo__ which is deprecated and is slated for removal in pylint 3.0:

from pylint.__pkginfo__ import numversion as pylint_version

@edaniszewski
Copy link
Owner

okay, I think I got it right this time around in e9f5583 (:

will cut a new release for that. closing this issue again, but will reopen if I've messed things up again

@kevinoid
Copy link
Author

Works for me. Thanks @edaniszewski!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants