Repository navigation
importlib.resources.abc.ResourceReader docs/implementation discrepancies #143513
Description
Activity
Thank you!
If fixes are desired
In the
importlib.resources.abc.ResourceReader.is_resourcecase, judging by this change in the typeshed, the parameter used to benameuntil 3.10 but the documentation must have not been updated accordingly (I didn't confirm with our log though :-)).
It may be desired to pass this parameter by keyword, so the name matters in terms of our API contract.
Therefore I'd say yes, fixing this in the docs is desired definitely!However, in the
contents()case: @jaraco, should we change the last sentence from the documentation or should the behavior be updated to reflect the documentation?I don't think we'll change
contents()anyway so I'd say go for the two fixes :-)Timeline for my reference
- 4ac5150 (Py 3.7) adds
importlib.abc.ResourceReader, withis_resource(name) - 6714825 (Py 3.10) resources in namespaces support, change to
is_resource(path) - e712a5b (Py 3.11) moves to
importlib.resources.abc.ResourceReader
importlib_resources.abc.ResourceReaderhas consistently usedis_resource(path)since that method was added in python/importlib_resources@e82b567- 4ac5150 (Py 3.7) adds
- added a commit that references this issue
on Jan 8, 2026 contents()timeline (near identical tois_resource()timeline above)- 4ac5150 (Py 3.7) adds
importlib.abc.ResourceReader, withcontents()returning an empty interator - 6714825 (Py 3.10) resources in namespaces support, change to
raise FileNotFoundError - e712a5b (Py 3.11) moves to
importlib.resources.abc.ResourceReader
importlib_resources.abc.ResourceReader.contents()has consistently raisedFileNotFoundErrorsince it was added in python/importlib_resources@e82b567. Typeshed doesn't care, exceptions aren't part of a type signature.- 4ac5150 (Py 3.7) adds
- Deprectated
ResourceReaderand others were removed fromimportlib.abcin Python 3.14 but docs still mention them
Code: 0751511#diff-f3e6ca7132200b34d6d4bdd7799b8b8270a33bd59945e034b50427893a2a9ca3
Docs:cpython/Doc/library/importlib.rst
Line 605 in cea2d24
.. class:: ResourceReader
- Deprectated
- added a commit that references this issue
on Jan 22, 2026
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsTodo
Documentation
Docs for
importlib.resources.abc.ResourceReaderand the implementation differ in a few details. So far I've noticedis_resource()differsDocs:
is_resource(name).Code:
is_resource(... path ...)Implementation calls the parameterpathcontents()differsDocs: "The abstract method returns an iterable of no items."
Code:
raise FileNotFoundErrorIf fixes are desired then I'm happy to take it on, and coordinate fixes with e.g. https://github.com/python/importlib_resources, https://github.com/python/typeshed
Linked PRs
ResourceReader.is_resource(GH-143523) #143562ResourceReader.is_resource(GH-143523) #143563