Support shell expansion in extend paths (#1323)

This commit is contained in:
Charlie Marsh
2022-12-21 20:46:38 -05:00
committed by GitHub
parent 66a6c81ebf
commit bf5fec342c
5 changed files with 24 additions and 3 deletions

View File

@@ -7,6 +7,7 @@ use std::path::{Path, PathBuf};
use anyhow::{anyhow, Result};
use glob::{glob, GlobError, Paths, PatternError};
use regex::Regex;
use shellexpand;
use crate::checks_gen::CheckCodePrefix;
use crate::cli::{collect_per_file_ignores, Overrides};
@@ -78,7 +79,14 @@ impl Configuration {
})
.collect()
}),
extend: options.extend.map(PathBuf::from),
extend: options
.extend
.map(|extend| {
let extend = shellexpand::full(&extend);
extend.map(|extend| PathBuf::from(extend.as_ref()))
})
.transpose()
.map_err(|e| anyhow!("Invalid `extend` value: {e}"))?,
extend_exclude: options
.extend_exclude
.map(|paths| {

View File

@@ -67,7 +67,8 @@ pub struct Options {
pub exclude: Option<Vec<String>>,
#[option(
doc = r#"
A path to a local `pyproject.toml` file to merge into this configuration.
A path to a local `pyproject.toml` file to merge into this configuration. User home
directory and environment variables will be expanded.
To resolve the current `pyproject.toml` file, Ruff will first resolve this base
configuration file, then merge in any properties defined in the current configuration