Skip to content

find_pylintrc removed in 3.0 #9105

New issue

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

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

Already on GitHub? # to your account

Closed
Alexander-Serov opened this issue Oct 3, 2023 · 9 comments
Closed

find_pylintrc removed in 3.0 #9105

Alexander-Serov opened this issue Oct 3, 2023 · 9 comments
Labels
Duplicate 🐫 Duplicate of an already existing issue

Comments

@Alexander-Serov
Copy link

Bug description

Pre-commit hook with pylint that has been working previously is not failing with the new pylint version released:


pylint...................................................................Failed
- hook id: pylint
- exit code: 1
Traceback (most recent call last):
  File "/builds/project/venv/bin/pylint", line 8, in <module>
    sys.exit(run_pylint())
  File "/builds/buynomics/project/venv/lib/python3.8/site-packages/pylint/__init__.py", line 34, in run_pylint
    PylintRun(argv or sys.argv[1:])
  File "/builds/project/venv/lib/python3.8/site-packages/pylint/lint/run.py", line 162, in __init__
    args = _config_initialization(
  File "/builds/project/venv/lib/python3.8/site-packages/pylint/config/config_initialization.py", line 57, in _config_initialization
    exec(utils._unquote(config_data["init-hook"]))  # pylint: disable=exec-used
  File "<string>", line 1, in <module>
ImportError: cannot import name 'find_pylintrc' from 'pylint.config' (/builds/project/venv/lib/python3.8/site-packages/pylint/config/__init__.py)
Traceback (most recent call last):
  File "/builds/project/venv/bin/pylint", line 8, in <module>
    sys.exit(run_pylint())
  File "/builds/project/venv/lib/python3.8/site-packages/pylint/__init__.py", line 34, in run_pylint
    PylintRun(argv or sys.argv[1:])
  File "/builds/project/venv/lib/python3.8/site-packages/pylint/lint/run.py", line 162, in __init__
    args = _config_initialization(
  File "/builds/project/venv/lib/python3.8/site-packages/pylint/config/config_initialization.py", line 57, in _config_initialization
    exec(utils._unquote(config_data["init-hook"]))  # pylint: disable=exec-used
  File "<string>", line 1, in <module>
ImportError: cannot import name 'find_pylintrc' from 'pylint.config' (/builds/project/venv/lib/python3.8/site-packages/pylint/config/__init__.py)

Downgrading to pylint==2.17 solves the problem.



### Configuration

```ini
The configuration has not changed from the previous version. My pre-commit configuration:


  - repo: local
    hooks:
      - id: pylint
        name: pylint
        entry: pylint
        language: system
        types: [python]
        args: [--errors-only]


### Command used

```shell
pre-commit run pylint

Pylint output

Not starting, see above

Expected behavior

Same behavior as in 2.17

Pylint version

pylint 3.0.0
astroid 3.0.0
python 3.8

OS / Environment

Linux / Macos

Additional dependencies

No response

@Alexander-Serov Alexander-Serov added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Oct 3, 2023
@Alexander-Serov
Copy link
Author

@Pierre-Sassoulas Do you think it could be related to your recent 3.0.0 release?

@jacobtylerwalls jacobtylerwalls self-assigned this Oct 3, 2023
@jacobtylerwalls
Copy link
Member

Hi @Alexander-Serov 👋

The release notes are a bit long, but it's in there 😉 :

Following a deprecation period, pylint.config.PYLINTRC was removed.
Use the pylint.config.find_default_config_files generator instead.

Duplicate of #8862

@jacobtylerwalls jacobtylerwalls closed this as not planned Won't fix, can't repro, duplicate, stale Oct 3, 2023
@jacobtylerwalls jacobtylerwalls added Duplicate 🐫 Duplicate of an already existing issue and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Oct 3, 2023
@Alexander-Serov
Copy link
Author

Hi @Alexander-Serov 👋

The release notes are a bit long, but it's in there 😉 :

Following a deprecation period, pylint.config.PYLINTRC was removed.
Use the pylint.config.find_default_config_files generator instead.

Duplicate of #8862

Thanks for identifying it fast. So just to be sure I understood the discussion in the other thread correctly: the .pylintrc has been deprecated and one should migrate the config to pyproject.toml instead, right?

@jacobtylerwalls
Copy link
Member

jacobtylerwalls commented Oct 3, 2023

I'm sympathetic to the fact this this is a little hard to parse out of the release notes. I guess in your case the specific news fragment is this one:

All code related to the optparse config parsing has been removed.
Refs #8405

But even more visible than the release note would have been the deprecation notice.

@jacobtylerwalls
Copy link
Member

jacobtylerwalls commented Oct 3, 2023

Thanks for identifying it fast. So just to be sure I understood the discussion in the other thread correctly: the .pylintrc has been deprecated and one should migrate the config to pyproject.toml instead, right?

Ah, no! rc files are still fine. You can provide an exact path or rely on the discovery in the order given here.

Hope that helps.

@jacobtylerwalls jacobtylerwalls changed the title Pylint installation fails after the recent release find_pylintrc removed in 3.0 Oct 3, 2023
@Alexander-Serov
Copy link
Author

Thanks, @jacobtylerwalls, it does.

@jacobtylerwalls
Copy link
Member

cc/ @DanielNoord for future, it's occurring to me now that pre-commit hooks probably swallow deprecation warnings. Not sure what to make of that, just hadn't thought of that before.

@DanielNoord
Copy link
Collaborator

Yeah, makes sense. The amount of plugin related issues also seems to confirm this..

Good call on changing the name, let's hope people find these issues before opening new ones.

@genzgd
Copy link

genzgd commented Mar 8, 2024

This is a byproduct of the approach for setting the sys/PYTHONPATH recommended here: https://stackoverflow.com/questions/1899436/pylint-unable-to-import-error-how-to-set-pythonpath. A "best practices" approach for this problem should probably be highly visible somewhere here in this Github repo.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Duplicate 🐫 Duplicate of an already existing issue
Projects
None yet
Development

No branches or pull requests

4 participants