Skip to content

[ty] Extract module root discovery from NameResolver. - #28531

Merged
lerebear merged 1 commit into
mainfrom
lerebear/push-ywpuuvszsonk
Sep 11, 2026
Merged

lerebear merged 1 commit into
mainfrom
lerebear/push-ywpuuvszsonk

Conversation

@lerebear

@lerebear lerebear commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This is a small step towards the larger refactor that will allow us to share ordinary module resolution rules with the module enumeration process required to support namespace packages for auto imports (please see that refactor PR for a detailed description of our motivations). It refactors the previously associated NameResolver::discover_roots method into a free function, such that it can more easily be reused for both ordinary module resolution and module enumeration.

Test Plan

This is a pure refactor that relies on existing tests.

@lerebear lerebear added internal An internal refactor or improvement (not for changelogs) ty The ty type checker labels Sep 11, 2026
@astral-sh-bot

astral-sh-bot Bot commented Sep 11, 2026

Copy link
Copy Markdown

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 97.84%. The percentage of expected errors that received a diagnostic held steady at 96.45%. The number of fully passing files held steady at 128/145.

@astral-sh-bot

astral-sh-bot Bot commented Sep 11, 2026

Copy link
Copy Markdown

Memory usage report

Memory usage unchanged ✅

@astral-sh-bot

astral-sh-bot Bot commented Sep 11, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

No diagnostic changes detected ✅

Full report with detailed diff (timing results)

@lerebear
lerebear marked this pull request as ready for review September 11, 2026 20:24
@lerebear
lerebear requested a review from a team as a code owner September 11, 2026 20:24
@astral-sh-bot
astral-sh-bot Bot requested a review from carljm September 11, 2026 20:24
@lerebear
lerebear merged commit 35a3ed1 into main Sep 11, 2026
72 checks passed
@lerebear
lerebear deleted the lerebear/push-ywpuuvszsonk branch September 11, 2026 20:24
lerebear added a commit that referenced this pull request Sep 11, 2026
…terface changes (#28536)

<!--
Thank you for contributing to Ruff/ty! To help us out with reviewing,
please consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title? (Please prefix
with `[ty]` for ty pull
  requests.)
- Does this pull request include references to any relevant issues?
- Does this PR follow our AI policy
(https://github.com/astral-sh/.github/blob/main/AI_POLICY.md)?
-->

## Summary

<!-- What's the purpose of the change? What does it do, and why? -->
#28531 incorrectly went a bit too
far in turning `NameResolver::discover_roots` into a free function. That
isn't actually necessary for the refactor we're aiming for; we just need
to widen its interface to accept new arguments that allows it to apply
to new contexts. This restores the private method but retains the wider
interface.

## Test Plan

This is a behaviour-preserving refactor that relies on existing tests.
<!-- How was it tested? -->
carljm added a commit that referenced this pull request Sep 14, 2026
…aliases

* origin/main: (21 commits)
  [ty] Share attribute write compatibility checks (#28555)
  [ty] Prefer `ty.toml` and `pyproject.toml` over playground `ty.json` (#28449)
  [`ruff`, `flake8-use-pathlib`] Support `parent_mode` (`RUF064`, `PTH103`) (#28528)
  [`pyupgrade`] Make the fix for `UP040` always unsafe (#28526)
  [`pyupgrade`] Skip `TypeVarTuple` and `ParamSpec` conversions with bounds or constraints (`UP040`, `UP046`, `UP047`) (#28505)
  [ty] Escape glob characters in anchored directory paths (#28518)
  [ty] Handle gradual metaclass ancestry and conflicts (#28474)
  [ty] Preserve recursive metadata in union transformations (#28497)
  [ty] Refactor "desperate" import resolution to use candidate operations that will also apply to module enumeration. (#28543)
  [ty] Report override conflicts introduced by new bases (#28530)
  [ty] Resolve dependencies within correlated inference alternatives (#28252)
  [ty] Extract shared abstract-method analysis (#28537)
  [ty] Reject reassignment of enum members (#28462)
  [ty] Preserve runtime comparison semantics when narrowing tagged unions (#28053)
  [ty] Extract a method on `NameResolver` to advance resolution by single module name component. (#28540)
  [ty] Return root discovery to `NameResolver`, but retain necessary interface changes (#28536)
  [ty] Default-specialize class objects in meta-protocol checks (#28265)
  [ty] Extract module root discovery from `NameResolver`. (#28531)
  [ty] Fix MRO ordering for generic bases (#28172)
  [ty] Run benchmarks for auto-imports in CI (#28490)
  ...

# Conflicts:
#	crates/ty_python_semantic/src/types/narrow.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal An internal refactor or improvement (not for changelogs) ty The ty type checker

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant