Title: Allow overriding own code with stubs · Issue #2502 · python/mypy · GitHub
Open Graph Title: Allow overriding own code with stubs · Issue #2502 · python/mypy
X Title: Allow overriding own code with stubs · Issue #2502 · python/mypy
Description: mypy currently has a bit of trouble with some of the more complicated types out there, especially when it comes to metaprogramming. It would be pretty useful if I can provide a stub that would override a class defined in my own code, in ...
Open Graph Description: mypy currently has a bit of trouble with some of the more complicated types out there, especially when it comes to metaprogramming. It would be pretty useful if I can provide a stub that would over...
X Description: mypy currently has a bit of trouble with some of the more complicated types out there, especially when it comes to metaprogramming. It would be pretty useful if I can provide a stub that would over...
Opengraph URL: https://github.com/python/mypy/issues/2502
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Allow overriding own code with stubs","articleBody":"\r\nmypy currently has a bit of trouble with some of the more complicated types out there, especially when it comes to metaprogramming.\r\n\r\n It would be pretty useful if I can provide a stub that would override a class defined in my own code, in cases where mypy fails to generate the proper type for a class. \r\n\r\nFor example, have a file like:\r\n\r\n```\r\n# mypy: ignore-type\r\nclass C:
\r\n a = 3\r\n\r\n
def f(c: C) -> str:
\r\n return c.a \r\n```\r\n\r\nwith the stub file being:\r\n\r\n```\r\nclass C:
\r\n a = ... # type: str\r\n```\r\n\r\n(Here f would type check because the type lookup for C would happen through the stub, not the implementation)\r\n\r\nThis will let some people properly type complex objects generated by tools like ORMs.\r\n\r\nI tried simply providing a stub for C along with the implementation, but currently it seems like the implementation's type inference works here.\r\n\r\n\r\n","author":{"url":"https://github.com/rtpg","@type":"Person","name":"rtpg"},"datePublished":"2016-11-28T15:50:09Z","url":"https://github.com/python/mypy/issues/2502"}
| 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:1f151183-4626-389d-7d15-9fd0be27460c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CCBA:34D604:11D24AC:175AF6C:6B000A43 |
| html-safe-nonce | d50025173ab43a92062de9c71b09f938007a2f5de4424b53eb71dd17b72f2c20 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQ0JBOjM0RDYwNDoxMUQyNEFDOjE3NUFGNkM6NkIwMDBBNDMiLCJ2aXNpdG9yX2lkIjoiODUxNTY5ODAyOTcwMzk4OTgyNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 3f346ab62b5490eda3cb7a264b398dbc54c8c84c42a4802988e9dca832ab9739 |
| hovercard-subject-tag | issue:192040827 |
| 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/2502/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2a7d0ee56c329583fe9ebc14e3b4c5c7ddb0dd60b1717c1c2860cdccf0958410/python/mypy/issues/2502 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2a7d0ee56c329583fe9ebc14e3b4c5c7ddb0dd60b1717c1c2860cdccf0958410/python/mypy/issues/2502 |
| og:image:alt | mypy currently has a bit of trouble with some of the more complicated types out there, especially when it comes to metaprogramming. It would be pretty useful if I can provide a stub that would over... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rtpg |
| 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