Title: Not enough type inference in `__init__` with `--check-untyped-defs` · Issue #7309 · python/mypy · GitHub
Open Graph Title: Not enough type inference in `__init__` with `--check-untyped-defs` · Issue #7309 · python/mypy
X Title: Not enough type inference in `__init__` with `--check-untyped-defs` · Issue #7309 · python/mypy
Description: mypy v0.720 using --check-untyped-defs class Foo: pass class A: def __init__(self) self.f1 = Foo() # Any reveal_type(self.f1) self.f2: Foo = Foo() # Foo reveal_type(self.f2) class B: def __init__(self) -> None: self.f1 = Foo() # Foo reve...
Open Graph Description: mypy v0.720 using --check-untyped-defs class Foo: pass class A: def __init__(self) self.f1 = Foo() # Any reveal_type(self.f1) self.f2: Foo = Foo() # Foo reveal_type(self.f2) class B: def __init__(s...
X Description: mypy v0.720 using --check-untyped-defs class Foo: pass class A: def __init__(self) self.f1 = Foo() # Any reveal_type(self.f1) self.f2: Foo = Foo() # Foo reveal_type(self.f2) class B: def __init__(s...
Opengraph URL: https://github.com/python/mypy/issues/7309
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Not enough type inference in `__init__` with `--check-untyped-defs`","articleBody":"mypy v0.720\r\n\r\nusing `--check-untyped-defs`\r\n\r\n```python\r\nclass Foo: pass\r\n\r\nclass A:\r\n def __init__(self) \r\n self.f1 = Foo()\r\n # Any\r\n reveal_type(self.f1)\r\n\r\n self.f2: Foo = Foo()\r\n # Foo\r\n reveal_type(self.f2)\r\n\r\nclass B:\r\n def __init__(self) -> None:\r\n self.f1 = Foo()\r\n # Foo\r\n reveal_type(self.f1)\r\n```\r\n\r\nI would expect `--check-untyped-defs` would make `A` behave like `B`. However, some type inference seems missing if `__init__` is not annotated.","author":{"url":"https://github.com/colinfang","@type":"Person","name":"colinfang"},"datePublished":"2019-08-09T12:18:37Z","url":"https://github.com/python/mypy/issues/7309"}
| 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:d5856952-2c04-c79c-1518-b34d1e43d05a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8572:3E1398:3E160F:537F49:6B002AC2 |
| html-safe-nonce | c148465bd65912d21b7f28e45ffd5b441c46070303af7bd71ae59c3fcab4e273 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NTcyOjNFMTM5ODozRTE2MEY6NTM3RjQ5OjZCMDAyQUMyIiwidmlzaXRvcl9pZCI6IjU1MDkyNjM3MTk5MzQ2NTgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 035d845ebb661bb7f769b8509afe917f5884a35ac7b9acaa197ad21128aba2f7 |
| hovercard-subject-tag | issue:478957774 |
| 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/7309/issue_layout |
| twitter:image | https://opengraph.githubassets.com/72f46d0234b26d4a6410ff435a50014ef0c5a4e7f89ca395823365d8c0930515/python/mypy/issues/7309 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/72f46d0234b26d4a6410ff435a50014ef0c5a4e7f89ca395823365d8c0930515/python/mypy/issues/7309 |
| og:image:alt | mypy v0.720 using --check-untyped-defs class Foo: pass class A: def __init__(self) self.f1 = Foo() # Any reveal_type(self.f1) self.f2: Foo = Foo() # Foo reveal_type(self.f2) class B: def __init__(s... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | colinfang |
| 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