Title: Surprising Any in result type of re.Match.group() where None expected · Issue #12090 · python/typeshed · GitHub
Open Graph Title: Surprising Any in result type of re.Match.group() where None expected · Issue #12090 · python/typeshed
X Title: Surprising Any in result type of re.Match.group() where None expected · Issue #12090 · python/typeshed
Description: I've been trying to typecheck some code that uses re.match but getting some unexpected Anys in it that came from these typeshed definitions (especially the second and third ones): # group() returns "AnyStr" or "AnyStr | None", depending ...
Open Graph Description: I've been trying to typecheck some code that uses re.match but getting some unexpected Anys in it that came from these typeshed definitions (especially the second and third ones): # group() returns...
X Description: I've been trying to typecheck some code that uses re.match but getting some unexpected Anys in it that came from these typeshed definitions (especially the second and third ones): # group() ret...
Opengraph URL: https://github.com/python/typeshed/issues/12090
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Surprising Any in result type of re.Match.group() where None expected","articleBody":"I've been trying to typecheck some code that uses `re.match` but getting some unexpected `Any`s in it that came from these typeshed definitions (especially the second and third ones):\r\n\r\n```python\r\n # group() returns \"AnyStr\" or \"AnyStr | None\", depending on the pattern.\r\n @overload\r\n def group(self, group: Literal[0] = 0, /) -> AnyStr: ...\r\n @overload\r\n def group(self, group: str | int, /) -> AnyStr | Any: ...\r\n @overload\r\n def group(self, group1: str | int, group2: str | int, /, *groups: str | int) -> tuple[AnyStr | Any, ...]: ...\r\n```\r\n\r\nUnder what circumstance is producing an `Any` at this point a good plan? The `AnyStr` is fine, but surely the `Any` should be a `None`? After all, right now it's saying \"Oh, we could spontaneously return a lock object from the `concurrency` module because we're feeling bored; no promises!\" which is rather at variance with the documentation which says effectively \"returns a substring if there is a match group, otherwise `None`\".","author":{"url":"https://github.com/dkfellows","@type":"Person","name":"dkfellows"},"datePublished":"2024-06-03T14:20:23Z","url":"https://github.com/python/typeshed/issues/12090"}
| 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:40797043-6a8d-f196-60c4-dfad9bd712f9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B27C:30501:6EBD8A:956568:6B003A79 |
| html-safe-nonce | 91fcc4a2c8f35ac0fd5e1a42d63c2d559326456ce4bc4adf087e8dab1205980a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMjdDOjMwNTAxOjZFQkQ4QTo5NTY1Njg6NkIwMDNBNzkiLCJ2aXNpdG9yX2lkIjoiNjExNTM0NTYxMzc2MTU1OTE2MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 83270d0344e4e1a28bedf15d4c1f636b88911576756514e82257fc7feae46be8 |
| hovercard-subject-tag | issue:2331287864 |
| 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/12090/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e23dd604df209c58d0e21776423df6d54ecc7ef1d48ae0c625a355d54023ac0f/python/typeshed/issues/12090 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e23dd604df209c58d0e21776423df6d54ecc7ef1d48ae0c625a355d54023ac0f/python/typeshed/issues/12090 |
| og:image:alt | I've been trying to typecheck some code that uses re.match but getting some unexpected Anys in it that came from these typeshed definitions (especially the second and third ones): # group() returns... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dkfellows |
| 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