You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Officially deprecate and remove abcs in importlib.abc moved to importlib.resources. #93963
In #90276, I grouped the functionality related to importlib.resources into its own package (creating clearer separation of responsibility from importlib.*). That included moving some abstract base classes from importlib.abc to importlib.resources.abc. We need to officially deprecate the presence in importlib.abc and then remove them in a future release.
@encukou Here's the deprecation that officially announces the intention added in #90276. I know you were working on the doc updates. Let me know if I can help with that, especially with regard to this direction.
changed the title [-]Officially deprecate abcs in importlib.abc moved to importlib.resources.[/-][+]Officially deprecate and remove abcs in importlib.abc moved to importlib.resources.[/+]on Jul 3, 2022
It's ResourceReader being passed to make_abc_subclasses that tries to retrieve abc.ResourceReader triggering a DeprecationWarning. Below is an approach where default refers to abc module and ResourceReaderDefaultsTests overrides it with resources.
diff --git a/Lib/test/test_importlib/test_abc.py b/Lib/test/test_importlib/test_abc.py
index d59b663a43..66c8bf09cf 100644
--- a/Lib/test/test_importlib/test_abc.py+++ b/Lib/test/test_importlib/test_abc.py@@ -13,6 +13,7 @@
init = test_util.import_importlib('importlib')
abc = test_util.import_importlib('importlib.abc')
machinery = test_util.import_importlib('importlib.machinery')
+resources = test_util.import_importlib('importlib.resources')
util = test_util.import_importlib('importlib.util')
@@ -125,7 +126,7 @@ class SourceLoader(InheritanceTests):
##### Default return values ####################################################
-def make_abc_subclasses(base_class, name=None, inst=False, **kwargs):+def make_abc_subclasses(base_class, name=None, inst=False, abc=abc, **kwargs):
if name is None:
name = base_class.__name__
base = {kind: getattr(splitabc, name)
@@ -324,7 +325,7 @@ def contents(self, *args, **kwargs):
class ResourceReaderDefaultsTests(ABCTestHarness):
- SPLIT = make_abc_subclasses(ResourceReader)+ SPLIT = make_abc_subclasses(ResourceReader, abc=resources)
def test_open_resource(self):
with self.assertRaises(FileNotFoundError):
The documentation for importlib.resources.abc.Traversable says: "Deprecated since version 3.12, will be removed in version 3.14: Use importlib.resources.abc.Traversable instead."
The documentation for importlib.resources.abc.TraversableResources says: "Deprecated since version 3.12, will be removed in version 3.14: Use importlib.resources.abc.TraversableResources instead."
Why does it recommend to use the same deprecated class?
Activity
jaraco commentedon Jun 17, 2022
@encukou Here's the deprecation that officially announces the intention added in #90276. I know you were working on the doc updates. Let me know if I can help with that, especially with regard to this direction.
Use 'warnings._deprecated'. Fixes #93963 until Python π.
[-]Officially deprecate abcs in importlib.abc moved to importlib.resources.[/-][+]Officially deprecate and remove abcs in importlib.abc moved to importlib.resources.[/+]gh-93963: Remove deprecated names from importlib.abc
gh-93963: Remove deprecated names from importlib.abc
gh-93963: Officially deprecate abcs and warn about their usage. (GH-9…
pythongh-93963: Document importlib.abc deprecations
Merge branch 'main' into gh-93963/remove-importlib-resources-abcs
jaraco commentedon Jul 24, 2022
Today I observed that one of the tests is still accessing
ResourceReaderfromimportlib.abc.1 remaining item
gh-93963: Document importlib.abc deprecations (#94546)
Merge remote-tracking branch 'upstream/main' into gh-93963/importlib-…
gh-93963: Remove usage of deprecated interface from importlib.abc. (#…
Merge branch 'main' into gh-93963/remove-importlib-resources-abcs
tirkarthi commentedon Jul 31, 2022
It's
ResourceReaderbeing passed tomake_abc_subclassesthat tries to retrieveabc.ResourceReadertriggering aDeprecationWarning. Below is an approach where default refers toabcmodule andResourceReaderDefaultsTestsoverrides it withresources.jaraco commentedon Sep 5, 2022
Oh, I'd missed test_abc. I think I'd like to just remove that test... or if it needs to exist, it should exist in
importlib_resourcesalso.jaraco commentedon Sep 5, 2022
I see now in ccf94a6, Irit suppressed the DeprecationWarnings.
gh-93963: Remove ResourceReaderDefaultsTests (GH-96598)
[3.11] pythongh-93963: Remove ResourceReaderDefaultsTests (pythonGH-9…
serhiy-storchaka commentedon Jul 27, 2023
I am confused.
The documentation for
importlib.resources.abc.Traversablesays: "Deprecated since version 3.12, will be removed in version 3.14: Useimportlib.resources.abc.Traversableinstead."The documentation for
importlib.resources.abc.TraversableResourcessays: "Deprecated since version 3.12, will be removed in version 3.14: Useimportlib.resources.abc.TraversableResourcesinstead."Why does it recommend to use the same deprecated class?
serhiy-storchaka commentedon Jul 27, 2023
Opened new issue #107352 for this.
hugovk commentedon May 29, 2024
Removal PR: #119720
gh-93963: Remove deprecated names from importlib.abc (#119720)
pythongh-93963: Remove deprecated names from importlib.abc (python#11…
pythongh-93963: Remove deprecated names from importlib.abc (python#11…