ruff
0f5f93b8 - [ty] Determine value vs. type syntax highlighting based on call arguments (#23949)

Commit
51 days ago
[ty] Determine value vs. type syntax highlighting based on call arguments (#23949) ## Summary We now expose a method to determine whether a call argument should be treated as a type form (or not), for the purposes of syntax highlighting. This is more difficult than it may sound, largely due to the existence of overloads and conditional bindings. For example, given the following: ```python from typing import cast from typing_extensions import assert_type func = cast if flag else assert_type ``` The highlighting we want to use for various arguments has to taken into account both the signatures of `cast` and `assert_type`, along with the type of the value provided to the argument. For example, given: ```python f(val=x, typ=int) ``` Both agree that `val=x` is a value, and `typ=int` is a type form. But given: ```python f(x, int) ``` Both match, but disagree: - `cast(x, int)` treats the arguments as `[Type, Value]` - `assert_type(x, int)` treats them as `[Value, Type]` So we treat them both as unknown. Closes https://github.com/astral-sh/ty/issues/3038.
Author
Parents
Loading