Skip to content

unexpected "var-annotated" when using constrained TypeVar #19618

@asottile-sentry

Description

@asottile-sentry

Bug Report

I expect to not need to annotate the example below

To Reproduce

class C[T: (int, str)]:
    def __init__(self, x: T) -> None:
        self.x = x

Expected Behavior

no errors

Actual Behavior

$ ./venv/bin/mypy t.py
t.py:3: error: Need type annotation for "x"  [var-annotated]

Your Environment

  • Mypy version used: 1.17.1
  • Mypy command-line flags: n/a
  • Mypy configuration options from mypy.ini (and other config files): n/a
  • Python version used: 3.13.1

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions