Title: Typing – Traversable vs MultiplexedPath return value of files() · Issue #286 · python/importlib_resources · GitHub
Open Graph Title: Typing – Traversable vs MultiplexedPath return value of files() · Issue #286 · python/importlib_resources
X Title: Typing – Traversable vs MultiplexedPath return value of files() · Issue #286 · python/importlib_resources
Description: Related to: python/cpython#106614 and #263 I see two possible workarounds for the mentioned issue: str((files("jupyterlab_server.test_data") / "dummy").parent) or str(files("jupyterlab_server.test_data")._paths[0]) but both have issues w...
Open Graph Description: Related to: python/cpython#106614 and #263 I see two possible workarounds for the mentioned issue: str((files("jupyterlab_server.test_data") / "dummy").parent) or str(files("jupyterlab_server.test_...
X Description: Related to: python/cpython#106614 and #263 I see two possible workarounds for the mentioned issue: str((files("jupyterlab_server.test_data") / "dummy").parent) or str(files(&quo...
Opengraph URL: https://github.com/python/importlib_resources/issues/286
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Typing – Traversable vs MultiplexedPath return value of files()","articleBody":"Related to: https://github.com/python/cpython/issues/106614 and https://github.com/python/importlib_resources/issues/263\r\n\r\nI see two possible workarounds for the mentioned issue:\r\n\r\n```python\r\nstr((files(\"jupyterlab_server.test_data\") / \"dummy\").parent)\r\n```\r\nor\r\n```python\r\nstr(files(\"jupyterlab_server.test_data\")._paths[0])\r\n```\r\nbut both have issues with typing because the signature of `files` function is:\r\nhttps://github.com/python/importlib_resources/blob/02f31b78d37da2525662369a4db2ace47188f4af/importlib_resources/_common.py#L52\r\nIn my specific case, files always returns `MultiplexedPath` so both workarounds are fine but mypy complains about it because `Traversable` neither has `_paths` not `parent` attributes.\r\n\r\nWhen I tried to change the return value in the annotation from `Traversable` to `MultiplexedPath` mypy did not complain about it so it seems that the function cannot return anything else than `MultiplexedPath`. Is that correct? Would it make sense to make the type annotation more specific?","author":{"url":"https://github.com/frenzymadness","@type":"Person","name":"frenzymadness"},"datePublished":"2023-08-02T11:35:02Z","url":"https://github.com/python/importlib_resources/issues/286"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:43703fc8-67c7-aea2-f82a-6c43295b9fb7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A948:30CC09:2C64263:3C44112:6B0051E1 |
| html-safe-nonce | e5ef4739b83a5cfea59f4122e9a02f385de0f154391ec83866bd4407deeed155 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOTQ4OjMwQ0MwOToyQzY0MjYzOjNDNDQxMTI6NkIwMDUxRTEiLCJ2aXNpdG9yX2lkIjoiNjYyMDM4Mzk1MDQ0NTQ5ODg0OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 58d93714300c162c40a401beee5d2ef81d6e3fa2db83b728d6bc598cf9e2c0f0 |
| hovercard-subject-tag | issue:1833005621 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/importlib_resources/286/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1e9f4b380bf299ac3a2046f1ce3a723b44e3e500b1c465cd191ae34b5063e6a4/python/importlib_resources/issues/286 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1e9f4b380bf299ac3a2046f1ce3a723b44e3e500b1c465cd191ae34b5063e6a4/python/importlib_resources/issues/286 |
| og:image:alt | Related to: python/cpython#106614 and #263 I see two possible workarounds for the mentioned issue: str((files("jupyterlab_server.test_data") / "dummy").parent) or str(files("jupyterlab_server.test_... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | frenzymadness |
| hostname | github.com |
| expected-hostname | github.com |
| None | f420f4996e6b1ff1ccd6d7683f8134f4b5f0f8a50124c210dbfe7490e5644abb |
| turbo-cache-control | no-preview |
| go-import | github.com/python/importlib_resources git https://github.com/python/importlib_resources.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 306147182 |
| octolytics-dimension-repository_nwo | python/importlib_resources |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 306147182 |
| octolytics-dimension-repository_network_root_nwo | python/importlib_resources |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 26e00df917aba0f128135dc073ea0c5e33a70d40 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width