Skip to content

False negative import-error when the package imported is one of pylint's dependency #10339

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

Open
Pierre-Sassoulas opened this issue Apr 11, 2025 · 1 comment
Labels
False Negative 🦋 No message is emitted but something is wrong with the code High effort 🏋 Difficult solution or problem to solve Needs design proposal 🔒 This is a huge feature, some discussion should happen before a PR is proposed

Comments

@Pierre-Sassoulas
Copy link
Member

Pierre-Sassoulas commented Apr 11, 2025

Bug description

When linting with pylint one must install pylint in its environment to be able to lint. So when pylint is providing a dependency that is not set in the project packaging, pylint does not raise import-error appropriately. For example for yaml:

import yaml

Then in an environment where pyyaml is not available this will fail.

Command used

pylint a.py

Pylint output

No error.

Expected behavior

E401: Unable to import yaml

Pylint version

A problem since forever, I guess.
@Pierre-Sassoulas Pierre-Sassoulas added False Negative 🦋 No message is emitted but something is wrong with the code High effort 🏋 Difficult solution or problem to solve Needs design proposal 🔒 This is a huge feature, some discussion should happen before a PR is proposed labels Apr 11, 2025
@pavan-msys
Copy link

Hi @Pierre-Sassoulas

Version:

pylint 4.0.0-dev0
astroid 4.0.0a0
Python 3.10.12 (main, Feb  4 2025, 14:57:36) [GCC 11.4.0]

OS:
Ubuntu 22.04

I tested this in my environment, and it's working as expected

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False Negative 🦋 No message is emitted but something is wrong with the code High effort 🏋 Difficult solution or problem to solve Needs design proposal 🔒 This is a huge feature, some discussion should happen before a PR is proposed
Projects
None yet
Development

No branches or pull requests

2 participants