ruff/crates
David Peter e6ddeed386
[ty] Default-specialization of generic type aliases (#21765)
## Summary

Implement default-specialization of generic type aliases (implicit or
PEP-613) if they are used in a type expression without an explicit
specialization.

closes https://github.com/astral-sh/ty/issues/1690

## Typing conformance

```diff
-generics_defaults_specialization.py:26:5: error[type-assertion-failure] Type `SomethingWithNoDefaults[int, str]` does not match asserted type `SomethingWithNoDefaults[int, DefaultStrT]`
```

That's exactly what we want ✔️ 

All other tests in this file pass as well, with the exception of this
assertion, which is just wrong (at least according to our
interpretation, `type[Bar] != <class 'Bar'>`). I checked that we do
correctly default-specialize the type parameter which is not displayed
in the diagnostic that we raise.
```py
class Bar(SubclassMe[int, DefaultStrT]): ...

assert_type(Bar, type[Bar[str]])  # ty: Type `type[Bar[str]]` does not match asserted type `<class 'Bar'>`
```

## Ecosystem impact

Looks like I should have included this last week 😎 

## Test Plan

Updated pre-existing tests and add a few new ones.
2025-12-03 09:10:45 +01:00
..
ruff Bump 0.14.7 (#21684) 2025-11-28 14:34:27 -06:00
ruff_annotate_snippets Only render hyperlinks for terminals known to support them (#21519) 2025-11-19 10:02:58 +01:00
ruff_benchmark Move Token, TokenKind and Tokens to ruff-python-ast (#21760) 2025-12-02 20:10:46 +01:00
ruff_cache
ruff_db [ty] Don't introduce invalid syntax when autofixing override-of-final-method (#21699) 2025-11-30 13:40:33 +00:00
ruff_dev Update Rust toolchain to 1.91 (#21179) 2025-11-01 01:50:58 +00:00
ruff_diagnostics [ty] Add code action to ignore diagnostic on the current line (#21595) 2025-11-29 15:41:54 +01:00
ruff_formatter [ty] Use "cannot" consistently over "can not" (#21255) 2025-11-03 10:38:20 -05:00
ruff_graph analyze: Add option to skip over imports in TYPE_CHECKING blocks (#21472) 2025-11-16 12:30:24 +00:00
ruff_index
ruff_linter [syntax-error] Default type parameter followed by non-default type parameter (#21657) 2025-12-03 12:01:31 +05:30
ruff_macros Document when a rule was added (#21035) 2025-10-23 14:48:41 -04:00
ruff_memory_usage
ruff_notebook [ty] Respect notebook cell boundaries when adding an auto import (#21322) 2025-11-13 18:58:08 +01:00
ruff_options_metadata
ruff_python_ast Move Token, TokenKind and Tokens to ruff-python-ast (#21760) 2025-12-02 20:10:46 +01:00
ruff_python_ast_integration_tests
ruff_python_codegen Move Token, TokenKind and Tokens to ruff-python-ast (#21760) 2025-12-02 20:10:46 +01:00
ruff_python_formatter Move Token, TokenKind and Tokens to ruff-python-ast (#21760) 2025-12-02 20:10:46 +01:00
ruff_python_importer Move Token, TokenKind and Tokens to ruff-python-ast (#21760) 2025-12-02 20:10:46 +01:00
ruff_python_index Move Token, TokenKind and Tokens to ruff-python-ast (#21760) 2025-12-02 20:10:46 +01:00
ruff_python_literal
ruff_python_parser [syntax-error] Default type parameter followed by non-default type parameter (#21657) 2025-12-03 12:01:31 +05:30
ruff_python_semantic Add rule to detect unnecessary class properties (#21535) 2025-11-26 09:31:22 +01:00
ruff_python_stdlib
ruff_python_trivia
ruff_python_trivia_integration_tests
ruff_server Set severity for non-rule diagnostics (#21559) 2025-11-21 17:42:35 +01:00
ruff_source_file
ruff_text_size [ty] Fix subtraction overflow bug 2025-11-21 15:07:37 -05:00
ruff_wasm Bump 0.14.7 (#21684) 2025-11-28 14:34:27 -06:00
ruff_workspace analyze: Add option to skip over imports in TYPE_CHECKING blocks (#21472) 2025-11-16 12:30:24 +00:00
ty [ty] Improve diagnostics for unsupported comparison operations (#21737) 2025-12-02 19:58:45 +00:00
ty_combine
ty_completion_eval [ty] Exclude typing_extensions from completions unless it's really available 2025-12-01 11:24:16 -05:00
ty_ide Move Token, TokenKind and Tokens to ruff-python-ast (#21760) 2025-12-02 20:10:46 +01:00
ty_project [ty] Fix --exclude and src.exclude merging (#21341) 2025-11-10 12:52:45 +01:00
ty_python_semantic [ty] Default-specialization of generic type aliases (#21765) 2025-12-03 09:10:45 +01:00
ty_server [ty] Fix auto-import code action to handle pre-existing import 2025-12-01 14:20:47 -05:00
ty_static
ty_test [ty] add tests for workspaces (#21741) 2025-12-02 06:43:41 -05:00
ty_vendored [ty] Create a specialization from a constraint set (#21414) 2025-11-19 14:20:33 -05:00
ty_wasm [ty] Add code action to ignore diagnostic on the current line (#21595) 2025-11-29 15:41:54 +01:00