ruff/crates/ty_python_semantic/src/semantic_index
Aria Desires 45ac30a4d7
[ty] Teach `ty` the meaning of desperation (try ancestor `pyproject.toml`s as search-paths if module resolution fails) (#21745)
## Summary

This makes an importing file a required argument to module resolution,
and if the fast-path cached query fails to resolve the module, take the
slow-path uncached (could be cached if we want)
`desperately_resolve_module` which will walk up from the importing file
until it finds a `pyproject.toml` (arbitrary decision, we could try
every ancestor directory), at which point it takes one last desperate
attempt to use that directory as a search-path. We do not continue
walking up once we've found a `pyproject.toml` (arbitrary decision, we
could keep going up).

Running locally, this fixes every broken-for-workspace-reasons import in
pyx's workspace!

* Fixes https://github.com/astral-sh/ty/issues/1539
* Improves https://github.com/astral-sh/ty/issues/839

## Test Plan

The workspace tests see a huge improvement on most absolute imports.
2025-12-03 15:04:36 -05:00
..
builder Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
use_def [ty] more precise lazy scope place lookup (#19932) 2025-09-08 21:08:35 +00:00
ast_ids.rs [ty] Split `ScopedPlaceId` into `ScopedSymbolId` and `ScopedMemberId` (#19497) 2025-07-25 13:54:33 +02:00
builder.rs [ty] Teach `ty` the meaning of desperation (try ancestor `pyproject.toml`s as search-paths if module resolution fails) (#21745) 2025-12-03 15:04:36 -05:00
definition.rs [ty] Generic types aliases (implicit and PEP 613) (#21553) 2025-11-28 20:38:24 +01:00
expression.rs [ty] Track heap usage of salsa structs (#19790) 2025-08-12 13:28:44 +02:00
member.rs [ty] Fix static assertion size check (#19814) 2025-08-07 13:38:16 -05:00
narrowing_constraints.rs [ty] Split `ScopedPlaceId` into `ScopedSymbolId` and `ScopedMemberId` (#19497) 2025-07-25 13:54:33 +02:00
place.rs [ty] Add version hint for failed stdlib attribute accesses (#20909) 2025-10-16 14:07:33 +00:00
predicate.rs [ty] Reachability constraints: minor documentation fixes (#21774) 2025-12-03 16:40:11 +01:00
re_exports.rs [ty] Teach `ty` the meaning of desperation (try ancestor `pyproject.toml`s as search-paths if module resolution fails) (#21745) 2025-12-03 15:04:36 -05:00
reachability_constraints.rs [ty] Reachability constraints: minor documentation fixes (#21774) 2025-12-03 16:40:11 +01:00
scope.rs [ty] display variance on hover over type variables (#20900) 2025-10-20 17:28:36 +00:00
symbol.rs [ty] name is parameter and global is a syntax error (#21312) 2025-11-14 18:15:34 +00:00
use_def.rs [ty] Fix flow of associated member states during star imports (#21776) 2025-12-03 17:52:31 +01:00