Skip to content

Conversation

@sharkdp
Copy link
Contributor

@sharkdp sharkdp commented Nov 19, 2025

Summary

Add a set of comprehensive tests for generic implicit type aliases to illustrate the current behavior with many flavors of @Todo types and false positive diagnostics.

The tests are partially based on the typing conformance suite, and the expected behavior has been checked against other type checkers.

@sharkdp sharkdp added the ty Multi-file analysis & type inference label Nov 19, 2025
@sharkdp sharkdp marked this pull request as ready for review November 19, 2025 13:11
@AlexWaygood AlexWaygood added the testing Related to testing Ruff itself label Nov 19, 2025
Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent!

@AlexWaygood
Copy link
Member

I guess one pathological case you could add would be something like

from typing import TypeVar

T = TypeVar("T")
U = TypeVar("U")
S = TypeVar("S")

A = dict[T, U]
B = A[int, S]

def f(x: B[str]):
    reveal_type(x)  # revealed: dict[int, str]

@sharkdp
Copy link
Contributor Author

sharkdp commented Nov 19, 2025

I guess one pathological case

Doesn't seem too pathological. I'll add something like this.

@sharkdp sharkdp enabled auto-merge (squash) November 19, 2025 14:01
@sharkdp sharkdp merged commit 5dd5626 into main Nov 19, 2025
37 checks passed
@sharkdp sharkdp deleted the david/generic-implicit-aliases-tests branch November 19, 2025 14:06
dcreager added a commit that referenced this pull request Nov 19, 2025
* origin/main:
  [ty] Fix flaky tests on macos (#21524)
  [ty] Add tests for generic implicit type aliases (#21522)
  [ty] Semantic tokens: consistently add the `DEFINITION` modifier (#21521)
  Only render hyperlinks for terminals known to support them (#21519)
  [ty] Keep colorizing `mypy_primer` output (#21515)
  [ty] Exit with `2` if there's any IO error (#21508)
  [`ruff`] Fix false positive for complex conversion specifiers in `logging-eager-conversion` (`RUF065`) (#21464)
  [ty] tighten up handling of subscripts in type expressions (#21503)
dcreager added a commit that referenced this pull request Nov 19, 2025
* origin/main:
  [ty] Fix flaky tests on macos (#21524)
  [ty] Add tests for generic implicit type aliases (#21522)
  [ty] Semantic tokens: consistently add the `DEFINITION` modifier (#21521)
  Only render hyperlinks for terminals known to support them (#21519)
  [ty] Keep colorizing `mypy_primer` output (#21515)
  [ty] Exit with `2` if there's any IO error (#21508)
  [`ruff`] Fix false positive for complex conversion specifiers in `logging-eager-conversion` (`RUF065`) (#21464)
  [ty] tighten up handling of subscripts in type expressions (#21503)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Related to testing Ruff itself ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants