mirror of https://github.com/astral-sh/ruff
Refs https://github.com/astral-sh/ty/issues/544 ## Summary Takes a more incremental approach to PEP 613 type alias support (vs https://github.com/astral-sh/ruff/pull/20107). Instead of eagerly inferring the RHS of a PEP 613 type alias as a type expression, infer it as a value expression, just like we do for implicit type aliases, taking advantage of the same support for e.g. unions and other type special forms. The main reason I'm following this path instead of the one in https://github.com/astral-sh/ruff/pull/20107 is that we've realized that people do sometimes use PEP 613 type aliases as values, not just as types (because they are just a normal runtime assignment, unlike PEP 695 type aliases which create an opaque `TypeAliasType`). This PR doesn't yet provide full support for recursive type aliases (they don't panic, but they just fall back to `Unknown` at the recursion point). This is future work. ## Test Plan Added mdtests. Many new ecosystem diagnostics, mostly because we understand new types in lots of places. Conformance suite changes are correct. Performance regression is due to understanding lots of new types; nothing we do in this PR is inherently expensive. |
||
|---|---|---|
| .. | ||
| annotation.md | ||
| builtins.md | ||
| callable_instance.md | ||
| callables_as_descriptors.md | ||
| constructor.md | ||
| dunder.md | ||
| dunder_import.md | ||
| function.md | ||
| getattr_static.md | ||
| invalid_syntax.md | ||
| methods.md | ||
| never.md | ||
| open.md | ||
| overloads.md | ||
| replace.md | ||
| str_startswith.md | ||
| subclass_of.md | ||
| union.md | ||