diff --git a/crates/ruff_db/src/source.rs b/crates/ruff_db/src/source.rs index a4b0c6ffacc6c..f7cd153d258ce 100644 --- a/crates/ruff_db/src/source.rs +++ b/crates/ruff_db/src/source.rs @@ -54,7 +54,6 @@ impl std::fmt::Debug for SourceText { #[cfg(test)] mod tests { - use filetime::FileTime; use salsa::EventKind; use ruff_source_file::OneIndexed; @@ -80,7 +79,7 @@ mod tests { db.file_system_mut() .write_file(path, "x = 20".to_string()) .unwrap(); - file.set_revision(&mut db).to(FileTime::now().into()); + file.touch(&mut db); assert_eq!(&*source_text(&db, file), "x = 20"); diff --git a/crates/ruff_db/src/vfs.rs b/crates/ruff_db/src/vfs.rs index 834b3910a24da..be275609f3737 100644 --- a/crates/ruff_db/src/vfs.rs +++ b/crates/ruff_db/src/vfs.rs @@ -272,6 +272,7 @@ impl VfsFile { Self::touch_impl(db, &path, Some(self)); } + /// Private method providing the implementation for [`Self::touch_path`] and [`Self::touch`]. fn touch_impl(db: &mut dyn Db, path: &VfsPath, file: Option) { match path { VfsPath::FileSystem(path) => { diff --git a/crates/ruff_python_semantic/src/module.rs b/crates/ruff_python_semantic/src/module.rs index 53ab4a83e2b4f..26c7aef90441d 100644 --- a/crates/ruff_python_semantic/src/module.rs +++ b/crates/ruff_python_semantic/src/module.rs @@ -66,7 +66,7 @@ impl ModuleName { return None; } - if name.split('.').all(|component| is_identifier(component)) { + if name.split('.').all(is_identifier) { Some(Self(name)) } else { None diff --git a/crates/ruff_python_semantic/src/module/resolver.rs b/crates/ruff_python_semantic/src/module/resolver.rs index ff00cddf6cd0c..1113b97591530 100644 --- a/crates/ruff_python_semantic/src/module/resolver.rs +++ b/crates/ruff_python_semantic/src/module/resolver.rs @@ -2,7 +2,7 @@ use std::ops::Deref; use std::sync::Arc; use ruff_db::file_system::{FileSystem, FileSystemPath, FileSystemPathBuf}; -use ruff_db::vfs::{file_system_path_to_file, vfs_path_to_file, VfsFile, VfsPath}; +use ruff_db::vfs::{system_path_to_file, vfs_path_to_file, VfsFile, VfsPath}; use crate::module::resolver::internal::ModuleResolverSearchPaths; use crate::module::{ @@ -258,13 +258,13 @@ fn resolve_name(db: &dyn Db, name: &ModuleName) -> Option<(ModuleSearchPath, Vfs // TODO Implement full https://peps.python.org/pep-0561/#type-checker-module-resolution-order resolution let stub = package_path.with_extension("pyi"); - if let Some(stub) = file_system_path_to_file(db.upcast(), &stub) { + if let Some(stub) = system_path_to_file(db.upcast(), &stub) { return Some((search_path.clone(), stub, kind)); } let module = package_path.with_extension("py"); - if let Some(module) = file_system_path_to_file(db.upcast(), &module) { + if let Some(module) = system_path_to_file(db.upcast(), &module) { return Some((search_path.clone(), module, kind)); } @@ -376,7 +376,7 @@ impl PackageKind { mod tests { use ruff_db::file_system::{FileSystemPath, FileSystemPathBuf}; - use ruff_db::vfs::{file_system_path_to_file, VfsFile, VfsPath}; + use ruff_db::vfs::{system_path_to_file, VfsFile, VfsPath}; use crate::db::tests::TestDb; use crate::module::{ModuleKind, ModuleName}; @@ -872,7 +872,7 @@ mod tests { let foo_module_name = ModuleName::new_static("foo").unwrap(); let foo_module = resolve_module(&db, foo_module_name.clone()).unwrap(); - let bar = file_system_path_to_file(&db, &bar_path).expect("bar.py to exist"); + let bar = system_path_to_file(&db, &bar_path).expect("bar.py to exist"); db.clear_salsa_events(); @@ -907,7 +907,7 @@ mod tests { // Now write the foo file db.memory_file_system().write_file(&foo_path, "x = 1")?; VfsFile::touch_path(&mut db, &VfsPath::FileSystem(foo_path.clone())); - let foo_file = file_system_path_to_file(&db, &foo_path).expect("foo.py to exist"); + let foo_file = system_path_to_file(&db, &foo_path).expect("foo.py to exist"); let foo_module = resolve_module(&db, foo_module_name).expect("Foo module to resolve"); assert_eq!(foo_file, foo_module.file());