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
Implement shell autocompletion for rule codes #2906
Implement shell autocompletion for rule codes #2906
Conversation
2e21b39
to
36b400e
Compare
Wow it includes the human-readable name? That is so nice. |
36b400e
to
db1f041
Compare
@@ -233,3 +233,76 @@ pub(crate) enum Specificity { | |||
Code4Chars, | |||
Code5Chars, | |||
} | |||
|
|||
mod clap_completion { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put it in a submodule so that we can easily feature gate it in the future (since we'll probably want to turn clap
into an optional dependency for the ruff
library).
Yeah I agree ... it's pretty neat. |
db1f041
to
5fb9aa4
Compare
@@ -109,15 +109,17 @@ pub struct CheckArgs { | |||
long, | |||
value_delimiter = ',', | |||
value_name = "RULE_CODE", | |||
help_heading = "Rule selection" | |||
help_heading = "Rule selection", | |||
hide_possible_values = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added hide_possible_values
because we don't want ruff help check
to list all 4,000 codes.^^
@@ -468,7 +468,7 @@ Options: | |||
--show-settings | |||
See the settings Ruff will use to lint a given Python file | |||
-h, --help | |||
Print help | |||
Print help (see more with '--help') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is related to hide_possible_values
, but I'm trying to wrap my head around what it's saying, when it would show up, and what would change by adding --help
-- isn't this message printed when the user runs --help
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah ... this also confused me quite a bit. As it turns out this is a Clap bug. I submitted a fix to upstream with clap-rs/clap#4710.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing that!
For example: $ ruff check --select=EM<Tab> EM -- flake8-errmsg EM10 EM1 -- EM101 -- raw-string-in-exception EM102 -- f-string-in-exception EM103 -- dot-format-in-exception (You will need to enable autocompletion as described in the Autocompletion section in the README.) Fixes astral-sh#2808. (The --help help change in the README is due to a clap bug, for which I already submitted a fix: clap-rs/clap#4710.)
5fb9aa4
to
08c7692
Compare
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [ruff](https://togithub.com/charliermarsh/ruff) | `^0.0.246` -> `^0.0.247` | [![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.247/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.247/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.247/compatibility-slim/0.0.246)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.247/confidence-slim/0.0.246)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>charliermarsh/ruff</summary> ### [`v0.0.247`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.247) [Compare Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.246...v0.0.247) <!-- Release notes generated using configuration in .github/release.yml at main --> #### What's Changed ##### Rules - \[`NPY001`] deprecated type aliases by [@​sbrugman](https://togithub.com/sbrugman) in [astral-sh/ruff#2810 - \[`RUF006`] Implement `asyncio-dangling-task` to track `asyncio.create_task` calls by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#2935 ##### CLI - Implement shell autocompletion for rule codes by [@​not-my-profile](https://togithub.com/not-my-profile) in [astral-sh/ruff#2906 ##### Bug Fixes - Handle multiple receiver decorators in receiver-decorator by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#2858 - Avoid false-positives with multi-byte characters in B005 by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#2862 - Avoid false-positives for runtime-types in type checking blocks by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#2863 - Avoid noqa removal upon unhandled syntax errors by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#2864 - Ignore non-imperative-mood in Google docstring convention by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#2900 - \[`flake8-tidy-imports`] autofix relative imports by [@​sbrugman](https://togithub.com/sbrugman) in [astral-sh/ruff#2891 - Respect self as positional-only argument in annotation rules by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#2927 - Apply nullable-model-string-field to all classes by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#2928 - Deduplicate files provided on the command-line by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#2931 - Re-show --target-version on CLI interface by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#2859 - Remove autofix for prefer-type-error by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#2880 - Avoid unnecessary-else violations in `elif` branches by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#2881 - Extend B904 to else branches by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#2886 - Allow private accesses on current class by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#2929 #### New Contributors - [@​Jeremiah-England](https://togithub.com/Jeremiah-England) made their first contribution in [astral-sh/ruff#2884 - [@​Chris-May](https://togithub.com/Chris-May) made their first contribution in [astral-sh/ruff#2896 - [@​simon04](https://togithub.com/simon04) made their first contribution in [astral-sh/ruff#2904 **Full Changelog**: astral-sh/ruff@v0.0.246...v0.0.247 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/ixm-one/pytest-cmake-presets). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4xMzguMyIsInVwZGF0ZWRJblZlciI6IjM0LjEzOC4zIn0=--> Signed-off-by: Renovate Bot <bot@renovateapp.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [ruff](https://togithub.com/charliermarsh/ruff) | `==0.0.246` -> `==0.0.247` | [![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.247/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.247/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.247/compatibility-slim/0.0.246)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.247/confidence-slim/0.0.246)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>charliermarsh/ruff</summary> ### [`v0.0.247`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.247) [Compare Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.246...v0.0.247) <!-- Release notes generated using configuration in .github/release.yml at main --> #### What's Changed ##### Rules - \[`NPY001`] deprecated type aliases by [@​sbrugman](https://togithub.com/sbrugman) in [astral-sh/ruff#2810 - \[`RUF006`] Implement `asyncio-dangling-task` to track `asyncio.create_task` calls by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#2935 ##### CLI - Implement shell autocompletion for rule codes by [@​not-my-profile](https://togithub.com/not-my-profile) in [astral-sh/ruff#2906 ##### Bug Fixes - Handle multiple receiver decorators in receiver-decorator by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#2858 - Avoid false-positives with multi-byte characters in B005 by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#2862 - Avoid false-positives for runtime-types in type checking blocks by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#2863 - Avoid noqa removal upon unhandled syntax errors by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#2864 - Ignore non-imperative-mood in Google docstring convention by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#2900 - \[`flake8-tidy-imports`] autofix relative imports by [@​sbrugman](https://togithub.com/sbrugman) in [astral-sh/ruff#2891 - Respect self as positional-only argument in annotation rules by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#2927 - Apply nullable-model-string-field to all classes by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#2928 - Deduplicate files provided on the command-line by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#2931 - Re-show --target-version on CLI interface by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#2859 - Remove autofix for prefer-type-error by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#2880 - Avoid unnecessary-else violations in `elif` branches by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#2881 - Extend B904 to else branches by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#2886 - Allow private accesses on current class by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#2929 #### New Contributors - [@​Jeremiah-England](https://togithub.com/Jeremiah-England) made their first contribution in [astral-sh/ruff#2884 - [@​Chris-May](https://togithub.com/Chris-May) made their first contribution in [astral-sh/ruff#2896 - [@​simon04](https://togithub.com/simon04) made their first contribution in [astral-sh/ruff#2904 **Full Changelog**: astral-sh/ruff@v0.0.246...v0.0.247 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/allenporter/flux-local). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4xNDMuMSIsInVwZGF0ZWRJblZlciI6IjM0LjE0My4xIn0=--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
For example:
(You will need to enable autocompletion as described
in the Autocompletion section in the README.)
Fixes #2808.