Skip to content

Commit 35d3969

Browse files
committed
Some windows annoyance
1 parent 244a469 commit 35d3969

26 files changed

+424
-376
lines changed

.editorconfig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@ indent_size = 4
1717
trim_trailing_whitespace = false
1818

1919
[*.md]
20-
max_line_length = 100
20+
max_line_length = 100
21+
22+
[*.toml]
23+
indent_size = 4

Cargo.lock

Lines changed: 27 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ criterion = { version = "0.5.1", default-features = false }
6666
crossbeam = { version = "0.8.4" }
6767
dashmap = { version = "6.0.1" }
6868
dir-test = { version = "0.3.0" }
69+
dunce = { version = "1.0.5" }
6970
drop_bomb = { version = "0.1.5" }
7071
env_logger = { version = "0.11.0" }
7172
etcetera = { version = "0.8.0" }
@@ -81,7 +82,7 @@ hashbrown = { version = "0.15.0", default-features = false, features = [
8182
ignore = { version = "0.4.22" }
8283
imara-diff = { version = "0.1.5" }
8384
imperative = { version = "1.0.4" }
84-
indexmap = {version = "2.6.0" }
85+
indexmap = { version = "2.6.0" }
8586
indicatif = { version = "0.17.8" }
8687
indoc = { version = "2.0.4" }
8788
insta = { version = "1.35.1" }

crates/red_knot/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ tracing-tree = { workspace = true }
3434
[dev-dependencies]
3535
filetime = { workspace = true }
3636
tempfile = { workspace = true }
37+
ruff_db = { workspace = true, features = ["testing"] }
3738

3839
[lints]
3940
workspace = true

crates/red_knot/tests/file_watching.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use red_knot_workspace::workspace::WorkspaceMetadata;
1414
use ruff_db::files::{system_path_to_file, File, FileError};
1515
use ruff_db::source::source_text;
1616
use ruff_db::system::{OsSystem, SystemPath, SystemPathBuf};
17+
use ruff_db::testing::setup_logging;
1718
use ruff_db::Upcast;
1819

1920
struct TestCase {
@@ -203,7 +204,9 @@ where
203204
.as_utf8_path()
204205
.canonicalize_utf8()
205206
.with_context(|| "Failed to canonicalize root path.")?,
206-
);
207+
)
208+
.simplified()
209+
.to_path_buf();
207210

208211
let workspace_path = root_path.join("workspace");
209212

@@ -1351,6 +1354,7 @@ fn nested_packages_delete_root() -> anyhow::Result<()> {
13511354

13521355
#[test]
13531356
fn added_package() -> anyhow::Result<()> {
1357+
let _ = setup_logging();
13541358
let mut case = setup([
13551359
(
13561360
"pyproject.toml",

crates/red_knot_python_semantic/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ thiserror = { workspace = true }
3232
tracing = { workspace = true }
3333
rustc-hash = { workspace = true }
3434
hashbrown = { workspace = true }
35+
serde = { workspace = true, optional = true }
3536
smallvec = { workspace = true }
3637
static_assertions = { workspace = true }
3738
test-case = { workspace = true }

crates/red_knot_python_semantic/src/program.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,15 @@ impl Program {
5454
}
5555

5656
#[derive(Clone, Debug, Eq, PartialEq)]
57+
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
5758
pub struct ProgramSettings {
5859
pub target_version: PythonVersion,
5960
pub search_paths: SearchPathSettings,
6061
}
6162

6263
/// Configures the search paths for module resolution.
6364
#[derive(Eq, PartialEq, Debug, Clone)]
65+
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
6466
pub struct SearchPathSettings {
6567
/// List of user-provided paths that should take first priority in the module resolution.
6668
/// Examples in other type checkers are mypy's MYPYPATH environment variable,
@@ -91,6 +93,7 @@ impl SearchPathSettings {
9193
}
9294

9395
#[derive(Debug, Clone, Eq, PartialEq)]
96+
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
9497
pub enum SitePackages {
9598
Derived {
9699
venv_path: SystemPathBuf,

crates/red_knot_python_semantic/src/python_version.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::fmt;
55
/// Unlike the `TargetVersion` enums in the CLI crates,
66
/// this does not necessarily represent a Python version that we actually support.
77
#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)]
8+
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
89
pub struct PythonVersion {
910
pub major: u8,
1011
pub minor: u8,

crates/red_knot_python_semantic/src/site_packages.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,20 @@ mod tests {
732732
let system = TestSystem::default();
733733
assert!(matches!(
734734
VirtualEnvironment::new("/.venv", &system),
735-
Err(SitePackagesDiscoveryError::VenvDirIsNotADirectory(_))
735+
Err(SitePackagesDiscoveryError::VenvDirCanonicalizationError(..))
736+
));
737+
}
738+
739+
#[test]
740+
fn reject_venv_that_is_not_a_directory() {
741+
let system = TestSystem::default();
742+
system
743+
.memory_file_system()
744+
.write_file("/.venv", "")
745+
.unwrap();
746+
assert!(matches!(
747+
VirtualEnvironment::new("/.venv", &system),
748+
Err(SitePackagesDiscoveryError::VenvDirIsNotADirectory(..))
736749
));
737750
}
738751

crates/red_knot_wasm/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ impl System for WasmSystem {
226226
}
227227

228228
fn canonicalize_path(&self, path: &SystemPath) -> ruff_db::system::Result<SystemPathBuf> {
229-
Ok(self.fs.canonicalize(path))
229+
self.fs.canonicalize(path)
230230
}
231231

232232
fn read_to_string(&self, path: &SystemPath) -> ruff_db::system::Result<String> {

0 commit comments

Comments
 (0)