Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
A5rocks opened this issue Dec 31, 2024 · 0 comments
Open

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

A5rocks opened this issue Dec 31, 2024 · 0 comments
Labels
bug mypy got something wrong topic-type-alias TypeAlias and other type alias issues

Comments

@A5rocks
Copy link
Contributor

A5rocks commented Dec 31, 2024

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
@A5rocks A5rocks added the bug mypy got something wrong label Dec 31, 2024
@brianschubert brianschubert added the topic-type-alias TypeAlias and other type alias issues label Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-type-alias TypeAlias and other type alias issues
Projects
None yet
Development

No branches or pull requests

2 participants