mirror of https://github.com/astral-sh/ruff
fix: failing snapshot test on Windows
This commit is contained in:
parent
39b5fa0e24
commit
faea478ca5
|
|
@ -81,7 +81,8 @@ pub fn normalize_path_to<P: AsRef<Path>, R: AsRef<Path>>(path: P, project_root:
|
|||
}
|
||||
|
||||
/// Convert an absolute path to be relative to the current working directory.
|
||||
pub fn relativize_path(path: &Path) -> String {
|
||||
pub fn relativize_path(path: impl AsRef<Path>) -> String {
|
||||
let path = path.as_ref();
|
||||
if let Ok(path) = path.strip_prefix(&*path_dedot::CWD) {
|
||||
return format!("{}", path.display());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,10 @@ impl Violation for ImplicitNamespacePackage {
|
|||
/// INP001
|
||||
pub fn implicit_namespace_package(path: &Path, package: Option<&Path>) -> Option<Diagnostic> {
|
||||
if package.is_none() && path.extension().map_or(true, |ext| ext != "pyi") {
|
||||
#[cfg(all(test, windows))]
|
||||
let path = path
|
||||
.to_string_lossy()
|
||||
.replace(std::path::MAIN_SEPARATOR, "/"); // The snapshot test expects / as the path separator.
|
||||
Some(Diagnostic::new(
|
||||
ImplicitNamespacePackage(fs::relativize_path(path)),
|
||||
Range::default(),
|
||||
|
|
|
|||
Loading…
Reference in New Issue