-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow override of configuration options via the CLI #8368
Labels
Comments
zanieb
added
configuration
Related to settings and configuration
cli
Related to the command-line interface
labels
Oct 30, 2023
For what it's worth, I think that |
Loved these proposals, here are examples and cons of each: 1. Environment variablesRUFF_FORMAT_LINE_LENGTH=120 ruff format . cons:
2. A repeatable CLI option with key value pairs (e.g.
|
AlexWaygood
added a commit
that referenced
this issue
Feb 9, 2024
…9599) Fixes #8368 Fixes #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 <[email protected]> Co-authored-by: Zanie Blue <[email protected]>
nkxxll
pushed a commit
to nkxxll/ruff
that referenced
this issue
Mar 10, 2024
…stral-sh#9599) Fixes astral-sh#8368 Fixes astral-sh#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 <[email protected]> Co-authored-by: Zanie Blue <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Currently, Ruff includes many configuration options that are only available via a configuration file. These options should be available via the CLI as well so users can either:
There have been previous requests for this, but I could not find them. If you know where they're at please share so we can have more historical context here.
Proposals
There are a few options for exposing this capability.
Environment variables
Add environment variable overrides for all settings. Environment variables would take precedence over all persistent configuration options but not CLI flags.
A repeatable CLI option with key value pairs
A CLI option for overriding settings e.g.
--setting <NAME>=<VALUE>
Alternative names include
--settings
,--override-setting
,--override-config
,--set-config
,--configure
,--override
,--option
,--options
A CLI option with JSON support
A CLI option for overriding settings in bulk e.g.
--settings {...}
This has been requested for programmatic use of Ruff previously e.g. you can use
jq
to pass a configuration file in bulk. However, this is not a very user-friendly approach for most use cases.Dedicated CLI options
A dedicated CLI option generated for each setting e.g.
--set-<name> VALUE
.We would probably omit enumerating these in the
help
menus and document the pattern instead. We could omit theset-
prefix but then we need to worry about collisions between configuration options and existing CLI flags. Additionally, this option does not work well with the<section>.<name>
syntax used in our configuration.The text was updated successfully, but these errors were encountered: