Title: false-positive `name-defined` regression with dataclasses and shadowing · Issue #12907 · python/mypy · GitHub
Open Graph Title: false-positive `name-defined` regression with dataclasses and shadowing · Issue #12907 · python/mypy
X Title: false-positive `name-defined` regression with dataclasses and shadowing · Issue #12907 · python/mypy
Description: Bug Report This file: from dataclasses import dataclass import collections @dataclass class Shadow: collections: collections.deque other: collections.defaultdict print(Shadow(collections.deque(), collections.defaultdict())) is perhaps a ...
Open Graph Description: Bug Report This file: from dataclasses import dataclass import collections @dataclass class Shadow: collections: collections.deque other: collections.defaultdict print(Shadow(collections.deque(), c...
X Description: Bug Report This file: from dataclasses import dataclass import collections @dataclass class Shadow: collections: collections.deque other: collections.defaultdict print(Shadow(collections.deque(), c...
Opengraph URL: https://github.com/python/mypy/issues/12907
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"false-positive `name-defined` regression with dataclasses and shadowing","articleBody":"**Bug Report**\r\n\r\nThis file:\r\n\r\n```python\r\nfrom dataclasses import dataclass\r\nimport collections\r\n\r\n\r\n@dataclass\r\nclass Shadow:\r\n\r\n collections: collections.deque\r\n other: collections.defaultdict\r\n\r\n\r\nprint(Shadow(collections.deque(), collections.defaultdict()))\r\n```\r\n\r\nis perhaps a bit unorthodox, but runs fine, because the `collections: ...` doesn't actually shadow the module when defining `other`.\r\n\r\n**Actual Behavior**\r\n\r\nmypy v0.950 was happy with it, but mypy v0.960 claims that:\r\n\r\n```\r\ntest.py:9: error: Name \"collections.defaultdict\" is not defined\r\n```\r\n\r\n**Introducing commit**\r\n\r\nBisected to 03901ef657daf6f477e6fe933c42ac270cf5034b (\"Running dataclass transform in a later pass to fix crashes (#12762)\", @JukkaL)\r\n\r\n**Your Environment**\r\n\r\n- Mypy version used: v0.960\r\n- Mypy command-line flags: none\r\n- Mypy configuration options from `mypy.ini` (and other config files): none\r\n- Python version used: 3.10.4\r\n- Operating system and version: Archlinux","author":{"url":"https://github.com/The-Compiler","@type":"Person","name":"The-Compiler"},"datePublished":"2022-05-30T08:32:49Z","url":"https://github.com/python/mypy/issues/12907"}
| 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:b80aa8d6-1d27-05f5-2ba2-2e25036102e9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9B0A:1D7BA0:21D263:2DF0FA:6B0022A5 |
| html-safe-nonce | 1a0c6f74c9e0407ad7cdff44204dbf343d6dc28bfd6203a454474c50529c1d93 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QjBBOjFEN0JBMDoyMUQyNjM6MkRGMEZBOjZCMDAyMkE1IiwidmlzaXRvcl9pZCI6IjQzNzYxMjg1NDc0NjMzNzM0NzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6757cb03cbd05d8df0e937b5a63bc16c44cd5cbfc978e6ac9d9575aa1baff4f5 |
| hovercard-subject-tag | issue:1252386655 |
| 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/12907/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3794b044e8886c714b025519a7275d06c7ab20687982305232499e254ab9dc63/python/mypy/issues/12907 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3794b044e8886c714b025519a7275d06c7ab20687982305232499e254ab9dc63/python/mypy/issues/12907 |
| og:image:alt | Bug Report This file: from dataclasses import dataclass import collections @dataclass class Shadow: collections: collections.deque other: collections.defaultdict print(Shadow(collections.deque(), c... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | The-Compiler |
| 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