File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,15 @@ class ResourceLoader(Loader):
7070
7171 """
7272
73+ def __init__ (self ):
74+ import warnings
75+ warnings .warn ("importlib.abc.ResourceLoader is deprecated in "
76+ "favour of supporting resource loading through "
77+ "importlib.resources.abc.ResourceReader." ,
78+ DeprecationWarning , stacklevel = 2 )
79+ super ().__init__ ()
80+
81+
7382 @abc .abstractmethod
7483 def get_data (self , path ):
7584 """Abstract method which when implemented should return the bytes for
Original file line number Diff line number Diff line change @@ -933,5 +933,13 @@ def path_stats(self, path):
933933 loader .path_mtime ('foo.py' )
934934
935935
936+ class ResourceLoaderDeprecationWarningsTests (unittest .TestCase ):
937+ """Tests ResourceLoader deprecation warnings."""
938+
939+ def test_deprecated_resource_loader (self ):
940+ with self .assertWarns (DeprecationWarning ):
941+ from importlib .abc import ResourceLoader
942+
943+
936944if __name__ == '__main__' :
937945 unittest .main ()
You can’t perform that action at this time.
0 commit comments