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

pylint error checking throws exeption due to deprecation warning #14

Open
RobFirth opened this issue Feb 1, 2023 · 2 comments · Fixed by #15
Open

pylint error checking throws exeption due to deprecation warning #14

RobFirth opened this issue Feb 1, 2023 · 2 comments · Fixed by #15
Labels
bug Something isn't working dependencies Pull requests that update a dependency file

Comments

@RobFirth
Copy link
Contributor

RobFirth commented Feb 1, 2023

Description

Running the check-pylint-import-errors hook throws deprecation error.

Details

The following error:

Check for pylint import errors............................................Failed
- hook id: check-pylint-import-errors
- exit code: 1

/Users/berto/PycharmProjects/autoredact/autoredact_develop/.venv/lib/python3.9/site-packages/hooks/check_pylint_import_errors.py:59: DeprecationWarning: 'epylint' will be removed in pylint 3.0, use https://github.com/emacsorphanage/pylint instead.
  pylint_stdout, pylint_err = lint.py_run(pylint_opts, return_std=True)
Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.9/3.9.13_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/Cellar/python@3.9/3.9.13_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/berto/PycharmProjects/autoredact/autoredact_develop/.venv/lib/python3.9/site-packages/hooks/check_pylint_import_errors.py", line 95, in <module>
    sys.exit(main())
  File "/Users/berto/PycharmProjects/autoredact/autoredact_develop/.venv/lib/python3.9/site-packages/hooks/check_pylint_import_errors.py", line 91, in main
    return CheckPylintImportErrors().run()
  File "/Users/berto/PycharmProjects/autoredact/autoredact_develop/.venv/lib/python3.9/site-packages/hooks/check_pylint_import_errors.py", line 63, in run
    raise Exception(pylint_err.getvalue())
Exception: <string>:1: DeprecationWarning: 'epylint' will be removed in pylint 3.0, use https://github.com/emacsorphanage/pylint instead.

Seems to be linked to v2.16 of pylint. https://pylint.pycqa.org/en/latest/whatsnew/2/2.16/index.html, with epylint migrated to https://github.com/emacsorphanage/pylint.

Why are we using the emacs version of pylint anyway?

ah ok, so it's because we can then capture the output:

https://pylint.pycqa.org/en/v2.13.9/user_guide/run.html#:~:text=To%20silently%20run%20Pylint%20on,C0114%27%2C%20return_std%3DTrue

@RobFirth
Copy link
Contributor Author

RobFirth commented Feb 1, 2023

Looks like we should migrate over to the new(er) API - https://pylint.pycqa.org/en/v2.16.0/development_guide/api/pylint.html

Expect this to look something like:

from io import StringIO

from pylint.lint import Run
from pylint.reporters.text import TextReporter

pylint_output = StringIO()  # Custom open stream
reporter = TextReporter(pylint_output)

Run(args=["autoredactdevelop", "--rcfile='pyproject.toml'", "--output-format=json"], reporter=reporter, exit=False)

print(pylint_output.getvalue())  # Retrieve and print the text report

@RobFirth RobFirth added bug Something isn't working dependencies Pull requests that update a dependency file labels Feb 1, 2023
@RobFirth RobFirth linked a pull request Feb 1, 2023 that will close this issue
@RobFirth
Copy link
Contributor Author

RobFirth commented Feb 2, 2023

I've opened an issue on the pylint repo - pylint-dev/pylint#8164

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant