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

v2.17.0 regression related to W0407: preferred-modules #8453

Closed
ssbarnea opened this issue Mar 14, 2023 · 4 comments · Fixed by #8454, #8521 or #9093
Closed

v2.17.0 regression related to W0407: preferred-modules #8453

ssbarnea opened this issue Mar 14, 2023 · 4 comments · Fixed by #8454, #8521 or #9093
Labels
Bug 🪲 Needs PR This issue is accepted, sufficiently specified and now needs an implementation Regression
Milestone

Comments

@ssbarnea
Copy link
Contributor

ssbarnea commented Mar 14, 2023

Bug description

v2.17.0 release broke the W0407 rule by making the match trigger on partial string match.

# now failing due to 'py' being part of the imported name:
import copy
# some:
import pytest

This was working fine in v2.16.3 but now we need to disable preffered-modules for the moment.

Configuration

[tool.pylint.IMPORTS]
preferred-modules = ["py:pathlib", "unittest:pytest"]

Command used

-

Pylint output

W0407: Prefer importing 'pathlib' instead of 'py' (preferred-module)

Expected behavior

No error

Pylint version

$ pylint --version
pylint 2.17.0
astroid 2.15.0
Python 3.11.2 (main, Feb 16 2023, 11:46:09) [Clang 14.0.0 (clang-1400.0.29.202)]

OS / Environment

No response

Additional dependencies

No response

Related: #7957

@ssbarnea ssbarnea added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Mar 14, 2023
@ssbarnea ssbarnea changed the title v2.17.0 regression related to W0407 v2.17.0 regression related to W0407: preferred-modules Mar 14, 2023
@Pierre-Sassoulas Pierre-Sassoulas added Regression Needs PR This issue is accepted, sufficiently specified and now needs an implementation Bug 🪲 and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Mar 14, 2023
@DanielNoord
Copy link
Collaborator

@d33bs Would you have time to look into this? It feels like we shouldn't use in but rather ==.

@d33bs
Copy link
Contributor

d33bs commented Mar 15, 2023

Thanks @DanielNoord, taking a look into this and will open a PR for a fix!

@ssbarnea
Copy link
Contributor Author

I am afraid that the bug is not fixed, even in 3.0.0a6 because I tried to uncomment the rule skip on my project and still got those errors.

I am running pylint using pre-commit and version v3.0.0a6, so maybe we should reopen it.

@Pierre-Sassoulas
Copy link
Member

Would you mind providing a reproducer @ssbarnea, please ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 Needs PR This issue is accepted, sufficiently specified and now needs an implementation Regression
Projects
None yet
4 participants