Title: mypy generates `__match_args__` for dataclasses and `NamedTuple`s on Python <3.10 · Issue #12489 · python/mypy · GitHub
Open Graph Title: mypy generates `__match_args__` for dataclasses and `NamedTuple`s on Python <3.10 · Issue #12489 · python/mypy
X Title: mypy generates `__match_args__` for dataclasses and `NamedTuple`s on Python <3.10 · Issue #12489 · python/mypy
Description: Bug Report Not a big deal, but mypy appears to generate __match_args__ for dataclasses and NamedTuples even when running with --python-version set to 3.9: from dataclasses import dataclass from typing import NamedTuple @dataclass class O...
Open Graph Description: Bug Report Not a big deal, but mypy appears to generate __match_args__ for dataclasses and NamedTuples even when running with --python-version set to 3.9: from dataclasses import dataclass from typ...
X Description: Bug Report Not a big deal, but mypy appears to generate __match_args__ for dataclasses and NamedTuples even when running with --python-version set to 3.9: from dataclasses import dataclass from typ...
Opengraph URL: https://github.com/python/mypy/issues/12489
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mypy generates `__match_args__` for dataclasses and `NamedTuple`s on Python \u003c3.10","articleBody":"**Bug Report**\r\n\r\nNot a big deal, but mypy appears to generate `__match_args__` for dataclasses and `NamedTuple`s even when running with `--python-version` set to 3.9:\r\n\r\n```python\r\nfrom dataclasses import dataclass\r\nfrom typing import NamedTuple\r\n\r\n@dataclass\r\nclass One:\r\n bar: int\r\n\r\nf: One\r\nreveal_type(f.__match_args__) # Revealed type is \"Tuple[Literal['bar']]\"\r\n\r\nclass Two(NamedTuple):\r\n baz: str\r\n\r\ng: Two\r\nreveal_type(g.__match_args__) # Revealed type is \"Tuple[Literal['baz']]\"\r\n```\r\n\r\n**Expected Behavior**\r\n\r\nMypy should not autogenerate `__match_args__` when running with `--python-version` set to \u003c3.10, as pattern-matching is new in 3.10.\r\n\r\n**Your Environment**\r\n\r\n- Mypy version used: `0.950+dev.a33d2353a81d075850a487f3913720037f2473aa (compiled: no)`\r\n- Mypy command-line flags: `--python-version 3.9`\r\n- Mypy configuration options from `mypy.ini` (and other config files): None\r\n- Python version used: 3.10\r\n- Operating system and version: Windows\r\n","author":{"url":"https://github.com/AlexWaygood","@type":"Person","name":"AlexWaygood"},"datePublished":"2022-03-29T21:29:14.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/12489/mypy/issues/12489"}
| 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:97bd05c0-a57d-081c-56fd-d817b25e1252 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C6FA:363855:BAC35D:10F0D92:6A574CD8 |
| html-safe-nonce | 0808166025960cab0e437654452b27f3c89871fbcdbbc64485952adc0b9618f8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNkZBOjM2Mzg1NTpCQUMzNUQ6MTBGMEQ5Mjo2QTU3NENEOCIsInZpc2l0b3JfaWQiOiI0MjIyODg4NDg1NDg0ODIyNjQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | aad156504fb7a8de881d61ddd66dc218c6e27c695a455ed98ff01ed0e0163c8d |
| hovercard-subject-tag | issue:1185434549 |
| 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/12489/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9f96f78b460c85e884446cda406c53c1a86d8e868f72abab85b41911ce0a0d44/python/mypy/issues/12489 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9f96f78b460c85e884446cda406c53c1a86d8e868f72abab85b41911ce0a0d44/python/mypy/issues/12489 |
| og:image:alt | Bug Report Not a big deal, but mypy appears to generate __match_args__ for dataclasses and NamedTuples even when running with --python-version set to 3.9: from dataclasses import dataclass from typ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | AlexWaygood |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4e7a7296a3830877cf21a6ad2a972c9e618a48915e03966cf0c53eb08e5aad98 |
| 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 | 602250ea3b6dd8302a7220ef98adb828dbc807e4 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width