Title: mypy fails to report missing "private" __x attribute · Issue #8267 · python/mypy · GitHub
Open Graph Title: mypy fails to report missing "private" __x attribute · Issue #8267 · python/mypy
X Title: mypy fails to report missing "private" __x attribute · Issue #8267 · python/mypy
Description: Mypy doesn't seem to grok that self.__x in a subclass is different from self.__x in a superclass. It also doesn't seem to understand order of initialization. Are you reporting a bug, or opening a feature request? bug Please insert below ...
Open Graph Description: Mypy doesn't seem to grok that self.__x in a subclass is different from self.__x in a superclass. It also doesn't seem to understand order of initialization. Are you reporting a bug, or opening a f...
X Description: Mypy doesn't seem to grok that self.__x in a subclass is different from self.__x in a superclass. It also doesn't seem to understand order of initialization. Are you reporting a bug, or ope...
Opengraph URL: https://github.com/python/mypy/issues/8267
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mypy fails to report missing \"private\" __x attribute","articleBody":"Mypy doesn't seem to grok that `self.__x` in a subclass is different from `self.__x` in a superclass. It also doesn't seem to understand order of initialization.\r\n\r\n> * Are you reporting a bug, or opening a feature request?\r\n\r\nbug\r\n\r\n> * Please insert below the code you are checking with mypy\r\n\r\n```py\r\nclass A:\r\n def __init__(self, x: int) -> None:\r\n self.__x = x # replace this with pass and mypy reports the error\r\n\r\n\r\nclass B(A):\r\n def __init__(self) -> None:\r\n A.__init__(self, self.__x)\r\n\r\n\r\nB()\r\n```\r\n\r\n> * What is the actual behavior/output?\r\n\r\n```\r\n$ mypy --strict tytest.py \r\nSuccess: no issues found in 1 source file\r\n$ python tytest.py \r\nTraceback (most recent call last):\r\n File \"tytest.py\", line 11, in \u003cmodule>\r\n B()\r\n File \"tytest.py\", line 8, in __init__\r\n A.__init__(self, self.__x)\r\nAttributeError: 'B' object has no attribute '_B__x\r\n```\r\n\r\n> * What is the behavior/output you expect?\r\n\r\nmypy should report:\r\n\r\n`tytest.py:8: error: \"B\" has no attribute \"__x`\r\n\r\n> * What are the versions of mypy and Python you are using?\r\n\r\nmypy 0.700\r\n\r\n> Do you see the same issue after installing mypy from Git master?\r\n\r\nyes (`mypy-0.770+dev.01ca4e062e38a9db8f462b9464fbbd5dd945a8cf`)\r\n\r\n> * What are the mypy flags you are using? (For example --strict-optional)\r\n`--strict`\r\n","author":{"url":"https://github.com/dckc","@type":"Person","name":"dckc"},"datePublished":"2020-01-09T18:31:23Z","url":"https://github.com/python/mypy/issues/8267"}
| 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:7f5711b7-91cb-64e0-bd00-ca5306b14951 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B750:C5FC2:1CBD338:25F4DBA:6B0038A9 |
| html-safe-nonce | e4e52296cd7af358dc45755219f19a3336efe2e89dfca1a153a6fd6f43f24922 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNzUwOkM1RkMyOjFDQkQzMzg6MjVGNERCQTo2QjAwMzhBOSIsInZpc2l0b3JfaWQiOiI2OTk0NDIzNzQwMTk2OTkzMTkzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 02207c6c652467be8fd8663289a9130f32adc4c3084cf4c3db927f287e11691c |
| hovercard-subject-tag | issue:547647351 |
| 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/8267/issue_layout |
| twitter:image | https://opengraph.githubassets.com/98869b3374e75a022272295eac36291a504122eaa1c87a17b20f6713eb81f967/python/mypy/issues/8267 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/98869b3374e75a022272295eac36291a504122eaa1c87a17b20f6713eb81f967/python/mypy/issues/8267 |
| og:image:alt | Mypy doesn't seem to grok that self.__x in a subclass is different from self.__x in a superclass. It also doesn't seem to understand order of initialization. Are you reporting a bug, or opening a f... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dckc |
| 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