Title: Need plugin hooks for functions/methods · Issue #6760 · python/mypy · GitHub
Open Graph Title: Need plugin hooks for functions/methods · Issue #6760 · python/mypy
X Title: Need plugin hooks for functions/methods · Issue #6760 · python/mypy
Description: For some frameworks like pytest it would be useful to have a plugin that works with functions. Currently mypy has decorator hook for classes. Some ideas for possible hooks: update function namespace to inject some names modify function s...
Open Graph Description: For some frameworks like pytest it would be useful to have a plugin that works with functions. Currently mypy has decorator hook for classes. Some ideas for possible hooks: update function namespac...
X Description: For some frameworks like pytest it would be useful to have a plugin that works with functions. Currently mypy has decorator hook for classes. Some ideas for possible hooks: update function namespac...
Opengraph URL: https://github.com/python/mypy/issues/6760
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Need plugin hooks for functions/methods","articleBody":"For some frameworks like `pytest` it would be useful to have a plugin that works with functions.\r\nCurrently mypy has decorator hook for classes.\r\n\r\nSome ideas for possible hooks: \r\n1. update function namespace to inject some names\r\n2. modify function signature \r\n3. generate function signature (types)\r\n\r\nFor example pytest has the following fixture\r\n\r\n```python\r\nfrom pathlib import Path\r\n\r\n@pytest.fixture\r\ndef db_path(tmp_path: Path) -> Path:\r\n return tmp_path / 'test.db'\r\n```\r\n\r\nThe fixture is used by name:\r\n```python\r\ndef test_a(db_path) -> None:\r\n ....\r\n```\r\n`db_path` argument here is a calucated the result of `db_path()` fixture call.\r\nIt is bound by parameter name which is the same as the fixture name.\r\n\r\nAdding a type to `db_path` argument is tedious, especially if a fixture returns some complex type like `Callable[[str, int], Awaitable[web.Response]]`.\r\n\r\nTechnically all needed information can be extracted from fixture definition if the definition is type annotated.\r\n\r\nA plugin for pytest would be awesome but as @ilevkivskyi said `mypy` needs a new hook to support it.","author":{"url":"https://github.com/asvetlov","@type":"Person","name":"asvetlov"},"datePublished":"2019-05-03T14:29:28Z","url":"https://github.com/python/mypy/issues/6760"}
| 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:50212214-9a7c-68d4-6225-a0b3ddf1f15e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 901C:B0403:109B695:15B6C06:6AFFFB7B |
| html-safe-nonce | 759d3be4830325ab0203ec7406c548fb4bc0f0eed545ead55009f63b4895be73 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MDFDOkIwNDAzOjEwOUI2OTU6MTVCNkMwNjo2QUZGRkI3QiIsInZpc2l0b3JfaWQiOiI3MDEzMDAyNjg2Mzg3NzE0OTM5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 575d3ca31c215307c8bd28eb76f393882b554db07912fb4a098c056c39741d2a |
| hovercard-subject-tag | issue:440072587 |
| 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/6760/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3597c13cafe1b7bfded79252816707f842714f7bee8675629423e4769a1fb134/python/mypy/issues/6760 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3597c13cafe1b7bfded79252816707f842714f7bee8675629423e4769a1fb134/python/mypy/issues/6760 |
| og:image:alt | For some frameworks like pytest it would be useful to have a plugin that works with functions. Currently mypy has decorator hook for classes. Some ideas for possible hooks: update function namespac... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | asvetlov |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0a0d8686a27478df474dd7415776a7a080cde8838b3cd92ea7601187572e5729 |
| 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 | 16a11879678aaf97e2a42c33ee70830aa084fa37 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width