From a4cd13c6e22ac940c304388130fe596ea8b17173 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Tue, 12 Aug 2025 13:59:56 -0400 Subject: [PATCH] [ty] Expose some routines in the module resolver We'll want to use these when implementing the "list modules" API. --- crates/ty_python_semantic/src/module_resolver/resolver.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/ty_python_semantic/src/module_resolver/resolver.rs b/crates/ty_python_semantic/src/module_resolver/resolver.rs index d1974fac18..0dcd42b0dd 100644 --- a/crates/ty_python_semantic/src/module_resolver/resolver.rs +++ b/crates/ty_python_semantic/src/module_resolver/resolver.rs @@ -656,7 +656,7 @@ struct ModuleNameIngredient<'db> { /// This includes "builtin" modules, which can never be shadowed at runtime either, as well as the /// `types` module, which tends to be imported early in Python startup, so can't be consistently /// shadowed, and is important to type checking. -fn is_non_shadowable(minor_version: u8, module_name: &str) -> bool { +pub(super) fn is_non_shadowable(minor_version: u8, module_name: &str) -> bool { module_name == "types" || ruff_python_stdlib::sys::is_builtin_module(minor_version, module_name) } @@ -890,7 +890,10 @@ fn resolve_name_in_search_path( /// /// `.pyi` files take priority, as they always have priority when /// resolving modules. -fn resolve_file_module(module: &ModulePath, resolver_state: &ResolverContext) -> Option { +pub(super) fn resolve_file_module( + module: &ModulePath, + resolver_state: &ResolverContext, +) -> Option { // Stubs have precedence over source files let stub_file = if resolver_state.mode.stubs_allowed() { module.with_pyi_extension().to_file(resolver_state)