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

False positive deprecated-class when the class is imported in a guarded import block #9533

Open
perrinjerome opened this issue Apr 3, 2024 · 0 comments
Labels
Enhancement ✨ Improvement to a component Help wanted 🙏 Outside help would be appreciated, good for new contributors Needs PR This issue is accepted, sufficiently specified and now needs an implementation

Comments

@perrinjerome
Copy link
Contributor

Current problem

import sys

if sys.version_info > (2, ):
    from collections.abc import Set
else:
    from collections import Set

isinstance(set(), Set)
$ pylint --disable=C a.py
************* Module a
a.py:6:4: W4904: Using deprecated class Set of module collections (deprecated-class)

-----------------------------------
Your code has been rated at 8.00/10

Desired solution

In #4702 pylint was extended with a concept of "guarded import blocks" and it does not trigger import-error and similar errosr when the import is made in a guarded import block.

I believe it would be nice to have same behavior for deprecated-class as well.

Additional context

No response

@perrinjerome perrinjerome added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Apr 3, 2024
@DanielNoord DanielNoord added Enhancement ✨ Improvement to a component Help wanted 🙏 Outside help would be appreciated, good for new contributors Needs PR This issue is accepted, sufficiently specified and now needs an implementation and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component Help wanted 🙏 Outside help would be appreciated, good for new contributors Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Projects
None yet
Development

No branches or pull requests

2 participants