Skip to content

Commit

Permalink
Port from obsolete wsl crate to is-wsl (#9356)
Browse files Browse the repository at this point in the history
The "wsl" crate was last touched in 2019, whereas the "is-wsl" crate was
last updated in 2023. Additionally, it is unclear whether the "wsl"
crate supports both WSL1 and WSL2 (which was announced in 2019), whereas
the "is-wsl" crate explicitly supports both WSL1 and WSL2.

The required code changes are minimal, since both crates provide only a
`is_wsl() -> bool` function.
  • Loading branch information
decathorpe authored Jan 2, 2024
1 parent 8db5bce commit 1f4dc12
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 13 deletions.
27 changes: 20 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ globset = { version = "0.4.14" }
ignore = { version = "0.4.21" }
insta = { version = "1.34.0", feature = ["filters", "glob"] }
is-macro = { version = "0.3.4" }
is-wsl = { version = "0.4.0" }
itertools = { version = "0.11.0" }
libcst = { version = "1.1.0", default-features = false }
log = { version = "0.4.17" }
Expand Down Expand Up @@ -53,7 +54,6 @@ unicode-ident = { version = "1.0.12" }
unicode_names2 = { version = "1.2.1" }
unicode-width = { version = "0.1.11" }
uuid = { version = "1.6.1", features = ["v4", "fast-rng", "macro-diagnostics", "js"] }
wsl = { version = "0.1.0" }

[workspace.lints.rust]
unsafe_code = "warn"
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff_linter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ glob = { workspace = true }
globset = { workspace = true }
imperative = { version = "1.0.4" }
is-macro = { workspace = true }
is-wsl = { workspace = true }
itertools = { workspace = true }
libcst = { workspace = true }
log = { workspace = true }
Expand Down Expand Up @@ -72,7 +73,6 @@ typed-arena = { version = "2.0.2" }
unicode-width = { workspace = true }
unicode_names2 = { workspace = true }
url = { version = "2.2.2" }
wsl = { version = "0.1.0" }

[dev-dependencies]
insta = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use std::path::Path;

use ruff_text_size::{Ranged, TextRange};
use wsl;

use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
Expand Down Expand Up @@ -45,7 +44,7 @@ impl Violation for ShebangMissingExecutableFile {
pub(crate) fn shebang_missing_executable_file(filepath: &Path) -> Option<Diagnostic> {
// WSL supports Windows file systems, which do not have executable bits.
// Instead, everything is executable. Therefore, we skip this rule on WSL.
if wsl::is_wsl() {
if is_wsl::is_wsl() {
return None;
}
if let Ok(true) = is_executable(filepath) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use std::path::Path;

use ruff_text_size::{Ranged, TextRange};
use wsl;

use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
Expand Down Expand Up @@ -45,7 +44,7 @@ impl Violation for ShebangNotExecutable {
pub(crate) fn shebang_not_executable(filepath: &Path, range: TextRange) -> Option<Diagnostic> {
// WSL supports Windows file systems, which do not have executable bits.
// Instead, everything is executable. Therefore, we skip this rule on WSL.
if wsl::is_wsl() {
if is_wsl::is_wsl() {
return None;
}

Expand Down

0 comments on commit 1f4dc12

Please sign in to comment.