mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:04 +00:00
[ty] Support typing.TypeAliasType
(#18156)
## Summary Support direct uses of `typing.TypeAliasType`, as in: ```py from typing import TypeAliasType IntOrStr = TypeAliasType("IntOrStr", int | str) def f(x: IntOrStr) -> None: reveal_type(x) # revealed: int | str ``` closes https://github.com/astral-sh/ty/issues/392 ## Ecosystem The new false positive here: ```diff + error[invalid-type-form] altair/utils/core.py:49:53: The first argument to `Callable` must be either a list of types, ParamSpec, Concatenate, or `...` ``` comes from the fact that we infer the second argument as a type expression now. We silence false positives for PEP695 `ParamSpec`s, but not for `P = ParamSpec("P")` inside `Callable[P, ...]`. ## Test Plan New Markdown tests
This commit is contained in:
parent
220137ca7b
commit
4c889d5251
8 changed files with 347 additions and 74 deletions
|
@ -294,4 +294,8 @@ impl SourceOrderVisitor<'_> for PullTypesVisitor<'_> {
|
|||
|
||||
/// Whether or not the .py/.pyi version of this file is expected to fail
|
||||
#[rustfmt::skip]
|
||||
const KNOWN_FAILURES: &[(&str, bool, bool)] = &[];
|
||||
const KNOWN_FAILURES: &[(&str, bool, bool)] = &[
|
||||
// Fails with too-many-cycle-iterations due to a self-referential
|
||||
// type alias, see https://github.com/astral-sh/ty/issues/256
|
||||
("crates/ruff_linter/resources/test/fixtures/pyflakes/F401_34.py", true, true),
|
||||
];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue