ruff/crates/ty_python_semantic/src
Dhruv Manilawala c7e020df6b
[ty] Filter overloads based on Any / Unknown (#18607)
## Summary

Closes: astral-sh/ty#552

This PR adds support for step 5 of the overload call evaluation
algorithm which specifies:

> For all arguments, determine whether all possible materializations of
the argument’s type are
> assignable to the corresponding parameter type for each of the
remaining overloads. If so,
> eliminate all of the subsequent remaining overloads.

The algorithm works in two parts:

1. Find out the participating parameter indexes. These are the
parameters that aren't gradual equivalent to one or more parameter types
at the same index in other overloads.
2. Loop over each overload and check whether that would be the _final_
overload for the argument types i.e., the remaining overloads will never
be matched against these argument types

For step 1, the participating parameter indexes are computed by just
comparing whether all the parameter types at the corresponding index for
all the overloads are **gradual equivalent**.

The step 2 of the algorithm used is described in [this
comment](https://github.com/astral-sh/ty/issues/552#issuecomment-2969165421).

## Test Plan

Update the overload call tests.
2025-06-17 15:35:09 +05:30
..
module_resolver [ty] Infer the Python version from --python=<system installation> on Unix (#18550) 2025-06-11 14:32:33 +00:00
semantic_index [ty] basic narrowing on attribute and subscript expressions (#17643) 2025-06-17 11:07:46 +02:00
types [ty] Filter overloads based on Any / Unknown (#18607) 2025-06-17 15:35:09 +05:30
util [ty] Infer the Python version from --python=<system installation> on Unix (#18550) 2025-06-11 14:32:33 +00:00
ast_node_ref.rs [ty] AST garbage collection (#18482) 2025-06-13 08:40:11 -04:00
db.rs [ty] Allow overriding rules for specific files (#18648) 2025-06-15 14:27:39 +01:00
dunder_all.rs [ty] Add infrastructure for AST garbage collection (#18445) 2025-06-05 11:43:18 -04:00
lib.rs [ty] Pull types on synthesized Python files created by mdtest (#18539) 2025-06-12 10:32:17 +01:00
lint.rs [ty] Allow overriding rules for specific files (#18648) 2025-06-15 14:27:39 +01:00
list.rs Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
module_name.rs [ty] AST garbage collection (#18482) 2025-06-13 08:40:11 -04:00
node_key.rs [ty] AST garbage collection (#18482) 2025-06-13 08:40:11 -04:00
place.rs [ty] basic narrowing on attribute and subscript expressions (#17643) 2025-06-17 11:07:46 +02:00
program.rs [ty] Infer the Python version from --python=<system installation> on Unix (#18550) 2025-06-11 14:32:33 +00:00
pull_types.rs [ty] Pull types on synthesized Python files created by mdtest (#18539) 2025-06-12 10:32:17 +01:00
python_platform.rs Hug closing } when f-string expression has a format specifier (#18704) 2025-06-17 07:39:42 +02:00
semantic_index.rs [ty] basic narrowing on attribute and subscript expressions (#17643) 2025-06-17 11:07:46 +02:00
semantic_model.rs [ty] Add infrastructure for AST garbage collection (#18445) 2025-06-05 11:43:18 -04:00
site_packages.rs [ty] Track the origin of the environment.python setting for better error messages (#18483) 2025-06-06 13:36:41 +01:00
suppression.rs [ty] Allow overriding rules for specific files (#18648) 2025-06-15 14:27:39 +01:00
types.rs [ty] Filter overloads based on Any / Unknown (#18607) 2025-06-17 15:35:09 +05:30
unpack.rs [ty] Add infrastructure for AST garbage collection (#18445) 2025-06-05 11:43:18 -04:00