Skip to content

Make --config and --isolated global flags#10150

Merged
AlexWaygood merged 19 commits into
astral-sh:mainfrom
AlexWaygood:config-global-option
Mar 4, 2024
Merged

Make --config and --isolated global flags#10150
AlexWaygood merged 19 commits into
astral-sh:mainfrom
AlexWaygood:config-global-option

Conversation

@AlexWaygood
Copy link
Copy Markdown
Member

Summary

Fixes #9892.

This PR makes --config and --isolated global flags that are accepted by all ruff subcommands: ruff will no longer error out if a redundant --config argument is passed to a command such as ruff version or ruff rule. The flag has no effect for subcommands that do not need it (but it is still validated).

Test Plan

There were no tests for ruff version, so I added them as part of this PR, and used the new tests to assert that the --config flag is now accepted by ruff version. I also manually tested to check things were working as expected.

Comment thread crates/ruff/src/lib.rs Outdated
Comment thread crates/ruff/src/version.rs Outdated
Comment thread crates/ruff/src/version.rs Outdated
Comment thread crates/ruff/src/args.rs
Comment thread crates/ruff/src/args.rs
Comment thread docs/configuration.md Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 28, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

Comment thread crates/ruff/tests/version.rs Outdated
@MichaReiser MichaReiser added the cli Related to the command-line interface label Feb 28, 2024
Comment thread docs/configuration.md Outdated
Comment thread crates/ruff/src/args.rs
Copy link
Copy Markdown
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improvements that we could make that are unrelated to your change but could improve readability (as separate PRs):

  • Rename HelpFormat to OutputFormat.
  • Move ConfigArguments next to FormatArguments and CheckArguments.

Comment thread crates/ruff/src/args.rs Outdated
Comment thread crates/ruff/src/args.rs Outdated
@AlexWaygood
Copy link
Copy Markdown
Member Author

Alright, ready for another look, I think 😅 the implementation now uses clap(flatten), as you suggested!

Comment thread crates/ruff/src/args.rs Outdated
@AlexWaygood AlexWaygood enabled auto-merge (squash) March 4, 2024 11:14
@AlexWaygood AlexWaygood merged commit 8b749e1 into astral-sh:main Mar 4, 2024
nkxxll pushed a commit to nkxxll/ruff that referenced this pull request Mar 10, 2024
@AlexWaygood AlexWaygood deleted the config-global-option branch July 1, 2024 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli Related to the command-line interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--config as a global flag/env var

3 participants