Allow arbitrary configuration options to be overridden via the CLI (#9599)

Fixes #8368
Fixes https://github.com/astral-sh/ruff/issues/9186

## Summary

Arbitrary TOML strings can be provided via the command-line to override
configuration options in `pyproject.toml` or `ruff.toml`. As an example:
to run over typeshed and respect typeshed's `pyproject.toml`, but
override a specific isort setting and enable an additional pep8-naming
setting:

```
cargo run -- check ../typeshed --no-cache --config ../typeshed/pyproject.toml --config "lint.isort.combine-as-imports=false" --config "lint.extend-select=['N801']"
```

---------

Co-authored-by: Micha Reiser <micha@reiser.io>
Co-authored-by: Zanie Blue <contact@zanie.dev>
This commit is contained in:
Alex Waygood 2024-02-09 13:56:37 -08:00 committed by GitHub
parent b21ba71ef4
commit 8ec56277e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 1099 additions and 235 deletions

View file

@ -108,8 +108,9 @@ impl Workspace {
#[wasm_bindgen(constructor)]
pub fn new(options: JsValue) -> Result<Workspace, Error> {
let options: Options = serde_wasm_bindgen::from_value(options).map_err(into_error)?;
let configuration = Configuration::from_options(options, Path::new("."), Path::new("."))
.map_err(into_error)?;
let configuration =
Configuration::from_options(options, Some(Path::new(".")), Path::new("."))
.map_err(into_error)?;
let settings = configuration
.into_settings(Path::new("."))
.map_err(into_error)?;