Skip to content

mypy should error about missing type vars in explicit type aliases #18394

Open
@A5rocks

Description

Bug Report

Explicit type aliases don't allow no-args for generics, but don't error about it either.

To Reproduce

from typing import Generic, TypeVar
from typing_extensions import TypeAlias

T = TypeVar("T")
class Y(Generic[T]): ...

Alias2a = Y
reveal_type(Alias2a)  # N: Revealed type is "def [T] () -> __main__.Y[T`1]"

Alias2b: TypeAlias = Y
reveal_type(Alias2b)  # N: Revealed type is "def () -> __main__.Y[Any]"

Expected Behavior

An error when defining Alias2b.

Actual Behavior

No error when defining Alias2b.

Your Environment

Checked on mypy playground.

  • Mypy version used: v1.14
  • Mypy command-line flags: --disallow-any-generics
  • Mypy configuration options from mypy.ini (and other config files): N/A
  • Python version used: 3.12

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions