Title: pathlib __truediv__ returns the "self" type · Issue #553 · python/typeshed · GitHub
Open Graph Title: pathlib __truediv__ returns the "self" type · Issue #553 · python/typeshed
X Title: pathlib __truediv__ returns the "self" type · Issue #553 · python/typeshed
Description: The pathlib implementation seems to go to some trouble to preserve subtypes in children. This works fine: import pathlib class MyPath(pathlib.PosixPath): def parity(self): return len(str(self)) % 2 root = MyPath('/') print(root.parity())...
Open Graph Description: The pathlib implementation seems to go to some trouble to preserve subtypes in children. This works fine: import pathlib class MyPath(pathlib.PosixPath): def parity(self): return len(str(self)) % 2...
X Description: The pathlib implementation seems to go to some trouble to preserve subtypes in children. This works fine: import pathlib class MyPath(pathlib.PosixPath): def parity(self): return len(str(self)) % 2...
Opengraph URL: https://github.com/python/typeshed/issues/553
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"pathlib __truediv__ returns the \"self\" type","articleBody":"The pathlib implementation seems to go to some trouble to preserve subtypes in children. This works fine:\n\n``` python\nimport pathlib\n\n\nclass MyPath(pathlib.PosixPath):\n def parity(self):\n return len(str(self)) % 2\n\nroot = MyPath('/')\nprint(root.parity())\nchild = root / 'there'\nprint(child.parity())\n```\n\n```\n$ python3 t.py \n1\n0\n```\n\nBut this declaration isn't parameterized:\n\n``` python\n def __truediv__(self, key: Union[str, PurePath]) -> PurePath: ...\n```\n\nso the program above doesn't typecheck:\n\n```\n$ mypy t.py \nt.py:11: error: \"PurePath\" has no attribute \"parity\"\n```\n","author":{"url":"https://github.com/dckc","@type":"Person","name":"dckc"},"datePublished":"2016-09-17T06:47:29Z","url":"https://github.com/python/typeshed/issues/553"}
| 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:038d397f-534d-5ae5-7237-678a99027cca |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B058:2B9B04:2F72A90:3EC87E4:6B002B6A |
| html-safe-nonce | 63becfafec61fc0dd11145fa687676dbfcac71fc7afad996c291a9376e8419d6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMDU4OjJCOUIwNDoyRjcyQTkwOjNFQzg3RTQ6NkIwMDJCNkEiLCJ2aXNpdG9yX2lkIjoiNDU3OTU2NTkwOTczMDkyOTUxNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 3b91a0b8c868af0dbf9c5944a82ae82c6eac4ee56ccc7d7494e702860563dc86 |
| hovercard-subject-tag | issue:177560227 |
| 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/typeshed/553/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cdb15f03563f7f719a983f1f9cc688ca6783c49c451c4f3191285435c041c068/python/typeshed/issues/553 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cdb15f03563f7f719a983f1f9cc688ca6783c49c451c4f3191285435c041c068/python/typeshed/issues/553 |
| og:image:alt | The pathlib implementation seems to go to some trouble to preserve subtypes in children. This works fine: import pathlib class MyPath(pathlib.PosixPath): def parity(self): return len(str(self)) % 2... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dckc |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/typeshed git https://github.com/python/typeshed.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 31696383 |
| octolytics-dimension-repository_nwo | python/typeshed |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31696383 |
| octolytics-dimension-repository_network_root_nwo | python/typeshed |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width