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

Change --fix-only exit semantics to mirror --fix #4146

Merged
merged 1 commit into from
May 4, 2023

Conversation

charliermarsh
Copy link
Member

Summary

After this change, running ruff --fix-only will exit with status code 0 unless the program hits an internal error, while ruff --fix-only --exit-non-zero-on-fix will exit with status code 1 if at least one diagnostic is fixed. This effectively mirrors ruff --fix, taking into account that non-fixable diagnostics are ignored. Previously, the --exit-non-zero-on-fix flag had no effect when combined with --fix-only.

Closes #4092.

@charliermarsh charliermarsh added breaking Breaking API change cli Related to the command-line interface labels Apr 29, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Apr 29, 2023

PR Check Results

Ecosystem

✅ ecosystem check detected no changes.

Benchmark

Linux

group                                      main                                   pr
-----                                      ----                                   --
linter/all-rules/large/dataset.py          1.00     14.8±0.53ms     2.7 MB/sec    1.01     15.0±0.51ms     2.7 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.00      3.5±0.18ms     4.7 MB/sec    1.02      3.6±0.09ms     4.6 MB/sec
linter/all-rules/numpy/globals.py          1.06   459.8±14.85µs     6.4 MB/sec    1.00   432.0±21.92µs     6.8 MB/sec
linter/all-rules/pydantic/types.py         1.00      5.9±0.37ms     4.3 MB/sec    1.02      6.1±0.25ms     4.2 MB/sec
linter/default-rules/large/dataset.py      1.00      7.2±0.49ms     5.7 MB/sec    1.04      7.4±0.20ms     5.5 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.01  1614.2±50.54µs    10.3 MB/sec    1.00  1593.5±33.90µs    10.4 MB/sec
linter/default-rules/numpy/globals.py      1.00    177.2±4.62µs    16.7 MB/sec    1.00    178.1±5.58µs    16.6 MB/sec
linter/default-rules/pydantic/types.py     1.00      3.3±0.07ms     7.8 MB/sec    1.05      3.5±0.09ms     7.4 MB/sec
parser/large/dataset.py                    1.00      5.6±0.31ms     7.3 MB/sec    1.05      5.8±0.16ms     7.0 MB/sec
parser/numpy/ctypeslib.py                  1.00  1122.1±28.38µs    14.8 MB/sec    1.03  1160.6±40.73µs    14.3 MB/sec
parser/numpy/globals.py                    1.01    117.4±4.59µs    25.1 MB/sec    1.00    115.8±4.28µs    25.5 MB/sec
parser/pydantic/types.py                   1.00      2.4±0.05ms    10.4 MB/sec    1.02      2.5±0.06ms    10.2 MB/sec

Windows

group                                      main                                   pr
-----                                      ----                                   --
linter/all-rules/large/dataset.py          1.02     12.4±0.17ms     3.3 MB/sec    1.00     12.1±0.08ms     3.4 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.00      3.2±0.03ms     5.3 MB/sec    1.00      3.1±0.02ms     5.3 MB/sec
linter/all-rules/numpy/globals.py          1.00    321.0±4.98µs     9.2 MB/sec    1.02    328.2±6.32µs     9.0 MB/sec
linter/all-rules/pydantic/types.py         1.00      5.3±0.05ms     4.9 MB/sec    1.00      5.3±0.08ms     4.8 MB/sec
linter/default-rules/large/dataset.py      1.02      6.3±0.05ms     6.5 MB/sec    1.00      6.2±0.04ms     6.6 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.01  1329.1±12.29µs    12.5 MB/sec    1.00  1316.6±12.05µs    12.6 MB/sec
linter/default-rules/numpy/globals.py      1.00    138.9±1.78µs    21.2 MB/sec    1.02    141.6±2.50µs    20.8 MB/sec
linter/default-rules/pydantic/types.py     1.02      2.9±0.03ms     8.9 MB/sec    1.00      2.8±0.02ms     9.1 MB/sec
parser/large/dataset.py                    1.00      4.9±0.05ms     8.3 MB/sec    1.01      4.9±0.05ms     8.3 MB/sec
parser/numpy/ctypeslib.py                  1.00    926.4±7.05µs    18.0 MB/sec    1.00    928.9±8.82µs    17.9 MB/sec
parser/numpy/globals.py                    1.00     95.4±1.06µs    30.9 MB/sec    1.00     95.8±1.38µs    30.8 MB/sec
parser/pydantic/types.py                   1.00      2.1±0.02ms    12.3 MB/sec    1.00      2.1±0.02ms    12.3 MB/sec

Comment on lines 283 to 296
if cli.diff {
if !diagnostics.fixed.is_empty() {
return Ok(ExitStatus::Failure);
}
} else if cli.exit_non_zero_on_fix {
if !diagnostics.fixed.is_empty() || !diagnostics.messages.is_empty() {
return Ok(ExitStatus::Failure);
} else if fix_only {
if cli.exit_non_zero_on_fix {
if !diagnostics.fixed.is_empty() {
return Ok(ExitStatus::Failure);
}
} else {
return Ok(ExitStatus::Success);
}
} else {
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit confused. Isn't diff --fix and fix_only --fix-only? If so, shouldn't the cli.diff and fix_only branches be identical?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, those aren't the same. --fix, --fix-only, and --diff are all different options.

Comment on lines 292 to 295
} else {
return Ok(ExitStatus::Success);
}
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Safe to fallthrough.

Suggested change
} else {
return Ok(ExitStatus::Success);
}
}

@MichaReiser
Copy link
Member

Nit: It may be helpful to add some documentation explaining why/when we exit with a negative exit code for each option.

@charliermarsh charliermarsh enabled auto-merge (squash) May 4, 2023 18:57
@charliermarsh charliermarsh merged commit b71cc37 into main May 4, 2023
12 checks passed
@charliermarsh charliermarsh deleted the charlie/fix-only branch May 4, 2023 19:03
renovate bot added a commit to ixm-one/pytest-cmake-presets that referenced this pull request May 5, 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.264` ->
`^0.0.265` |
[![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.265/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.265/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.265/compatibility-slim/0.0.264)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.265/confidence-slim/0.0.264)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>charliermarsh/ruff</summary>

###
[`v0.0.265`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.265)

[Compare
Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.264...v0.0.265)

<!-- Release notes generated using configuration in .github/release.yml
at main -->

#### What's Changed

##### Breaking Changes

- Change `--fix-only` exit semantics to mirror `--fix` by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#4146

##### Rules

- \[flake8-pyi] PYI020 by [@&#8203;arya-k](https://togithub.com/arya-k)
in
[astral-sh/ruff#4211
- Update B027 to support autofixing by
[@&#8203;aacunningham](https://togithub.com/aacunningham) in
[astral-sh/ruff#4178
- \[`flake8-pyi`] Implement `PYI042` and `PYI043` by
[@&#8203;arya-k](https://togithub.com/arya-k) in
[astral-sh/ruff#4214
- \[`pylint`] Implement import-self (`W0406`) by
[@&#8203;chanman3388](https://togithub.com/chanman3388) in
[astral-sh/ruff#4154
- Warn on PEP 604 syntax not in an annotation, but don't autofix by
[@&#8203;wookie184](https://togithub.com/wookie184) in
[astral-sh/ruff#4170

##### Bug Fixes

- Fix panic in pydocstyle D214 when docstring indentation is empty by
[@&#8203;madkinsz](https://togithub.com/madkinsz) in
[astral-sh/ruff#4216
- Render tabs as 4 spaces in diagnostics by
[@&#8203;MichaReiser](https://togithub.com/MichaReiser) in
[astral-sh/ruff#4132
- Fix era panic caused by out of bound edition by
[@&#8203;leiserfg](https://togithub.com/leiserfg) in
[astral-sh/ruff#4206
- End of statement insertion should occur after newline by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[astral-sh/ruff#4215
- Ignore **debuggerskip** in unused variable checks by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#4229

##### CLI

- Show settings path in `--show-settings` output by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[astral-sh/ruff#4199

##### Documentation

- Allow linking to individual rules by
[@&#8203;calumy](https://togithub.com/calumy) in
[astral-sh/ruff#4158

#### New Contributors

- [@&#8203;wookie184](https://togithub.com/wookie184) made their first
contribution in
[astral-sh/ruff#4170
- [@&#8203;arya-k](https://togithub.com/arya-k) made their first
contribution in
[astral-sh/ruff#4211

**Full Changelog**:
astral-sh/ruff@v0.0.264...v0.0.265

</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:eyJjcmVhdGVkSW5WZXIiOiIzNS43MS40IiwidXBkYXRlZEluVmVyIjoiMzUuNzEuNCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

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 May 7, 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.264` ->
`==0.0.265` |
[![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.265/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.265/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.265/compatibility-slim/0.0.264)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.265/confidence-slim/0.0.264)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>charliermarsh/ruff</summary>

###
[`v0.0.265`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.265)

[Compare
Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.264...v0.0.265)

<!-- Release notes generated using configuration in .github/release.yml
at main -->

#### What's Changed

##### Breaking Changes

- Change `--fix-only` exit semantics to mirror `--fix` by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#4146

##### Rules

- \[flake8-pyi] PYI020 by [@&#8203;arya-k](https://togithub.com/arya-k)
in
[astral-sh/ruff#4211
- Update B027 to support autofixing by
[@&#8203;aacunningham](https://togithub.com/aacunningham) in
[astral-sh/ruff#4178
- \[`flake8-pyi`] Implement `PYI042` and `PYI043` by
[@&#8203;arya-k](https://togithub.com/arya-k) in
[astral-sh/ruff#4214
- \[`pylint`] Implement import-self (`W0406`) by
[@&#8203;chanman3388](https://togithub.com/chanman3388) in
[astral-sh/ruff#4154
- Warn on PEP 604 syntax not in an annotation, but don't autofix by
[@&#8203;wookie184](https://togithub.com/wookie184) in
[astral-sh/ruff#4170

##### Bug Fixes

- Fix panic in pydocstyle D214 when docstring indentation is empty by
[@&#8203;madkinsz](https://togithub.com/madkinsz) in
[astral-sh/ruff#4216
- Render tabs as 4 spaces in diagnostics by
[@&#8203;MichaReiser](https://togithub.com/MichaReiser) in
[astral-sh/ruff#4132
- Fix era panic caused by out of bound edition by
[@&#8203;leiserfg](https://togithub.com/leiserfg) in
[astral-sh/ruff#4206
- End of statement insertion should occur after newline by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[astral-sh/ruff#4215
- Ignore **debuggerskip** in unused variable checks by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#4229

##### CLI

- Show settings path in `--show-settings` output by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[astral-sh/ruff#4199

##### Documentation

- Allow linking to individual rules by
[@&#8203;calumy](https://togithub.com/calumy) in
[astral-sh/ruff#4158

#### New Contributors

- [@&#8203;wookie184](https://togithub.com/wookie184) made their first
contribution in
[astral-sh/ruff#4170
- [@&#8203;arya-k](https://togithub.com/arya-k) made their first
contribution in
[astral-sh/ruff#4211

**Full Changelog**:
astral-sh/ruff@v0.0.264...v0.0.265

</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:eyJjcmVhdGVkSW5WZXIiOiIzNS43MS40IiwidXBkYXRlZEluVmVyIjoiMzUuNzEuNCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
renovate bot added a commit to allenporter/pyrainbird that referenced this pull request May 7, 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.264` ->
`==0.0.265` |
[![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.265/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.265/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.265/compatibility-slim/0.0.264)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.265/confidence-slim/0.0.264)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>charliermarsh/ruff</summary>

###
[`v0.0.265`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.265)

[Compare
Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.264...v0.0.265)

<!-- Release notes generated using configuration in .github/release.yml
at main -->

#### What's Changed

##### Breaking Changes

- Change `--fix-only` exit semantics to mirror `--fix` by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#4146

##### Rules

- \[flake8-pyi] PYI020 by [@&#8203;arya-k](https://togithub.com/arya-k)
in
[astral-sh/ruff#4211
- Update B027 to support autofixing by
[@&#8203;aacunningham](https://togithub.com/aacunningham) in
[astral-sh/ruff#4178
- \[`flake8-pyi`] Implement `PYI042` and `PYI043` by
[@&#8203;arya-k](https://togithub.com/arya-k) in
[astral-sh/ruff#4214
- \[`pylint`] Implement import-self (`W0406`) by
[@&#8203;chanman3388](https://togithub.com/chanman3388) in
[astral-sh/ruff#4154
- Warn on PEP 604 syntax not in an annotation, but don't autofix by
[@&#8203;wookie184](https://togithub.com/wookie184) in
[astral-sh/ruff#4170

##### Bug Fixes

- Fix panic in pydocstyle D214 when docstring indentation is empty by
[@&#8203;madkinsz](https://togithub.com/madkinsz) in
[astral-sh/ruff#4216
- Render tabs as 4 spaces in diagnostics by
[@&#8203;MichaReiser](https://togithub.com/MichaReiser) in
[astral-sh/ruff#4132
- Fix era panic caused by out of bound edition by
[@&#8203;leiserfg](https://togithub.com/leiserfg) in
[astral-sh/ruff#4206
- End of statement insertion should occur after newline by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[astral-sh/ruff#4215
- Ignore **debuggerskip** in unused variable checks by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#4229

##### CLI

- Show settings path in `--show-settings` output by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[astral-sh/ruff#4199

##### Documentation

- Allow linking to individual rules by
[@&#8203;calumy](https://togithub.com/calumy) in
[astral-sh/ruff#4158

#### New Contributors

- [@&#8203;wookie184](https://togithub.com/wookie184) made their first
contribution in
[astral-sh/ruff#4170
- [@&#8203;arya-k](https://togithub.com/arya-k) made their first
contribution in
[astral-sh/ruff#4211

**Full Changelog**:
astral-sh/ruff@v0.0.264...v0.0.265

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

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS43MS40IiwidXBkYXRlZEluVmVyIjoiMzUuNzEuNCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

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
breaking Breaking API change cli Related to the command-line interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--fix-only returns exit code 1 upon fixes
2 participants