Skip to content
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

Merged

Conversation

not-my-profile
Copy link
Contributor

@not-my-profile not-my-profile commented Feb 14, 2023

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 #2808.

@charliermarsh
Copy link
Member

Wow it includes the human-readable name? That is so nice.

@@ -233,3 +233,76 @@ pub(crate) enum Specificity {
Code4Chars,
Code5Chars,
}

mod clap_completion {
Copy link
Contributor Author

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).

@not-my-profile
Copy link
Contributor Author

Yeah I agree ... it's pretty neat.

@@ -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
Copy link
Contributor Author

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')
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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.)
@charliermarsh charliermarsh merged commit 70e378b into astral-sh:main Feb 15, 2023
renovate bot added a commit to ixm-one/pytest-cmake-presets that referenced this pull request Feb 16, 2023
[![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
[@&#8203;sbrugman](https://togithub.com/sbrugman) in
[astral-sh/ruff#2810
- \[`RUF006`] Implement `asyncio-dangling-task` to track
`asyncio.create_task` calls by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2935

##### CLI

- Implement shell autocompletion for rule codes by
[@&#8203;not-my-profile](https://togithub.com/not-my-profile) in
[astral-sh/ruff#2906

##### Bug Fixes

- Handle multiple receiver decorators in receiver-decorator by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2858
- Avoid false-positives with multi-byte characters in B005 by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2862
- Avoid false-positives for runtime-types in type checking blocks by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2863
- Avoid noqa removal upon unhandled syntax errors by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2864
- Ignore non-imperative-mood in Google docstring convention by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2900
- \[`flake8-tidy-imports`] autofix relative imports by
[@&#8203;sbrugman](https://togithub.com/sbrugman) in
[astral-sh/ruff#2891
- Respect self as positional-only argument in annotation rules by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2927
- Apply nullable-model-string-field to all classes by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2928
- Deduplicate files provided on the command-line by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2931
- Re-show --target-version on CLI interface by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2859
- Remove autofix for prefer-type-error by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2880
- Avoid unnecessary-else violations in `elif` branches by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2881
- Extend B904 to else branches by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2886
- Allow private accesses on current class by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2929

#### New Contributors

- [@&#8203;Jeremiah-England](https://togithub.com/Jeremiah-England) made
their first contribution in
[astral-sh/ruff#2884
- [@&#8203;Chris-May](https://togithub.com/Chris-May) made their first
contribution in
[astral-sh/ruff#2896
- [@&#8203;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>
renovate bot added a commit to allenporter/flux-local that referenced this pull request Feb 18, 2023
[![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
[@&#8203;sbrugman](https://togithub.com/sbrugman) in
[astral-sh/ruff#2810
- \[`RUF006`] Implement `asyncio-dangling-task` to track
`asyncio.create_task` calls by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2935

##### CLI

- Implement shell autocompletion for rule codes by
[@&#8203;not-my-profile](https://togithub.com/not-my-profile) in
[astral-sh/ruff#2906

##### Bug Fixes

- Handle multiple receiver decorators in receiver-decorator by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2858
- Avoid false-positives with multi-byte characters in B005 by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2862
- Avoid false-positives for runtime-types in type checking blocks by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2863
- Avoid noqa removal upon unhandled syntax errors by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2864
- Ignore non-imperative-mood in Google docstring convention by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2900
- \[`flake8-tidy-imports`] autofix relative imports by
[@&#8203;sbrugman](https://togithub.com/sbrugman) in
[astral-sh/ruff#2891
- Respect self as positional-only argument in annotation rules by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2927
- Apply nullable-model-string-field to all classes by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2928
- Deduplicate files provided on the command-line by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2931
- Re-show --target-version on CLI interface by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2859
- Remove autofix for prefer-type-error by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2880
- Avoid unnecessary-else violations in `elif` branches by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2881
- Extend B904 to else branches by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2886
- Allow private accesses on current class by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2929

#### New Contributors

- [@&#8203;Jeremiah-England](https://togithub.com/Jeremiah-England) made
their first contribution in
[astral-sh/ruff#2884
- [@&#8203;Chris-May](https://togithub.com/Chris-May) made their first
contribution in
[astral-sh/ruff#2896
- [@&#8203;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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ruff autocompletion for --select rules
2 participants