Skip to content

Commit

Permalink
naming fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood committed Jul 18, 2024
1 parent e6067be commit 9275b10
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
4 changes: 2 additions & 2 deletions crates/red_knot_module_resolver/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ use ruff_db::Upcast;

use crate::resolver::{
editable_install_resolution_paths, file_to_module, internal::ModuleNameIngredient,
resolve_module_query, resolve_module_resolution_settings,
module_resolution_settings, resolve_module_query,
};
use crate::typeshed::parse_typeshed_versions;

#[salsa::jar(db=Db)]
pub struct Jar(
ModuleNameIngredient<'_>,
resolve_module_resolution_settings,
module_resolution_settings,
editable_install_resolution_paths,
resolve_module_query,
file_to_module,
Expand Down
18 changes: 6 additions & 12 deletions crates/red_knot_module_resolver/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,8 @@ pub(crate) fn file_to_module(db: &dyn Db, file: File) -> Option<Module> {
///
/// This method also implements the typing spec's [module resolution order].
///
/// TODO(Alex): this method does multiple `.unwrap()` calls when it should really return an error.
/// Each `.unwrap()` call is a point where we're validating a setting that the user would pass
/// and transforming it into an internal representation for a validated path.
/// Rather than panicking if a path fails to validate, we should display an error message to the user
/// and exit the process with a nonzero exit code.
/// This validation should probably be done outside of Salsa?
///
/// [module resolution order]: https://typing.readthedocs.io/en/latest/spec/distributing.html#import-resolution-ordering
#[salsa::tracked(return_ref)]
pub(crate) fn resolve_module_resolution_settings(
fn try_resolve_module_resolution_settings(
db: &dyn Db,
) -> Result<ModuleResolutionSettings, SearchPathValidationError> {
let program = Program::get(db.upcast());
Expand Down Expand Up @@ -185,9 +177,11 @@ pub(crate) fn resolve_module_resolution_settings(
})
}

fn module_resolution_settings(db: &dyn Db) -> &ModuleResolutionSettings {
// TODO proper error handling if this Salsa query returns an error:
resolve_module_resolution_settings(db).as_ref().unwrap()
#[salsa::tracked(return_ref)]
pub(crate) fn module_resolution_settings(db: &dyn Db) -> ModuleResolutionSettings {
// TODO proper error handling if this Salsa query returns an error
// rather than panicking if a path fails to validate
try_resolve_module_resolution_settings(db).unwrap()
}

/// Collect all dynamic search paths:
Expand Down

0 comments on commit 9275b10

Please sign in to comment.