Title: How to typecheck "2nd" party packages? · Issue #3350 · python/mypy · GitHub
Open Graph Title: How to typecheck "2nd" party packages? · Issue #3350 · python/mypy
X Title: How to typecheck "2nd" party packages? · Issue #3350 · python/mypy
Description: Let's say we have two separate packages, a and b. b depends on stuff in a, so a is installed when b is installed. E.g., there's a module in b that does the following: # b/module.py import a.util def foo(var: str) -> str: ... def bar() ->...
Open Graph Description: Let's say we have two separate packages, a and b. b depends on stuff in a, so a is installed when b is installed. E.g., there's a module in b that does the following: # b/module.py import a.util de...
X Description: Let's say we have two separate packages, a and b. b depends on stuff in a, so a is installed when b is installed. E.g., there's a module in b that does the following: # b/module.py import a...
Opengraph URL: https://github.com/python/mypy/issues/3350
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"How to typecheck \"2nd\" party packages?","articleBody":"Let's say we have two separate packages, `a` and `b`. `b` depends on stuff in `a`, so `a` is installed when `b` is installed. E.g., there's a module in `b` that does the following:\r\n\r\n```python\r\n# b/module.py\r\nimport a.util\r\n\r\ndef foo(var: str) -> str: ...\r\n\r\ndef bar() -> None:\r\n mystr = a.util.func_that_returns_str()\r\n print(foo(mystr))\r\n```\r\n```python\r\n# a/util.py\r\ndef func_that_returns_str() -> str: ...\r\n```\r\n\r\nIf I run `mypy` on `b/module.py` I will get the following error: `error: Cannot find module named 'a'`, even though `a` is installed in my virtualenv.\r\n\r\nAs I understand it, this is the intended behavior, and the solution is to either append `--ignore-missing-imports` or add stubs to typeshed.\r\n\r\nThe problem in our case is that \r\n* `a` is a private package we have developed for our own internal use, so typeshed is not an option\r\n* `mypy --ignore-missing-imports b/module.py` will not be able to verify that `module.bar` correctly calls `module.foo` \r\n* attempting to add my virtualenv's packages to `MYPYPATH` seems to be [highly discouraged](http://mypy.readthedocs.io/en/latest/basics.html), and is also not a great option because `b` might also depend on and install 3rd party stuff that isn't properly type hinted\r\n\r\nSo basically, my question is this: *How can we tell mypy to include the imported package `a` when typechecking `b`?*\r\n\r\nI suppose we could add `.pyi` stubs for `a` inside the `b` repository and point `MYPYPATH` there, but that is suboptimal as it would require us to maintain the API for `a` in two separate repositories, and entirely unnecessary since everything in `a` is already properly type hinted.","author":{"url":"https://github.com/eddie-dunn","@type":"Person","name":"eddie-dunn"},"datePublished":"2017-05-10T08:52:12Z","url":"https://github.com/python/mypy/issues/3350"}
| 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:6b7bf986-41c7-0cf7-d48b-efa4c3e239b4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CEBE:1756E4:195AF24:2173910:6B002D46 |
| html-safe-nonce | 560f182f9b30c73a6549d119d3ea85a25aac58bf5479814cb3144aab059c808e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRUJFOjE3NTZFNDoxOTVBRjI0OjIxNzM5MTA6NkIwMDJENDYiLCJ2aXNpdG9yX2lkIjoiNTIwMTA4Njc0NDQ4NDY1NDQwNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 6508b808f39c2851472c9eb7c2a55238c9901f7028e40074fc357ca8636fdebf |
| hovercard-subject-tag | issue:227609244 |
| 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/3350/issue_layout |
| twitter:image | https://opengraph.githubassets.com/79f573b0a74da7c8535825409b7126608759f731dc5ef564b755da2a747bc37f/python/mypy/issues/3350 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/79f573b0a74da7c8535825409b7126608759f731dc5ef564b755da2a747bc37f/python/mypy/issues/3350 |
| og:image:alt | Let's say we have two separate packages, a and b. b depends on stuff in a, so a is installed when b is installed. E.g., there's a module in b that does the following: # b/module.py import a.util de... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | eddie-dunn |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width