Title: Mypy doesn't catch error due to using attribute befor defining it · Issue #7756 · python/mypy · GitHub
Open Graph Title: Mypy doesn't catch error due to using attribute befor defining it · Issue #7756 · python/mypy
X Title: Mypy doesn't catch error due to using attribute befor defining it · Issue #7756 · python/mypy
Description: Consider this code: from typing import List class Foo: def __init__(self) -> None: self.bar() self.foo: List[int] = [] def bar(self) -> None: self.foo.append(3) if __name__ == "__main__": foo = Foo() Following code raise AttributeError b...
Open Graph Description: Consider this code: from typing import List class Foo: def __init__(self) -> None: self.bar() self.foo: List[int] = [] def bar(self) -> None: self.foo.append(3) if __name__ == "__main__": foo = Foo...
X Description: Consider this code: from typing import List class Foo: def __init__(self) -> None: self.bar() self.foo: List[int] = [] def bar(self) -> None: self.foo.append(3) if __name__ == "__main__&...
Opengraph URL: https://github.com/python/mypy/issues/7756
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Mypy doesn't catch error due to using attribute befor defining it ","articleBody":"Consider this code: \r\n\r\n```\r\nfrom typing import List\r\n\r\nclass Foo:\r\n\r\n def __init__(self) -> None:\r\n self.bar()\r\n self.foo: List[int] = []\r\n\r\n def bar(self) -> None:\r\n self.foo.append(3)\r\n\r\nif __name__ == \"__main__\":\r\n foo = Foo()\r\n```\r\n\r\nFollowing code raise `AttributeError` but Mypy consider it valid:\r\n```\r\n$ mypy foo.py --strict\r\nSuccess: no issues found in 1 source file\r\n```","author":{"url":"https://github.com/h8hawk","@type":"Person","name":"h8hawk"},"datePublished":"2019-10-20T16:51:22Z","url":"https://github.com/python/mypy/issues/7756"}
| 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:03873144-7210-ed55-2ae8-7efa5341b17c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C6D8:1DA187:3392195:44543E6:6B003860 |
| html-safe-nonce | 6ed08dcbeb86b7331720ebc19f80706d2ec7b40e4e43819c45a12fa7073234fe |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNkQ4OjFEQTE4NzozMzkyMTk1OjQ0NTQzRTY6NkIwMDM4NjAiLCJ2aXNpdG9yX2lkIjoiNDI4MDY5OTIxNDU3NDQwMTYzMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c0cdbd1eb93237fd4e02a12b5f74007a98b1b9da88b924ae75e837ed830fa423 |
| hovercard-subject-tag | issue:509620522 |
| 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/7756/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9b551af0e0956af70ef758cf1a121aa86bbb717d61b49bb33fa46ce8da08f8e6/python/mypy/issues/7756 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9b551af0e0956af70ef758cf1a121aa86bbb717d61b49bb33fa46ce8da08f8e6/python/mypy/issues/7756 |
| og:image:alt | Consider this code: from typing import List class Foo: def __init__(self) -> None: self.bar() self.foo: List[int] = [] def bar(self) -> None: self.foo.append(3) if __name__ == "__main__": foo = Foo... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | h8hawk |
| 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