mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 05:44:56 +00:00
Support shell expansion for --config argument (#3107)
This commit is contained in:
parent
18800c6884
commit
9645790a8b
3 changed files with 10 additions and 3 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -2012,6 +2012,7 @@ dependencies = [
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"shellexpand",
|
||||||
"similar",
|
"similar",
|
||||||
"strum",
|
"strum",
|
||||||
"textwrap",
|
"textwrap",
|
||||||
|
|
|
@ -50,6 +50,7 @@ regex = { workspace = true }
|
||||||
rustc-hash = { workspace = true }
|
rustc-hash = { workspace = true }
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
serde_json = { workspace = true }
|
serde_json = { workspace = true }
|
||||||
|
shellexpand = { version = "3.0.0" }
|
||||||
similar = { version = "2.2.1" }
|
similar = { version = "2.2.1" }
|
||||||
strum = { version = "0.24.1" }
|
strum = { version = "0.24.1" }
|
||||||
textwrap = { version = "0.16.0" }
|
textwrap = { version = "0.16.0" }
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
use std::path::Path;
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use path_absolutize::path_dedot;
|
use path_absolutize::path_dedot;
|
||||||
|
|
||||||
use ruff::resolver::{
|
use ruff::resolver::{
|
||||||
resolve_settings_with_processor, ConfigProcessor, PyprojectDiscovery, Relativity,
|
resolve_settings_with_processor, ConfigProcessor, PyprojectDiscovery, Relativity,
|
||||||
};
|
};
|
||||||
|
@ -29,8 +30,12 @@ pub fn resolve(
|
||||||
// Second priority: the user specified a `pyproject.toml` file. Use that
|
// Second priority: the user specified a `pyproject.toml` file. Use that
|
||||||
// `pyproject.toml` for _all_ configuration, and resolve paths relative to the
|
// `pyproject.toml` for _all_ configuration, and resolve paths relative to the
|
||||||
// current working directory. (This matches ESLint's behavior.)
|
// current working directory. (This matches ESLint's behavior.)
|
||||||
if let Some(pyproject) = config {
|
if let Some(pyproject) = config
|
||||||
let settings = resolve_settings_with_processor(pyproject, &Relativity::Cwd, overrides)?;
|
.map(|config| config.display().to_string())
|
||||||
|
.map(|config| shellexpand::full(&config).map(|config| PathBuf::from(config.as_ref())))
|
||||||
|
.transpose()?
|
||||||
|
{
|
||||||
|
let settings = resolve_settings_with_processor(&pyproject, &Relativity::Cwd, overrides)?;
|
||||||
return Ok(PyprojectDiscovery::Fixed(settings));
|
return Ok(PyprojectDiscovery::Fixed(settings));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue