Skip to content

importlib.resources.abc.ResourceReader docs/implementation discrepancies #143513

Description

@moreati

Documentation

Docs for importlib.resources.abc.ResourceReader and the implementation differ in a few details. So far I've noticed

  • Parameter name of is_resource() differs
    Docs: is_resource(name).
    Code: is_resource(... path ...)Implementation calls the parameter path
  • Behaviour of contents() differs
    Docs: "The abstract method returns an iterable of no items."
    Code: raise FileNotFoundError

If 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

Activity

  1. johnslavik commented on Jan 7, 2026

    @johnslavik
    Member

    Thank you!

    If fixes are desired

    In the importlib.resources.abc.ResourceReader.is_resource case, judging by this change in the typeshed, the parameter used to be name until 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?

  2. johnslavik commented on Jan 7, 2026

    @johnslavik
    Member

    I don't think we'll change contents() anyway so I'd say go for the two fixes :-)

  3. moreati commented on Jan 7, 2026

    @moreati
    ContributorAuthor

    Timeline for my reference

    • 4ac5150 (Py 3.7) adds importlib.abc.ResourceReader, with is_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.ResourceReader has consistently used is_resource(path) since that method was added in python/importlib_resources@e82b567

  4. added a commit that references this issue on Jan 7, 2026
  5. added a commit that references this issue on Jan 8, 2026
  6. added 2 commits that reference this issue on Jan 8, 2026
  7. added 2 commits that reference this issue on Jan 8, 2026
  8. moreati commented on Jan 8, 2026

    @moreati
    ContributorAuthor

    contents() timeline (near identical to is_resource() timeline above)

    • 4ac5150 (Py 3.7) adds importlib.abc.ResourceReader, with contents() 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 raised FileNotFoundError since it was added in python/importlib_resources@e82b567. Typeshed doesn't care, exceptions aren't part of a type signature.

  9. moreati commented on Jan 8, 2026

    @moreati
    ContributorAuthor
  10. added 3 commits that reference this issue on Jan 8, 2026
  11. added a commit that references this issue on Jan 12, 2026
  12. added a commit that references this issue on Jan 22, 2026
  13. added a commit that references this issue on Jan 22, 2026
  14. added a commit that references this issue on Jan 22, 2026
  15. added a commit that references this issue on Jan 23, 2026
  16. added 2 commits that reference this issue on Feb 15, 2026
  17. added a commit that references this issue on May 4, 2026
  18. added a commit that references this issue on Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions