Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

mypy generates __match_args__ for dataclasses and NamedTuples on Python <3.10 #12489

Copy link
Copy link
Closed
@AlexWaygood

Description

@AlexWaygood
Issue body actions

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 One:
    bar: int

f: One
reveal_type(f.__match_args__)  # Revealed type is "Tuple[Literal['bar']]"

class Two(NamedTuple):
    baz: str

g: Two
reveal_type(g.__match_args__)  # Revealed type is "Tuple[Literal['baz']]"

Expected Behavior

Mypy should not autogenerate __match_args__ when running with --python-version set to <3.10, as pattern-matching is new in 3.10.

Your Environment

  • Mypy version used: 0.950+dev.a33d2353a81d075850a487f3913720037f2473aa (compiled: no)
  • Mypy command-line flags: --python-version 3.9
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: 3.10
  • Operating system and version: Windows

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.