From b54b1c1f05187838b8f25eedb9608a9074958eb8 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Tue, 9 Jan 2024 00:42:43 -0500 Subject: [PATCH] Add Windows --- Cargo.lock | 7 +++++++ Cargo.toml | 1 + crates/ruff_workspace/Cargo.toml | 1 + crates/ruff_workspace/src/resolver.rs | 6 ++++-- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ff8e93dc34418..4ebdba3151bc7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1541,6 +1541,12 @@ dependencies = [ "once_cell", ] +[[package]] +name = "path-slash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e91099d4268b0e11973f036e885d652fb0b21fedcf69738c627f94db6a44f42" + [[package]] name = "pathdiff" version = "0.2.1" @@ -2499,6 +2505,7 @@ dependencies = [ "matchit", "once_cell", "path-absolutize", + "path-slash", "pep440_rs 0.4.0", "regex", "ruff_cache", diff --git a/Cargo.toml b/Cargo.toml index ba3684a0b47a5..ba217f6947c37 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,6 +62,7 @@ natord = { version = "1.0.9" } notify = { version = "6.1.1" } once_cell = { version = "1.19.0" } path-absolutize = { version = "3.1.1" } +path-slash = { version = "0.2.1" } pathdiff = { version = "0.2.1" } pep440_rs = { version = "0.4.0", features = ["serde"] } pretty_assertions = "1.3.0" diff --git a/crates/ruff_workspace/Cargo.toml b/crates/ruff_workspace/Cargo.toml index 1dc2e0d4b1ccc..07bbc9a7492f6 100644 --- a/crates/ruff_workspace/Cargo.toml +++ b/crates/ruff_workspace/Cargo.toml @@ -33,6 +33,7 @@ log = { workspace = true } matchit = { workspace = true } once_cell = { workspace = true } path-absolutize = { workspace = true } +path-slash = { workspace = true } pep440_rs = { workspace = true, features = ["serde"] } regex = { workspace = true } rustc-hash = { workspace = true } diff --git a/crates/ruff_workspace/src/resolver.rs b/crates/ruff_workspace/src/resolver.rs index 43d1ab9ca052f..9fcd3a4c15efd 100644 --- a/crates/ruff_workspace/src/resolver.rs +++ b/crates/ruff_workspace/src/resolver.rs @@ -14,6 +14,7 @@ use itertools::Itertools; use log::debug; use matchit::{InsertError, Router}; use path_absolutize::path_dedot; +use path_slash::PathExt; use rustc_hash::{FxHashMap, FxHashSet}; use ruff_linter::fs; @@ -105,8 +106,9 @@ impl Resolver { /// Add a resolved [`Settings`] under a given [`PathBuf`] scope. fn add(&mut self, path: &Path, settings: Settings) -> Result<()> { self.settings.push(settings); + println!("path: {:?}", path.to_slash_lossy()); match self.router.insert( - format!("{}/*filepath", path.to_string_lossy()), + format!("{}/*filepath", path.to_slash_lossy()), self.settings.len() - 1, ) { Ok(()) => Ok(()), @@ -125,7 +127,7 @@ impl Resolver { PyprojectDiscoveryStrategy::Fixed => &pyproject_config.settings, PyprojectDiscoveryStrategy::Hierarchical => self .router - .at(&path.to_string_lossy()) + .at(&path.to_slash_lossy()) .map(|match_| &self.settings[*match_.value]) .unwrap_or(&pyproject_config.settings), }