This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jaraco
Recipients FFY00, brett.cannon, jaraco
Date 2021-05-24.17:07:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1621876050.98.0.354454429552.issue44195@roundup.psfhosted.org>
In-reply-to
Content
> are people supposed to be implementing readers with just files(), or are they always expected to inherit TraversableResources?

A resource provider could potentially implement only the `files()` method (what I think you're calling `TraversableReader`), but my expectation was that all providers would provide a Reader derived from `TraversableResources` in order to provide backward-compatibility for the `ResourceReader` interface. Long term, I'd expect to deprecate all but `files()` on `TraversableResources`.

If a provider only implemented `files()` today and did not inherit from `TraversableResources`, they would still satisfy the `files()` API, but not the ResourceReader API (i.e. violate the expectation that `Loader.get_resource_reader` returns a ResourceReader).

I decided not to present both `TraversableReader` and `TraversableResources` as separate classes because the latter was sufficient for all known cases.

> It seems to me that maybe that is an issue and we actually want [DegenerateFiles] to inherit from TraversableResources.

Perhaps. What advantage would that have?

> Regardless of the usefulness in code, please also consider type hinting.

Agreed, there are some places where type hints would drastically improve readability.

> If people are expecting to be using this protocol, we should expose it.

My instinct is `TraversableResources` is the preferred protocol for now, although I think it's likely we'll want to separate out the TraversableReader when necessary. Let's plan to do that in importlib_resources first.
History
Date User Action Args
2021-05-24 17:07:31jaracosetrecipients: + jaraco, brett.cannon, FFY00
2021-05-24 17:07:30jaracosetmessageid: <1621876050.98.0.354454429552.issue44195@roundup.psfhosted.org>
2021-05-24 17:07:30jaracolinkissue44195 messages
2021-05-24 17:07:30jaracocreate