ruff/crates
Douglas Creager 4aee0398cb
[ty] Show the raw argument type in reveal_type (#19400)
This PR is changes how `reveal_type` determines what type to reveal, in
a way that should be a no-op to most callers.

Previously, we would reveal the type of the first parameter, _after_ all
of the call binding machinery had done its work. This includes inferring
the specialization of a generic function, and then applying that
specialization to all parameter and argument types, which is relevant
since the typeshed definition of `reveal_type` is generic:

```pyi
def reveal_type(obj: _T, /) -> _T: ...
```

Normally this does not matter, since we infer `_T = [arg type]` and
apply that to the parameter type, yielding `[arg type]`. But applying
that specialization also simplifies the argument type, which makes
`reveal_type` less useful as a debugging aid when we want to see the
actual, raw, unsimplified argument type.

With this patch, we now grab the original unmodified argument type and
reveal that instead.

In addition to making the debugging aid example work, this also makes
our `reveal_type` implementation more robust to custom typeshed
definitions, such as

```py
def reveal_type(obj: Any) -> Any: ...
```

(That custom definition is probably not what anyone would want, since
you wouldn't be able to depend on the return type being equivalent to
the argument type, but still)
2025-07-17 16:50:29 -04:00
..
ruff Canonicalize path before filtering (#19407) 2025-07-17 14:02:17 -04:00
ruff_annotate_snippets Update Rust toolchain to 1.88 and MSRV to 1.86 (#19011) 2025-06-28 20:24:00 +02:00
ruff_benchmark [ty] Enum literal types (#19328) 2025-07-15 21:31:53 +02:00
ruff_cache
ruff_db Move Pylint rendering to ruff_db (#19340) 2025-07-15 10:14:49 -04:00
ruff_dev Auto-generate environment variable references for ty (#19205) 2025-07-08 10:48:31 -04:00
ruff_diagnostics Combine OldDiagnostic and Diagnostic (#19053) 2025-07-03 13:01:09 -04:00
ruff_formatter
ruff_graph Update Rust toolchain to 1.88 and MSRV to 1.86 (#19011) 2025-06-28 20:24:00 +02:00
ruff_index Update Rust toolchain to 1.88 and MSRV to 1.86 (#19011) 2025-06-28 20:24:00 +02:00
ruff_linter Bump 0.12.4 (#19406) 2025-07-17 12:14:01 -05:00
ruff_macros [ty] Merge ty_macros into ruff_macros (#19229) 2025-07-09 11:28:21 +00:00
ruff_notebook
ruff_options_metadata
ruff_python_ast [ty] Use an interval map for scopes by expression (#19025) 2025-07-14 13:50:58 +02:00
ruff_python_ast_integration_tests
ruff_python_codegen Fix f-string interpolation escaping (#18882) 2025-06-25 10:04:15 +02:00
ruff_python_formatter Update pre-commit dependencies (#19162) 2025-07-07 04:07:44 +00:00
ruff_python_index
ruff_python_literal
ruff_python_parser [ty] add support for nonlocal statements 2025-07-11 09:44:54 -07:00
ruff_python_semantic [flake8-return] Fix false-positive for variables used inside nested functions in RET504 (#18433) 2025-07-10 16:10:22 -04:00
ruff_python_stdlib
ruff_python_trivia
ruff_python_trivia_integration_tests
ruff_server Render Azure, JSON, and JSON lines output with the new diagnostics (#19133) 2025-07-11 15:04:46 -04:00
ruff_source_file Move Pylint rendering to ruff_db (#19340) 2025-07-15 10:14:49 -04:00
ruff_text_size [ty] Add environment variable to dump Salsa memory usage stats (#18928) 2025-06-26 21:27:51 +00:00
ruff_wasm Bump 0.12.4 (#19406) 2025-07-17 12:14:01 -05:00
ruff_workspace [flake8-type-checking, pyupgrade, ruff] Add from __future__ import annotations when it would allow new fixes (TC001, TC002, TC003, UP037, RUF013) (#19100) 2025-07-16 08:50:52 -04:00
ty lint on the global keyword if there's no explicit definition in the global scope 2025-07-15 16:56:54 -07:00
ty_ide [ty] Initial implementation of declaration and definition providers. (#19371) 2025-07-16 15:07:24 -07:00
ty_project [ty] publish settings diagnostics (#19335) 2025-07-17 11:57:00 -04:00
ty_python_semantic [ty] Show the raw argument type in reveal_type (#19400) 2025-07-17 16:50:29 -04:00
ty_server [ty] publish settings diagnostics (#19335) 2025-07-17 11:57:00 -04:00
ty_static [ty] Merge ty_macros into ruff_macros (#19229) 2025-07-09 11:28:21 +00:00
ty_test [ty] Make check_file a salsa query (#19255) 2025-07-10 18:46:56 +05:30
ty_vendored [ty] Sync vendored typeshed stubs (#19368) 2025-07-15 18:14:46 +00:00
ty_wasm [ty] Fix server version (#19284) 2025-07-14 09:06:34 +02:00