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

Add _collections_abc methods to DEPRECATED_METHODS #4388

Closed
jiajunsu opened this issue Apr 22, 2021 · 2 comments · Fixed by #4419
Closed

Add _collections_abc methods to DEPRECATED_METHODS #4388

jiajunsu opened this issue Apr 22, 2021 · 2 comments · Fixed by #4419
Labels
Enhancement ✨ Improvement to a component

Comments

@jiajunsu
Copy link
Contributor

Is your feature request related to a problem? Please describe

According to Python documentation of module collections[1], methods in _collections_abc will be moved from collections to collections.abc. And now Pylint hasn't checked it.

Describe the solution you'd like

I suggest to add methods in _collections_abc.__all__ to DEPRECATED_METHODS[3] of Pylint.

Additional context

Test code is

from collections import Iterable


print(isinstance(None, Iterable))

pylint 2.7.4
astroid 2.5.3
Python 3.7.2

[1]https://docs.python.org/3/library/collections.html
[2]https://github.com/python/cpython/blob/3.9/Lib/_collections_abc.py#L18
[3]https://github.com/PyCQA/pylint/blob/af52033971eccecea47597ebbfaeac15773b3e1b/pylint/checkers/stdlib.py#L85

@gousaiyang
Copy link

I guess adding them to DEPRECATED_METHODS will not be sufficient as a "method" is only detected when called as a function. So that code like isinstance(obj, collections.Iterable) will not be detected. Probably we will need a new type of message like deprecated-class or deprecated-member.

@jiajunsu
Copy link
Contributor Author

I guess adding them to DEPRECATED_METHODS will not be sufficient as a "method" is only detected when called as a function. So that code like isinstance(obj, collections.Iterable) will not be detected. Probably we will need a new type of message like deprecated-class or deprecated-member.

Yeah, just "method" is not sufficient.

Test cases would be

from collections import Iterable  # [deprecated-module]

import collections


collections.Iterable  # [deprecated-method]

Pierre-Sassoulas pushed a commit that referenced this issue Apr 30, 2021
* Add new warning ``deprecated-class``, fix pre-commit ci pipeline.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants