Title: @overload cannot be used with conditional "if TYPE_CHECKING" · Issue #9744 · python/mypy · GitHub
Open Graph Title: @overload cannot be used with conditional "if TYPE_CHECKING" · Issue #9744 · python/mypy
X Title: @overload cannot be used with conditional "if TYPE_CHECKING" · Issue #9744 · python/mypy
Description: Bug Report The handling of @overload decorators happens in (code) blocks only, which makes it not find the implementation when using: from typing import overload from typing import TYPE_CHECKING from typing import Union class K: if TYPE_...
Open Graph Description: Bug Report The handling of @overload decorators happens in (code) blocks only, which makes it not find the implementation when using: from typing import overload from typing import TYPE_CHECKING fr...
X Description: Bug Report The handling of @overload decorators happens in (code) blocks only, which makes it not find the implementation when using: from typing import overload from typing import TYPE_CHECKING fr...
Opengraph URL: https://github.com/python/mypy/issues/9744
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"@overload cannot be used with conditional \"if TYPE_CHECKING\"","articleBody":"**Bug Report**\r\n\r\nThe handling of `@overload` decorators happens in (code) blocks only, which makes it not find the implementation when using:\r\n```python\r\nfrom typing import overload\r\nfrom typing import TYPE_CHECKING\r\nfrom typing import Union\r\n\r\n\r\nclass K:\r\n if TYPE_CHECKING:\r\n @overload\r\n def foo(self, arg: int) -> int:\r\n ...\r\n\r\n @overload\r\n def foo(self, arg: str) -> str:\r\n ...\r\n\r\n def foo(self, arg: Union[int, str]) -> Union[int, str]:\r\n ...\r\n```\r\n\r\n```\r\nt-overload.py:8: error: An overloaded function outside a stub file must have an implementation [misc]\r\nt-overload.py:16: error: Name 'foo' already defined on line 8 [no-redef]\r\nFound 2 errors in 1 file (checked 1 source file)\r\n```\r\n\r\nI think it would be nice / feasible to merge `if TYPE_CHECKING` blocks maybe, so that the parser would handle it together?\r\n\r\nmypy 0.800+dev.6e99a2db100d794b1bf900746470527cd03fce16","author":{"url":"https://github.com/blueyed","@type":"Person","name":"blueyed"},"datePublished":"2020-11-22T17:54:23Z","url":"https://github.com/python/mypy/issues/9744"}
| 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:584dbc0b-ca76-4e9a-4c65-2acd8fc93669 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E536:30DBED:31973C5:415C52B:6B002942 |
| html-safe-nonce | 2d056896bcf9250d15681839a92b08ed65e9ec39fe7fa7d6ef58eaaa7f8701d9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNTM2OjMwREJFRDozMTk3M0M1OjQxNUM1MkI6NkIwMDI5NDIiLCJ2aXNpdG9yX2lkIjoiNTE0MTg4NzE4MzAxOTMyMTY2NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 79b31d2eff9b25e8e3c67f3f0ae3c3f89bd98def6ff8f268c646080e7484c30b |
| hovercard-subject-tag | issue:748303423 |
| 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/9744/issue_layout |
| twitter:image | https://opengraph.githubassets.com/64cd1c5547cb371c2c0ecd08647edcd9894eea1909d31d1bcd5963b01f889f9d/python/mypy/issues/9744 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/64cd1c5547cb371c2c0ecd08647edcd9894eea1909d31d1bcd5963b01f889f9d/python/mypy/issues/9744 |
| og:image:alt | Bug Report The handling of @overload decorators happens in (code) blocks only, which makes it not find the implementation when using: from typing import overload from typing import TYPE_CHECKING fr... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | blueyed |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| 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 | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width