René's URL Explorer Experiment


Title: Feedback on new files() and Traverseable API · Issue #90 · python/importlib_resources · GitHub

Open Graph Title: Feedback on new files() and Traverseable API · Issue #90 · python/importlib_resources

X Title: Feedback on new files() and Traverseable API · Issue #90 · python/importlib_resources

Description: In GitLab by @gregory.szorc on Mar 15, 2020, 18:04 I'm attempting to implement the new files() and Traverseable APIs in PyOxidizer and am struggling to figure it out. First, the new classes in abc.py don't have type annotations. I think ...

Open Graph Description: In GitLab by @gregory.szorc on Mar 15, 2020, 18:04 I'm attempting to implement the new files() and Traverseable APIs in PyOxidizer and am struggling to figure it out. First, the new classes in abc....

X Description: In GitLab by @gregory.szorc on Mar 15, 2020, 18:04 I'm attempting to implement the new files() and Traverseable APIs in PyOxidizer and am struggling to figure it out. First, the new classes in ...

Opengraph URL: https://github.com/python/importlib_resources/issues/90

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Feedback on new files() and Traverseable API","articleBody":"In GitLab by @gregory.szorc on Mar 15, 2020, 18:04\n\nI'm attempting to implement the new `files()` and `Traverseable` APIs in PyOxidizer and am struggling to figure it out.\n\nFirst, the new classes in `abc.py` don't have type annotations. I think I can work them out. But being explicit would be much appreciated. Having type annotations would also match the rest of the file.\n\nSecond, the overloading of `Traverseable` to be both a _resource loader_ and an actual resource is a bit confusing. Elsewhere in the `importlib` world, there is a separation between _the interface for loading things_ and _the things returned by that interface_. It is weird to me that a single `Traverseable` both represents the returned value from `files()` (a logical collection of resources or a mechanism to obtain resources) as well as a _handle_ on an individual resource. I would like for these interfaces to be teased apart, if possible. More on this later.\n\nThird - and this is related to the last point - I just don't understand how you are supposed to handle directories in all cases. Because `Traversable` is both a loader and a handle on an individual resource, what are we supposed to do for operations like calling `Traverseable.open()` on an object that represents a directory? Are we supposed to return `None`? Raise an `OsError` or `IoError` or whatever the OS emits when you try to open a directory? Do we assume the caller calls `is_dir()` / `is_file()` and isn't dumb enough to call `open()` on a directory? But what if they do?\n\nFourth, I don't understand why there exists an `open`, `read_text`, and `read_bytes` on `Traverseable`. `read_text` and `read_bytes` can be implemented in terms of `open()`. So why are they a) abstract b) part of the interface in the first place? If we're going to provide `open()`, I think it makes sense to expose helper functions for `read_text` and `read_bytes` that are implemented in terms of `open()`.\n\nFifth, to be honest, I'm not a huge fan of `open()` because it puts a lot of burden on custom implementations. What subset of `Path.open()` needs to be implemented? `Path.open()` is supposed to accept `mode`, `buffering`, `encoding`, `errors`, and `newline` arguments. Since these are all `*args, **kwrags`-awayed in the interface and the docs only call out `mode`, what is supposed to be supported? Is it really reasonable for custom implementations (which may not be able to simply call out to `builtins.open()` because they aren't using a traditional filesystem) to have to implement all this functionality? I would highly encourage reducing the scope of `open()` to binary file reading. Remove buffering, encoding, errors, and newline support. If people really want to buffer or read resources as text, they can use `io.BufferedReader` and/or `io.TextIOWrapper`. And of course, helper APIs that wrap low-level binary-only file-like objects can exist to make `read_text()` a trivial one-liner. Or consider making the text reading APIs optional and having the default resource reading code go through a polyfill that uses `io.*` wrappers accordingly.\n\nI want to say the new `files()` + `Traverseable` API is a net improvement and thank everybody responsible. But at this point in time, I feel like the pile of warts I described in #58 has more or less been replaced by a different pile of warts :/ I failed to see the new API being designed and feel like I missed an opportunity to influence its design towards something more reasonable for advanced use cases like PyOxidizer. For that I feel bad and apologize. If it isn't too late to make backwards-incompatible changes to the interface, I would strongly vote for reducing the scope of `open()` and removing `read_text` and `read_bytes`. If we do that and clarify the interface and semantics a bit more, I think this new API will be clearly better than what came before.","author":{"url":"https://github.com/jaraco","@type":"Person","name":"jaraco"},"datePublished":"2020-10-21T22:13:48Z","url":"https://github.com/python/importlib_resources/issues/90"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:6a296f82-93c5-43a2-6d1b-da720076c428
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBBD4:1833B7:2C18329:3C0ACC3:6B0057AE
html-safe-nonce4213dadbce06225132084500b7eaacce84b3199ef200caccf16ace1c66db0dc0
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQkQ0OjE4MzNCNzoyQzE4MzI5OjNDMEFDQzM6NkIwMDU3QUUiLCJ2aXNpdG9yX2lkIjoiODExNTk3OTUyMzg0MjkyMjQxNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac43a225a2049a36a5b25289a947c3f4ed2a8d6cde652e26f534e15151c8c14328
hovercard-subject-tagissue:726899020
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/importlib_resources/90/issue_layout
twitter:imagehttps://opengraph.githubassets.com/9bef4a8a837c06421116c4c4f5daccdc14f673d4ab4576fbf71be84ad3199e9c/python/importlib_resources/issues/90
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/9bef4a8a837c06421116c4c4f5daccdc14f673d4ab4576fbf71be84ad3199e9c/python/importlib_resources/issues/90
og:image:altIn GitLab by @gregory.szorc on Mar 15, 2020, 18:04 I'm attempting to implement the new files() and Traverseable APIs in PyOxidizer and am struggling to figure it out. First, the new classes in abc....
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamejaraco
hostnamegithub.com
expected-hostnamegithub.com
Nonef420f4996e6b1ff1ccd6d7683f8134f4b5f0f8a50124c210dbfe7490e5644abb
turbo-cache-controlno-preview
go-importgithub.com/python/importlib_resources git https://github.com/python/importlib_resources.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id306147182
octolytics-dimension-repository_nwopython/importlib_resources
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id306147182
octolytics-dimension-repository_network_root_nwopython/importlib_resources
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release26e00df917aba0f128135dc073ea0c5e33a70d40
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/importlib_resources/issues/90#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fimportlib_resources%2Fissues%2F90
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fimportlib_resources%2Fissues%2F90
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fimportlib_resources
Reloadhttps://github.com/python/importlib_resources/issues/90
Reloadhttps://github.com/python/importlib_resources/issues/90
Reloadhttps://github.com/python/importlib_resources/issues/90
pythonhttps://github.com/python
importlib_resourceshttps://github.com/python/importlib_resources
Codehttps://github.com/python/importlib_resources
Issues5 (5)https://github.com/python/importlib_resources/issues
Pull requests7 (7)https://github.com/python/importlib_resources/pulls
Actionshttps://github.com/python/importlib_resources/actions
Projectshttps://github.com/python/importlib_resources/projects
Security and qualityhttps://github.com/python/importlib_resources/security
Insightshttps://github.com/python/importlib_resources/insights
https://github.com/python/importlib_resources
New issuehttps://github.com/login?return_to=https://github.com/python/importlib_resources/issues/90
New issuehttps://github.com/login?return_to=https://github.com/python/importlib_resources/issues/90
Feedback on new files() and Traverseable APIhttps://github.com/python/importlib_resources/issues/90#top
https://github.com/jaraco
jaracohttps://github.com/jaraco
on Oct 21, 2020https://github.com/python/importlib_resources/issues/90#issue-726899020
#58https://github.com/python/importlib_resources/issues/58
https://github.com/jaraco
jaracohttps://github.com/jaraco
on Oct 21, 2020https://github.com/python/importlib_resources/issues/90#issuecomment-713907247
@jaracohttps://github.com/jaraco
https://github.com/jaraco
jaracohttps://github.com/jaraco
on Oct 21, 2020https://github.com/python/importlib_resources/issues/90#issuecomment-713907267
https://github.com/jaraco
jaracohttps://github.com/jaraco
on Oct 21, 2020https://github.com/python/importlib_resources/issues/90#issuecomment-713907284
@jaracohttps://github.com/jaraco
zipp.Pathhttps://zipp.readthedocs.io/en/latest/index.html#zipp.Path
accessing contents over the networkhttps://blog.jaraco.com/tiny-hack-extracting-small-file-from-a-large-zip/
https://github.com/jaraco
jaracohttps://github.com/jaraco
on Oct 21, 2020https://github.com/python/importlib_resources/issues/90#issuecomment-713907307
https://github.com/jaraco
jaracohttps://github.com/jaraco
on Oct 21, 2020https://github.com/python/importlib_resources/issues/90#issuecomment-713907328
@brettcannonhttps://github.com/brettcannon
https://github.com/jaraco
jaracohttps://github.com/jaraco
on Oct 21, 2020https://github.com/python/importlib_resources/issues/90#issuecomment-713907347
https://github.com/jaraco
jaracohttps://github.com/jaraco
on Oct 21, 2020https://github.com/python/importlib_resources/issues/90#issuecomment-713907369
@jaracohttps://github.com/jaraco
examplehttps://github.com/jaraco/zipp/blob/ec6ff0f1d65e0052ef7d38186d7f8a638a83d768/zipp.py#L117-L132
path packagehttps://github.com/jaraco/path/issues/130
proposal abovehttps://github.com/python/importlib_resources/issues/90#note_307473902
https://github.com/jaraco
jaracohttps://github.com/jaraco
on Oct 21, 2020https://github.com/python/importlib_resources/issues/90#issuecomment-713907387
@jaracohttps://github.com/jaraco
1394980https://github.com/python/importlib_resources/commit/13949807ed42e95dd0cf17c2e583d42c9fff94dd
https://github.com/jaraco
jaracohttps://github.com/jaraco
on Oct 21, 2020https://github.com/python/importlib_resources/issues/90#issuecomment-713907408
@jaracohttps://github.com/jaraco
https://github.com/jaraco
jaracohttps://github.com/jaraco
on Oct 21, 2020https://github.com/python/importlib_resources/issues/90#issuecomment-713907423
@jaracohttps://github.com/jaraco
feature/90-low-level-reader branchhttps://gitlab.com/python-devs/importlib_resources/-/tree/feature/90-low-level-reader
https://github.com/jaraco
jaracohttps://github.com/jaraco
on Oct 21, 2020https://github.com/python/importlib_resources/issues/90#issuecomment-713907442
@brettcannonhttps://github.com/brettcannon
https://github.com/jaraco
jaracohttps://github.com/jaraco
on Oct 21, 2020https://github.com/python/importlib_resources/issues/90#issuecomment-713907459
@jaracohttps://github.com/jaraco
https://github.com/jaraco
jaracohttps://github.com/jaraco
on Oct 21, 2020https://github.com/python/importlib_resources/issues/90#issuecomment-713907485
https://pyoxidizer.readthedocs.io/en/latest/packaging_resource_files.htmlhttps://pyoxidizer.readthedocs.io/en/latest/packaging_resource_files.html
https://pyoxidizer.readthedocs.io/en/latest/packaging_importer.htmlhttps://pyoxidizer.readthedocs.io/en/latest/packaging_importer.html
https://github.com/jaraco
jaracohttps://github.com/jaraco
on Oct 21, 2020https://github.com/python/importlib_resources/issues/90#issuecomment-713907502
@jaracohttps://github.com/jaraco
https://github.com/jaraco
jaracohttps://github.com/jaraco
on Jan 19, 2021https://github.com/python/importlib_resources/issues/90#issuecomment-762577514
@indygreghttps://github.com/indygreg
#183https://github.com/python/importlib_resources/pull/183
https://github.com/jaraco
jaracohttps://github.com/jaraco
on May 4, 2021https://github.com/python/importlib_resources/issues/90#issuecomment-832210441
jaracohttps://github.com/jaraco
completedhttps://github.com/python/importlib_resources/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on May 4, 2021https://github.com/python/importlib_resources/issues/90#event-4685424442
https://github.com/septatrix
septatrixhttps://github.com/septatrix
on May 11, 2021https://github.com/python/importlib_resources/issues/90#issuecomment-838582440
https://github.com/jaraco
jaracohttps://github.com/jaraco
on May 11, 2021https://github.com/python/importlib_resources/issues/90#issuecomment-838683527
#80https://github.com/python/importlib_resources/issues/80
changelog for 1.1https://importlib-resources.readthedocs.io/en/latest/history.html#v1-1-0
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/importlib_resources/issues/90
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/importlib_resources/issues/90
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.