Title: Type check untyped code using correspoding stub · Issue #3505 · python/mypy · GitHub
Open Graph Title: Type check untyped code using correspoding stub · Issue #3505 · python/mypy
X Title: Type check untyped code using correspoding stub · Issue #3505 · python/mypy
Description: I have a file I don't want to add type annotations to (not my code, core.py) and a stub for that file (core.pyi). I would like mypy to check for type issues in the file, pulling in the types from the stub as needed. Example workflow: Unt...
Open Graph Description: I have a file I don't want to add type annotations to (not my code, core.py) and a stub for that file (core.pyi). I would like mypy to check for type issues in the file, pulling in the types from t...
X Description: I have a file I don't want to add type annotations to (not my code, core.py) and a stub for that file (core.pyi). I would like mypy to check for type issues in the file, pulling in the types fr...
Opengraph URL: https://github.com/python/mypy/issues/3505
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Type check untyped code using correspoding stub","articleBody":"I have a file I don't want to add type annotations to (not my code, core.py) and a stub for that file (core.pyi).\r\nI would like mypy to check for type issues in the file, pulling in the types from the stub as needed.\r\n\r\nExample workflow:\r\n\r\n**Untyped code (core.py):**\r\n```\r\ndef foo():\r\n return '123'\r\n```\r\n**Corresponding stub file (core.pyi):**\r\n```\r\ndef foo() -> int: ...\r\n```\r\nNote that if the type annotations were in the code, it would catch the type issue;\r\n\r\n```bash\r\n$>mypy core_with_type_annotations.py\r\nmypy_test.py:2: error: Incompatible return value type (got \"str\", expected \"int\")\r\n```\r\n\r\nIt would be useful if `mypy core.py` would pull in type annotations as necessary from the corresponding stub file (possibly by supplying a flag on the command-line):\r\n\r\n```bash\r\n$>mypy --use-self-stubs core.py\r\nmypy_test.py:2: error: Incompatible return value type (got \"str\", expected \"int\")\r\n```\r\n\r\nSince this feature does not exist, I currently have to modify the source directly and add the type annotations, and then back out those changes if I need to make a commit against the source (being careful not to commit the annotations).\r\n\r\n","author":{"url":"https://github.com/movermeyer","@type":"Person","name":"movermeyer"},"datePublished":"2017-06-07T14:29:05Z","url":"https://github.com/python/mypy/issues/3505"}
| 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:532fac46-bc8f-39de-892f-b738228aa8db |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 964E:A0638:28D5676:35A316C:6B000A6C |
| html-safe-nonce | 656f30f9bc87635d4b3a34c6eff7fa9c0954d47bd19119e9ef6e3b78e61fdeb7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NjRFOkEwNjM4OjI4RDU2NzY6MzVBMzE2Qzo2QjAwMEE2QyIsInZpc2l0b3JfaWQiOiIyMTE4MTkxMzkzMDE1ODU5ODIwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 2ea10795d6525321fe177d9dc049923c891b67676be4758539eee07fec07858b |
| hovercard-subject-tag | issue:234229074 |
| 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/3505/issue_layout |
| twitter:image | https://opengraph.githubassets.com/feeadf13fd15682418a2214170c702e5f814c8119d5b6977a9e737743246fbf9/python/mypy/issues/3505 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/feeadf13fd15682418a2214170c702e5f814c8119d5b6977a9e737743246fbf9/python/mypy/issues/3505 |
| og:image:alt | I have a file I don't want to add type annotations to (not my code, core.py) and a stub for that file (core.pyi). I would like mypy to check for type issues in the file, pulling in the types from t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | movermeyer |
| 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 | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width