Title: Improve documentation for decisions around certain `list`, `dict`, `Mapping`, and `Sequence` methods · Issue #7015 · python/typeshed · GitHub
Open Graph Title: Improve documentation for decisions around certain `list`, `dict`, `Mapping`, and `Sequence` methods · Issue #7015 · python/typeshed
X Title: Improve documentation for decisions around certain `list`, `dict`, `Mapping`, and `Sequence` methods · Issue #7015 · python/typeshed
Description: list.index and list.count currently only accepts values of the element type and Sequence.index and Sequence.count use Any for the type of the argument. In my opinion all of these functions could safely take object. dict.get and Mapping.g...
Open Graph Description: list.index and list.count currently only accepts values of the element type and Sequence.index and Sequence.count use Any for the type of the argument. In my opinion all of these functions could sa...
X Description: list.index and list.count currently only accepts values of the element type and Sequence.index and Sequence.count use Any for the type of the argument. In my opinion all of these functions could sa...
Opengraph URL: https://github.com/python/typeshed/issues/7015
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Improve documentation for decisions around certain `list`, `dict`, `Mapping`, and `Sequence` methods","articleBody":"[`list.index`](https://github.com/python/typeshed/blob/35064a7f759facd7c3787ab6095964008f97d873/stdlib/builtins.pyi#L797) and [`list.count`](https://github.com/python/typeshed/blob/35064a7f759facd7c3787ab6095964008f97d873/stdlib/builtins.pyi#L798) currently only accepts values of the element type and [`Sequence.index`](https://github.com/python/typeshed/blob/35064a7f759facd7c3787ab6095964008f97d873/stdlib/typing.pyi#L328) and [`Sequence.count`](https://github.com/python/typeshed/blob/35064a7f759facd7c3787ab6095964008f97d873/stdlib/typing.pyi#L329) use `Any` for the type of the argument. In my opinion all of these functions could safely take `object`.\r\n\r\n[`dict.get`](https://github.com/python/typeshed/blob/35064a7f759facd7c3787ab6095964008f97d873/stdlib/builtins.pyi#L861-L864) and [`Mapping.get`](https://github.com/python/typeshed/blob/35064a7f759facd7c3787ab6095964008f97d873/stdlib/typing.pyi#L453-L456) currently only accepts values of the key type. This could be safely extended to be any Hashable object. Non-Hashable values will raise TypeError, but runtime safely accepts values of any other type. I ran into someone on the gitter who needed this a few weeks ago, but he never opened an issue.\r\n\r\nI would be willing to make a PR for this.","author":{"url":"https://github.com/ktbarrett","@type":"Person","name":"ktbarrett"},"datePublished":"2022-01-24T03:15:08.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/7015/typeshed/issues/7015"}
| 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:bf4777ff-74b1-fc70-5aa7-6ca5f51e206b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9880:13966B:E09A40:13606D5:6A6258CF |
| html-safe-nonce | 20be5af0168d3cb9c27cef0da5eb905c2194a912fd9f030eda49543733794118 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5ODgwOjEzOTY2QjpFMDlBNDA6MTM2MDZENTo2QTYyNThDRiIsInZpc2l0b3JfaWQiOiIzNjQyNTgyNTU4MDYzNjM2NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b1a76d6f7fc458786939081bda689ac35f1f9c1e1ce488d3f0609cb8ce0bcc57 |
| hovercard-subject-tag | issue:1112116009 |
| 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/7015/issue_layout |
| twitter:image | https://opengraph.githubassets.com/079fff7ae847eecb214284ca4e0c947ea8427f6600fbf8ab0ff0985dce73c48a/python/typeshed/issues/7015 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/079fff7ae847eecb214284ca4e0c947ea8427f6600fbf8ab0ff0985dce73c48a/python/typeshed/issues/7015 |
| og:image:alt | list.index and list.count currently only accepts values of the element type and Sequence.index and Sequence.count use Any for the type of the argument. In my opinion all of these functions could sa... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ktbarrett |
| hostname | github.com |
| expected-hostname | github.com |
| None | b928dd27bb9305f313c737471c216297e218430ec505d064cf33d7d74af9bf89 |
| 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 | 6f728c3f39985ee4d171ffdd5591d8d2652392d9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width