Skip to content

Fix false negative for deprecated-module when a __import__ method is used instead of import sentence #10454

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

Conversation

moylop260
Copy link
Contributor

@moylop260 moylop260 commented Jul 11, 2025

Using the following python code style

__import__("deprecated_module")

The deprecated-module is ignored since that it expects

import deprecated_module

This change adds the posibility to process these kind of style too

This style is used from popular auto-code snippets:

Type of Changes

Type
🐛 Bug fix
X ✨ New feature
X 🔨 Refactoring
X 📜 Docs

Description

Closes #10453

@moylop260 moylop260 force-pushed the main-debug-statement-importpdb-moy branch 2 times, most recently from 5e00cc3 to a246d1a Compare July 11, 2025 02:49
@moylop260
Copy link
Contributor Author

@Pierre-Sassoulas What do you think?

Regards!

Copy link

codecov bot commented Jul 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.88%. Comparing base (e4f49e2) to head (b4dc60c).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #10454   +/-   ##
=======================================
  Coverage   95.88%   95.88%           
=======================================
  Files         176      176           
  Lines       19140    19142    +2     
=======================================
+ Hits        18352    18354    +2     
  Misses        788      788           
Files with missing lines Coverage Δ
pylint/checkers/deprecated.py 99.08% <100.00%> (+0.01%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@moylop260 moylop260 force-pushed the main-debug-statement-importpdb-moy branch 3 times, most recently from e994e91 to e336aa5 Compare July 11, 2025 03:15
@moylop260 moylop260 changed the title Fix false negative deprecated-module considering __import__("deprecated_module") style Fix false negative for deprecated-module when a __import__ method is used instead of import sentence Jul 11, 2025

This comment has been minimized.

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look great, this is going in 4.0 :)

@Pierre-Sassoulas Pierre-Sassoulas added the False Negative 🦋 No message is emitted but something is wrong with the code label Jul 11, 2025
@Pierre-Sassoulas Pierre-Sassoulas added this to the 4.0.0 milestone Jul 11, 2025
… is used instead of `import` sentence.

Using the following python code style

```python
__import__("deprecated_module")
```

The deprecated-module is ignored since that it expects

```python
import deprecated_module
```

This change adds the posibility to process these kind of style too

This style is used from popular auto-code snippets:
 - https://github.com/honza/vim-snippets/blob/f0a3184/snippets/python.snippets#L209

Fix pylint-dev#10453
@moylop260 moylop260 force-pushed the main-debug-statement-importpdb-moy branch from e336aa5 to b4dc60c Compare July 11, 2025 04:19
Copy link
Contributor

🤖 According to the primer, this change has no effect on the checked open source code. 🤖🎉

This comment was generated for commit b4dc60c

Copy link
Collaborator

@DanielNoord DanielNoord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@Pierre-Sassoulas Pierre-Sassoulas merged commit 8d4c687 into pylint-dev:main Jul 13, 2025
40 checks passed
@moylop260 moylop260 deleted the main-debug-statement-importpdb-moy branch July 13, 2025 16:38
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

False negative for deprecated-module when a __import__ method is used instead of import sentence.
3 participants