Title: Proposal: infer obvious parameters and return types · Issue #10149 · python/mypy · GitHub
Open Graph Title: Proposal: infer obvious parameters and return types · Issue #10149 · python/mypy
X Title: Proposal: infer obvious parameters and return types · Issue #10149 · python/mypy
Description: Feature Similar to #4409, but also broader, allow for mypy to infer the parameter and return types for a function that's a passthrough to other typed functions. Pitch Consider the case in keyring, where the get_password function is a con...
Open Graph Description: Feature Similar to #4409, but also broader, allow for mypy to infer the parameter and return types for a function that's a passthrough to other typed functions. Pitch Consider the case in keyring, ...
X Description: Feature Similar to #4409, but also broader, allow for mypy to infer the parameter and return types for a function that's a passthrough to other typed functions. Pitch Consider the case in keyri...
Opengraph URL: https://github.com/python/mypy/issues/10149
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Proposal: infer obvious parameters and return types","articleBody":"**Feature**\r\n\r\nSimilar to #4409, but also broader, allow for mypy to infer the parameter and return types for a function that's a passthrough to other typed functions.\r\n\r\n**Pitch**\r\n\r\nConsider the case in keyring, where the `get_password` function is a convenience accessor to (a) resolve the backend and (b) invoke the method of the same name on that backend with the same parameters:\r\n\r\nhttps://github.com/jaraco/keyring/blob/db6896acea942a86d3fbee7e2a556fffb38055ba/keyring/core.py#L54-L56\r\n\r\nThe `get_keyring()` is annotated and [always returns](https://github.com/jaraco/keyring/blob/db6896acea942a86d3fbee7e2a556fffb38055ba/keyring/core.py#L30) a `KeyringBackend`. `KeyringBackend` is [annotated](https://github.com/jaraco/keyring/blob/db6896acea942a86d3fbee7e2a556fffb38055ba/keyring/backend.py#L97) and its `get_password` always demands `str` parameters and declares its return type.\r\n\r\nAs a result, it's unambiguous what the required parameters and return type for `core.get_password` must be.\r\n\r\nIn pypa/twine#733, we learned that if a downstream consumer of the library enables `disallow_untyped_calls`, it will fail on `core.get_password` unless that function is redundantly decorated with the same parameters and return types of `KeyringBackend.get_password`.\r\n\r\nIt would be nice if mypy could infer the types from these unambiguous cases like passthrough functions, possibly gated by a feature flag or a decorator on the function (e.g. `@typing.passthrough`), and avoid the [somewhat messy redundancy](https://github.com/jaraco/keyring/commit/ceeaa922c6ac492505aabdb2791b86899adfedbc) that results from hand-copying the types.","author":{"url":"https://github.com/jaraco","@type":"Person","name":"jaraco"},"datePublished":"2021-02-27T17:25:10Z","url":"https://github.com/python/mypy/issues/10149"}
| 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:d96597c1-1856-f8b6-29e6-9b25e9fbf89a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AFD0:144E47:2A2E802:37543CB:6B000CA8 |
| html-safe-nonce | 572b455b1a29df7f4098914273e782e6d23f61e0035da1dd5f57b404d21174dc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRkQwOjE0NEU0NzoyQTJFODAyOjM3NTQzQ0I6NkIwMDBDQTgiLCJ2aXNpdG9yX2lkIjoiNTY1MzUzMDMxNjExNjA2OTU0NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f8b8a8e59ad94b62960f0f1f7aa5d99d75015c0af4f8b6ff5afa6582e85e4829 |
| hovercard-subject-tag | issue:817975742 |
| 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/mypy/10149/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3ac96187bbcf5db00305b9aaa139ab1a255851fa690612422e205005eb0c6140/python/mypy/issues/10149 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3ac96187bbcf5db00305b9aaa139ab1a255851fa690612422e205005eb0c6140/python/mypy/issues/10149 |
| og:image:alt | Feature Similar to #4409, but also broader, allow for mypy to infer the parameter and return types for a function that's a passthrough to other typed functions. Pitch Consider the case in keyring, ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jaraco |
| hostname | github.com |
| expected-hostname | github.com |
| None | cf7ee0062053ad9eb05b6e5de57bd96c2055708bcbada4144946b5ec129cf1d7 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/mypy git https://github.com/python/mypy.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 7053637 |
| octolytics-dimension-repository_nwo | python/mypy |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7053637 |
| octolytics-dimension-repository_network_root_nwo | python/mypy |
| 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 | 9cab7de176a56362d2aabcbb4d1e07e846eba8a0 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width