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

gh-93963: Officially deprecate abcs and warn about their usage. #93965

Merged
merged 5 commits into from
Jul 3, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions Lib/importlib/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,29 @@
import abc
import warnings

# for compatibility with Python 3.10
from .resources.abc import ResourceReader, Traversable, TraversableResources
from .resources import abc as _resources_abc


__all__ = [
'Loader', 'Finder', 'MetaPathFinder', 'PathEntryFinder',
'ResourceLoader', 'InspectLoader', 'ExecutionLoader',
'FileLoader', 'SourceLoader',

# for compatibility with Python 3.10
'ResourceReader', 'Traversable', 'TraversableResources',
warsaw marked this conversation as resolved.
Show resolved Hide resolved
]


def __getattr__(name, canonical=_resources_abc):
"""
For backwards compatibility, continue to make names
from canonical available through this module. #93963
"""
if name in canonical.__all__:
obj = getattr(canonical, name)
warnings._deprecated(__name__, remove=(3, 14))
jaraco marked this conversation as resolved.
Show resolved Hide resolved
globals()[name] = obj
return obj
raise AttributeError(f'module {__name__!r} has no attribute {name!r}')
warsaw marked this conversation as resolved.
Show resolved Hide resolved


def _register(abstract_cls, *classes):
for cls in classes:
abstract_cls.register(cls)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Officially deprecate from ``importlib.abc`` classes moved to
``importlib.resources.abc``.