René's URL Explorer Experiment


Title: Replace `DegenerateFiles` with `CompatibilityFiles` · Issue #226 · python/importlib_resources · GitHub

Open Graph Title: Replace `DegenerateFiles` with `CompatibilityFiles` · Issue #226 · python/importlib_resources

X Title: Replace `DegenerateFiles` with `CompatibilityFiles` · Issue #226 · python/importlib_resources

Description: When reimplementing the lagacy api with files() in preparation for the legacy API deprecation, as discussed in #80, I uncovered that it does not have proper support for the legacy ResourceReader API. We implement DegenerateFiles, which t...

Open Graph Description: When reimplementing the lagacy api with files() in preparation for the legacy API deprecation, as discussed in #80, I uncovered that it does not have proper support for the legacy ResourceReader AP...

X Description: When reimplementing the lagacy api with files() in preparation for the legacy API deprecation, as discussed in #80, I uncovered that it does not have proper support for the legacy ResourceReader AP...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Replace `DegenerateFiles` with `CompatibilityFiles`","articleBody":"When reimplementing the lagacy api with `files()` in preparation for the legacy API deprecation, as discussed in #80, I uncovered that it does not have proper support for the legacy `ResourceReader` API.\r\n\r\nWe implement `DegenerateFiles`, which takes a module spec and implements a degenerate object to be used as a fallback if no better `TraversableReader` is available.\r\n\r\nhttps://github.com/python/importlib_resources/blob/a024adf2c5235218aeb6d90817fe93b4e63496b9/importlib_resources/_adapters.py#L31-L74\r\nhttps://github.com/python/importlib_resources/blob/a024adf2c5235218aeb6d90817fe93b4e63496b9/importlib_resources/_compat.py#L64-L77\r\n\r\nIn some of the cases where it is used, we actually have a valid `ResourceReader` that we can use. We have one example in the tests.\r\n\r\nhttps://github.com/python/importlib_resources/blob/a024adf2c5235218aeb6d90817fe93b4e63496b9/importlib_resources/tests/util.py#L54-L61\r\n\r\nThe `files()` api won't work here, even though the legacy API does. If we deprecate the legacy api, users in these situations won't have any good alternative. I expect some of them to be in situations where they are not the ones that provide the reader, and so they are not able to fix it by adopting `TraversableReader`.\r\n\r\nTo solve this I propose replacing `DegenerateFiles` with a new implementation, `CompatibilityFiles`. It would adapt the `ResourceReader` api to provide a `TraversableReader`, essentially the oposite of `TraversableResources`, which implements a `ResourceReader` from a `TraversableReader`.\r\n\r\nI have a working implementation in #221. Though, when changing the leagcy api to use `files()`, in order to make sure it supports all the use cases in the legacy api tests, I ran into some failures.\r\n\r\nhttps://github.com/FFY00/importlib_resources/blob/7cb935e1defc995c24a63e8a08453e9f55d0fef2/importlib_resources/_adapters.py#L32-L113\r\n\r\n---\r\n\r\n@brettcannon you wrote the two tests that are now failing when you added support for the `ResourceReader` api, so I was hoping maybe you would be able to clarify some things.\r\n\r\n`test_resource_path` does not set `contents` in `create_package` and then tries to open the file. This worked in the legacy api, but raises `FileNotFoundError` in `files()`. I would guess that it was simply ommited because it worked, but that might not be necessarily true. Do you remember?\r\n\r\nI have set `contents` so that it includes `utf-8.file` in my PR, which fixes the issue. I think it is reasonable to fail reading a resource if that resource is not listed by `ResourceReader.contents`, that's actually what I would expect.\r\n\r\nhttps://github.com/python/importlib_resources/blob/a024adf2c5235218aeb6d90817fe93b4e63496b9/importlib_resources/tests/util.py#L121-L126\r\n\r\nThe other test, which is the one that is giving me trouble, is `test_resource_opener`. As far as I can tell, it essentially tests if we can still read a resource when `resource_path`, `is_resource` and `contents` (from `ResourceReader`) raise an exception, which does not seem very correct to me.\r\n\r\nThose methods are writen to raise an exception if `Reader.path` is an exception. This test specifically triggers that and then atempts to read the file.\r\n\r\n@brettcannon do you have any more context on this? Does it seems right? Or should it be removed?\r\n\r\nhttps://github.com/python/importlib_resources/blob/a024adf2c5235218aeb6d90817fe93b4e63496b9/importlib_resources/tests/util.py#L115-L119\r\n\r\nhttps://github.com/python/importlib_resources/blob/a024adf2c5235218aeb6d90817fe93b4e63496b9/importlib_resources/tests/util.py#L17-L51\r\n\r\nHopefully I have provided here all the context needed to understand the issue without having to go dig through the code, but let me know if there is still something I could clarify.","author":{"url":"https://github.com/FFY00","@type":"Person","name":"FFY00"},"datePublished":"2021-05-20T23:54:51Z","url":"https://github.com/python/importlib_resources/issues/226"}

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:89f7fd87-ac92-92c1-a585-379aabd60b7e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBCF0:A70A9:1A80F41:230056D:6B0219B2
html-safe-nonceb5aaaa66094de58a67ee63933fc0f5967a0ae912885938f332f65e2d5ce400fe
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQ0YwOkE3MEE5OjFBODBGNDE6MjMwMDU2RDo2QjAyMTlCMiIsInZpc2l0b3JfaWQiOiI4MzU2NjQ4MDc2NDAzOTM5NzYyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac932b892de90df30c63137bb994d0ca5253d299c097d224c1e20691c5a333545d
hovercard-subject-tagissue:897558682
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/226/issue_layout
twitter:imagehttps://opengraph.githubassets.com/6fb5bd50e258a9984fc885ab7ab9befb4baf095aaca5350a6317c804fd38063d/python/importlib_resources/issues/226
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/6fb5bd50e258a9984fc885ab7ab9befb4baf095aaca5350a6317c804fd38063d/python/importlib_resources/issues/226
og:image:altWhen reimplementing the lagacy api with files() in preparation for the legacy API deprecation, as discussed in #80, I uncovered that it does not have proper support for the legacy ResourceReader AP...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameFFY00
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
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
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetcanary-1
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/importlib_resources/issues/226#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fimportlib_resources%2Fissues%2F226
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%2F226
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/226
Reloadhttps://github.com/python/importlib_resources/issues/226
Reloadhttps://github.com/python/importlib_resources/issues/226
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/226
New issuehttps://github.com/login?return_to=https://github.com/python/importlib_resources/issues/226
Replace DegenerateFiles with CompatibilityFileshttps://github.com/python/importlib_resources/issues/226#top
https://github.com/FFY00
FFY00https://github.com/FFY00
on May 20, 2021https://github.com/python/importlib_resources/issues/226#issue-897558682
#80https://github.com/python/importlib_resources/issues/80
importlib_resources/importlib_resources/_adapters.pyhttps://github.com/python/importlib_resources/blob/a024adf2c5235218aeb6d90817fe93b4e63496b9/importlib_resources/_adapters.py#L31-L74
a024adfhttps://github.com/python/importlib_resources/commit/a024adf2c5235218aeb6d90817fe93b4e63496b9
importlib_resources/importlib_resources/_compat.pyhttps://github.com/python/importlib_resources/blob/a024adf2c5235218aeb6d90817fe93b4e63496b9/importlib_resources/_compat.py#L64-L77
a024adfhttps://github.com/python/importlib_resources/commit/a024adf2c5235218aeb6d90817fe93b4e63496b9
importlib_resources/importlib_resources/tests/util.pyhttps://github.com/python/importlib_resources/blob/a024adf2c5235218aeb6d90817fe93b4e63496b9/importlib_resources/tests/util.py#L54-L61
a024adfhttps://github.com/python/importlib_resources/commit/a024adf2c5235218aeb6d90817fe93b4e63496b9
#221https://github.com/python/importlib_resources/pull/221
https://github.com/FFY00/importlib_resources/blob/7cb935e1defc995c24a63e8a08453e9f55d0fef2/importlib_resources/_adapters.py#L32-L113https://github.com/FFY00/importlib_resources/blob/7cb935e1defc995c24a63e8a08453e9f55d0fef2/importlib_resources/_adapters.py#L32-L113
@brettcannonhttps://github.com/brettcannon
importlib_resources/importlib_resources/tests/util.pyhttps://github.com/python/importlib_resources/blob/a024adf2c5235218aeb6d90817fe93b4e63496b9/importlib_resources/tests/util.py#L121-L126
a024adfhttps://github.com/python/importlib_resources/commit/a024adf2c5235218aeb6d90817fe93b4e63496b9
@brettcannonhttps://github.com/brettcannon
importlib_resources/importlib_resources/tests/util.pyhttps://github.com/python/importlib_resources/blob/a024adf2c5235218aeb6d90817fe93b4e63496b9/importlib_resources/tests/util.py#L115-L119
a024adfhttps://github.com/python/importlib_resources/commit/a024adf2c5235218aeb6d90817fe93b4e63496b9
importlib_resources/importlib_resources/tests/util.pyhttps://github.com/python/importlib_resources/blob/a024adf2c5235218aeb6d90817fe93b4e63496b9/importlib_resources/tests/util.py#L17-L51
a024adfhttps://github.com/python/importlib_resources/commit/a024adf2c5235218aeb6d90817fe93b4e63496b9
https://github.com/jaraco
jaracohttps://github.com/jaraco
on May 24, 2021https://github.com/python/importlib_resources/issues/226#issuecomment-847168805
e1a0b90https://github.com/python/importlib_resources/commit/e1a0b908e3533f1b0d8d373d054fdf522b68a0bc
https://github.com/FFY00
FFY00https://github.com/FFY00
on May 29, 2021https://github.com/python/importlib_resources/issues/226#issuecomment-850880230
https://github.com/jaraco
jaracohttps://github.com/jaraco
on Jul 16, 2021https://github.com/python/importlib_resources/issues/226#issuecomment-881668936
#221https://github.com/python/importlib_resources/pull/221
jaracohttps://github.com/jaraco
completedhttps://github.com/python/importlib_resources/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Jul 16, 2021https://github.com/python/importlib_resources/issues/226#event-5032530450
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/importlib_resources/issues/226
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/importlib_resources/issues/226
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.