ruff/crates
Douglas Creager 7673d46b71
[ty] Splat variadic arguments into parameter list (#18996)
This PR updates our call binding logic to handle splatted arguments.

Complicating matters is that we have separated call bind analysis into
two phases: parameter matching and type checking. Parameter matching
looks at the arity of the function signature and call site, and assigns
arguments to parameters. Importantly, we don't yet know the type of each
argument! This is needed so that we can decide whether to infer the type
of each argument as a type form or value form, depending on the
requirements of the parameter that the argument was matched to.

This is an issue when splatting an argument, since we need to know how
many elements the splatted argument contains to know how many positional
parameters to match it against. And to know how many elements the
splatted argument has, we need to know its type.

To get around this, we now make the assumption that splatted arguments
can only be used with value-form parameters. (If you end up splatting an
argument into a type-form parameter, we will silently pass in its
value-form type instead.) That allows us to preemptively infer the
(value-form) type of any splatted argument, so that we have its arity
available during parameter matching. We defer inference of non-splatted
arguments until after parameter matching has finished, as before.

We reuse a lot of the new tuple machinery to make this happen — in
particular resizing the tuple spec representing the number of arguments
passed in with the tuple length representing the number of parameters
the splat was matched with.

This work also shows that we might need to change how we are performing
argument expansion during overload resolution. At the moment, when we
expand parameters, we assume that each argument will still be matched to
the same parameters as before, and only retry the type-checking phase.
With splatted arguments, this is no longer the case, since the inferred
arity of each union element might be different than the arity of the
union as a whole, which can affect how many parameters the splatted
argument is matched to. See the regression test case in
`mdtest/call/function.md` for more details.
2025-07-22 14:33:08 -04:00
..
ruff Move fix suggestion to subdiagnostic (#19464) 2025-07-22 10:03:58 -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] Add support for @warnings.deprecated (#19376) 2025-07-18 23:50:29 +00:00
ruff_cache
ruff_db Move fix suggestion to subdiagnostic (#19464) 2025-07-22 10:03:58 -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 [ty] Track open files in the server (#19264) 2025-07-18 19:33:35 +05:30
ruff_index Update Rust toolchain to 1.88 and MSRV to 1.86 (#19011) 2025-06-28 20:24:00 +02:00
ruff_linter [flake8-pyi] Skip fix if all Union members are None (PYI016) (#19416) 2025-07-22 17:03:14 +00: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 [ty] AST garbage collection (#18482) 2025-06-13 08:40:11 -04:00
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 Fix unreachable panic in parser (#19183) 2025-07-20 22:04:14 +00: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 Treat ty: comments as pragma comments (#18532) 2025-06-07 16:02:43 +02:00
ruff_python_trivia_integration_tests
ruff_server Move fix suggestion to subdiagnostic (#19464) 2025-07-22 10:03:58 -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 Move fix suggestion to subdiagnostic (#19464) 2025-07-22 10:03:58 -04: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 [ty] Consistent use of American english (in rules) (#19488) 2025-07-22 16:10:38 +02:00
ty_ide [ty] Splat variadic arguments into parameter list (#18996) 2025-07-22 14:33:08 -04:00
ty_project Move fix suggestion to subdiagnostic (#19464) 2025-07-22 10:03:58 -04:00
ty_python_semantic [ty] Splat variadic arguments into parameter list (#18996) 2025-07-22 14:33:08 -04:00
ty_server [ty] Track open files in the server (#19264) 2025-07-18 19:33:35 +05:30
ty_static [ty] Merge ty_macros into ruff_macros (#19229) 2025-07-09 11:28:21 +00:00
ty_test [ty] Track open files in the server (#19264) 2025-07-18 19:33:35 +05:30
ty_vendored [ty] Sync vendored typeshed stubs (#19461) 2025-07-21 14:01:42 +01:00
ty_wasm [ty] Add goto definition to playground (#19425) 2025-07-19 15:44:44 +02:00