mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-02 06:41:23 +00:00
Port from obsolete wsl crate to is-wsl (#9356)
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.
This commit is contained in:
parent
8db5bce92f
commit
1f4dc12631
5 changed files with 24 additions and 13 deletions
27
Cargo.lock
generated
27
Cargo.lock
generated
|
@ -1089,6 +1089,15 @@ dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "is-docker"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "928bae27f42bc99b60d9ac7334e3a21d10ad8f1835a4e12ec3ec0464765ed1b3"
|
||||||
|
dependencies = [
|
||||||
|
"once_cell",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "is-macro"
|
name = "is-macro"
|
||||||
version = "0.3.4"
|
version = "0.3.4"
|
||||||
|
@ -1112,6 +1121,16 @@ dependencies = [
|
||||||
"windows-sys 0.48.0",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "is-wsl"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "173609498df190136aa7dea1a91db051746d339e18476eed5ca40521f02d7aa5"
|
||||||
|
dependencies = [
|
||||||
|
"is-docker",
|
||||||
|
"once_cell",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itertools"
|
name = "itertools"
|
||||||
version = "0.10.5"
|
version = "0.10.5"
|
||||||
|
@ -2172,6 +2191,7 @@ dependencies = [
|
||||||
"imperative",
|
"imperative",
|
||||||
"insta",
|
"insta",
|
||||||
"is-macro",
|
"is-macro",
|
||||||
|
"is-wsl",
|
||||||
"itertools 0.11.0",
|
"itertools 0.11.0",
|
||||||
"libcst",
|
"libcst",
|
||||||
"log",
|
"log",
|
||||||
|
@ -2218,7 +2238,6 @@ dependencies = [
|
||||||
"unicode-width",
|
"unicode-width",
|
||||||
"unicode_names2",
|
"unicode_names2",
|
||||||
"url",
|
"url",
|
||||||
"wsl",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -3756,12 +3775,6 @@ dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wsl"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f8dab7ac864710bdea6594becbea5b5050333cf34fefb0dc319567eb347950d4"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "yaml-rust"
|
name = "yaml-rust"
|
||||||
version = "0.4.5"
|
version = "0.4.5"
|
||||||
|
|
|
@ -23,6 +23,7 @@ globset = { version = "0.4.14" }
|
||||||
ignore = { version = "0.4.21" }
|
ignore = { version = "0.4.21" }
|
||||||
insta = { version = "1.34.0", feature = ["filters", "glob"] }
|
insta = { version = "1.34.0", feature = ["filters", "glob"] }
|
||||||
is-macro = { version = "0.3.4" }
|
is-macro = { version = "0.3.4" }
|
||||||
|
is-wsl = { version = "0.4.0" }
|
||||||
itertools = { version = "0.11.0" }
|
itertools = { version = "0.11.0" }
|
||||||
libcst = { version = "1.1.0", default-features = false }
|
libcst = { version = "1.1.0", default-features = false }
|
||||||
log = { version = "0.4.17" }
|
log = { version = "0.4.17" }
|
||||||
|
@ -53,7 +54,6 @@ unicode-ident = { version = "1.0.12" }
|
||||||
unicode_names2 = { version = "1.2.1" }
|
unicode_names2 = { version = "1.2.1" }
|
||||||
unicode-width = { version = "0.1.11" }
|
unicode-width = { version = "0.1.11" }
|
||||||
uuid = { version = "1.6.1", features = ["v4", "fast-rng", "macro-diagnostics", "js"] }
|
uuid = { version = "1.6.1", features = ["v4", "fast-rng", "macro-diagnostics", "js"] }
|
||||||
wsl = { version = "0.1.0" }
|
|
||||||
|
|
||||||
[workspace.lints.rust]
|
[workspace.lints.rust]
|
||||||
unsafe_code = "warn"
|
unsafe_code = "warn"
|
||||||
|
|
|
@ -41,6 +41,7 @@ glob = { workspace = true }
|
||||||
globset = { workspace = true }
|
globset = { workspace = true }
|
||||||
imperative = { version = "1.0.4" }
|
imperative = { version = "1.0.4" }
|
||||||
is-macro = { workspace = true }
|
is-macro = { workspace = true }
|
||||||
|
is-wsl = { workspace = true }
|
||||||
itertools = { workspace = true }
|
itertools = { workspace = true }
|
||||||
libcst = { workspace = true }
|
libcst = { workspace = true }
|
||||||
log = { workspace = true }
|
log = { workspace = true }
|
||||||
|
@ -72,7 +73,6 @@ typed-arena = { version = "2.0.2" }
|
||||||
unicode-width = { workspace = true }
|
unicode-width = { workspace = true }
|
||||||
unicode_names2 = { workspace = true }
|
unicode_names2 = { workspace = true }
|
||||||
url = { version = "2.2.2" }
|
url = { version = "2.2.2" }
|
||||||
wsl = { version = "0.1.0" }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
insta = { workspace = true }
|
insta = { workspace = true }
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use ruff_text_size::{Ranged, TextRange};
|
use ruff_text_size::{Ranged, TextRange};
|
||||||
use wsl;
|
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
|
@ -45,7 +44,7 @@ impl Violation for ShebangMissingExecutableFile {
|
||||||
pub(crate) fn shebang_missing_executable_file(filepath: &Path) -> Option<Diagnostic> {
|
pub(crate) fn shebang_missing_executable_file(filepath: &Path) -> Option<Diagnostic> {
|
||||||
// WSL supports Windows file systems, which do not have executable bits.
|
// WSL supports Windows file systems, which do not have executable bits.
|
||||||
// Instead, everything is executable. Therefore, we skip this rule on WSL.
|
// Instead, everything is executable. Therefore, we skip this rule on WSL.
|
||||||
if wsl::is_wsl() {
|
if is_wsl::is_wsl() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
if let Ok(true) = is_executable(filepath) {
|
if let Ok(true) = is_executable(filepath) {
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use ruff_text_size::{Ranged, TextRange};
|
use ruff_text_size::{Ranged, TextRange};
|
||||||
use wsl;
|
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
|
@ -45,7 +44,7 @@ impl Violation for ShebangNotExecutable {
|
||||||
pub(crate) fn shebang_not_executable(filepath: &Path, range: TextRange) -> Option<Diagnostic> {
|
pub(crate) fn shebang_not_executable(filepath: &Path, range: TextRange) -> Option<Diagnostic> {
|
||||||
// WSL supports Windows file systems, which do not have executable bits.
|
// WSL supports Windows file systems, which do not have executable bits.
|
||||||
// Instead, everything is executable. Therefore, we skip this rule on WSL.
|
// Instead, everything is executable. Therefore, we skip this rule on WSL.
|
||||||
if wsl::is_wsl() {
|
if is_wsl::is_wsl() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue