Title: spurious "Need type annotation" error with overloads · Issue #4227 · python/mypy · GitHub
Open Graph Title: spurious "Need type annotation" error with overloads · Issue #4227 · python/mypy
X Title: spurious "Need type annotation" error with overloads · Issue #4227 · python/mypy
Description: I'm getting "Need type annotation for variable" errors which I think are the result of a bug with overloads. Stub file overload_test.pyi: from typing import overload, TypeVar, Any _T = TypeVar('_T') @overload def attr(default: _T = ..., ...
Open Graph Description: I'm getting "Need type annotation for variable" errors which I think are the result of a bug with overloads. Stub file overload_test.pyi: from typing import overload, TypeVar, Any _T = TypeVar('_T'...
X Description: I'm getting "Need type annotation for variable" errors which I think are the result of a bug with overloads. Stub file overload_test.pyi: from typing import overload, TypeVar, Any _T ...
Opengraph URL: https://github.com/python/mypy/issues/4227
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"spurious \"Need type annotation\" error with overloads","articleBody":"I'm getting \"Need type annotation for variable\" errors which I think are the result of a bug with overloads.\r\n\r\nStub file `overload_test.pyi`:\r\n\r\n```python\r\nfrom typing import overload, TypeVar, Any\r\n\r\n_T = TypeVar('_T')\r\n\r\n@overload\r\ndef attr(default: _T = ..., blah: int = ...) -> _T: ...\r\n@overload\r\ndef attr(default: Any = ...) -> Any: ...\r\n```\r\n\r\nTest program:\r\n\r\n```python\r\nfrom overload_test import attr\r\n\r\na = attr()\r\nb = attr()\r\n\r\nreveal_type(a)\r\nreveal_type(b)\r\n```\r\n\r\nmypy output:\r\n```\r\ntest.py:3: error: Need type annotation for variable\r\ntest.py:4: error: Need type annotation for variable\r\ntest.py:6: error: Revealed type is 'Any'\r\ntest.py:6: error: Cannot determine type of 'a'\r\ntest.py:7: error: Revealed type is 'Any'\r\ntest.py:7: error: Cannot determine type of 'b'\r\n```\r\n\r\nIt may be interesting to note that if I swap the order of the overloads, the \"Need type annotation for variable\" and \"Cannot determine type\" errors go away. \r\n\r\n","author":{"url":"https://github.com/chadrik","@type":"Person","name":"chadrik"},"datePublished":"2017-11-08T22:52:13Z","url":"https://github.com/python/mypy/issues/4227"}
| 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:56e320ab-d273-8f2e-0f56-594b941c5def |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DBBE:1BAA33:1287705:1862E67:6B00055D |
| html-safe-nonce | c648af8521fdc3856563e373101a0bfc951cac0333cdea53a90e7c8d13cb0d27 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQkJFOjFCQUEzMzoxMjg3NzA1OjE4NjJFNjc6NkIwMDA1NUQiLCJ2aXNpdG9yX2lkIjoiMTYyNDQ5NzM4NzgxMDU4Nzk5NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 324ef38549282103b19951ab19199717214b23ead55ff7501a4cba981fe2007e |
| hovercard-subject-tag | issue:272379025 |
| 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/4227/issue_layout |
| twitter:image | https://opengraph.githubassets.com/23b0792005bddd21d78c205507b2cc41c8752238647160ce5e3e37d3e02a2bb6/python/mypy/issues/4227 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/23b0792005bddd21d78c205507b2cc41c8752238647160ce5e3e37d3e02a2bb6/python/mypy/issues/4227 |
| og:image:alt | I'm getting "Need type annotation for variable" errors which I think are the result of a bug with overloads. Stub file overload_test.pyi: from typing import overload, TypeVar, Any _T = TypeVar('_T'... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | chadrik |
| 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