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

Rename format option to output-format #7514

Merged
merged 1 commit into from Sep 20, 2023

Conversation

MichaReiser
Copy link
Member

@MichaReiser MichaReiser commented Sep 19, 2023

Summary

This PR renames the check --format option to --output-format, the RUFF_FORMAT environment variable to RUFF_OUTPUT_FORMAT, and the format configuration option to output-format to avoid ambiguity and make the format option available for the formatter.

The issue #7354 suggests building support in our configuration macro. I decided against it because it requires multiple manual edits anyway (CLI, add warning, when loading the configuration from options, another warning).

Closes #7354

Test Plan

New option works

❯ cargo run --bin ruff -- check  . --no-cache --output-format=grouped
    Finished dev [unoptimized + debuginfo] target(s) in 0.14s
     Running `target/debug/ruff check . --no-cache --output-format=grouped`
crates/ruff_cli/resources/test/fixtures/cache_remove_old_files/source.py:
  4:1 F822 Undefined name `b` in `__all__`

crates/ruff_python_resolver/resources/test/airflow/airflow/api/common/mark_tasks.py:
   2:8  F401 [*] `os` imported but unused
   5:47 F401 [*] `airflow.jobs.scheduler_job_runner.SchedulerJobRunner` imported but unused
   8:38 F401 [*] `airflow.compat.functools.cached_property` imported but unused
  11:54 F401 [*] `airflow.providers.google.cloud.hooks.gcs.GCSHook` imported but unused
  14:28 F401 [*] `sqlalchemy.orm.Query` imported but unused

Found 6 errors.
[*] 5 potentially fixable with the --fix option.

The --format option works but prints a warning

❯ cargo run --bin ruff -- check  . --no-cache --format=grouped
    Finished dev [unoptimized + debuginfo] target(s) in 0.10s
     Running `target/debug/ruff check . --no-cache --format=grouped`
warning: The argument `--format=<FORMAT>` is deprecated. Use `--output-format=<FORMAT>` instead.
crates/ruff_cli/resources/test/fixtures/cache_remove_old_files/source.py:
  4:1 F822 Undefined name `b` in `__all__`

crates/ruff_python_resolver/resources/test/airflow/airflow/api/common/mark_tasks.py:
   2:8  F401 [*] `os` imported but unused
   5:47 F401 [*] `airflow.jobs.scheduler_job_runner.SchedulerJobRunner` imported but unused
   8:38 F401 [*] `airflow.compat.functools.cached_property` imported but unused
  11:54 F401 [*] `airflow.providers.google.cloud.hooks.gcs.GCSHook` imported but unused
  14:28 F401 [*] `sqlalchemy.orm.Query` imported but unused

Found 6 errors.
[*] 5 potentially fixable with the --fix option.

Using both options prints an error

❯ cargo run --bin ruff -- check  . --no-cache --format=grouped --output-format=text
    Finished dev [unoptimized + debuginfo] target(s) in 0.10s
     Running `target/debug/ruff check . --no-cache --format=grouped --output-format=text`
error: the argument '--format <FORMAT>' cannot be used with '--output-format <OUTPUT_FORMAT>'

Usage: ruff check --no-cache <FILES>...

For more information, try '--help'.

Using the old environment variable prints a warning but applies the format

❯ RUFF_FORMAT=grouped cargo run --bin ruff -- check  . --no-cache
    Finished dev [unoptimized + debuginfo] target(s) in 0.10s
     Running `target/debug/ruff check . --no-cache`
warning: The environment variable `RUFF_FORMAT` is deprecated. Use `RUFF_OUTPUT_FORMAT` instead.
crates/ruff_cli/resources/test/fixtures/cache_remove_old_files/source.py:
  4:1 F822 Undefined name `b` in `__all__`

crates/ruff_python_resolver/resources/test/airflow/airflow/api/common/mark_tasks.py:
   2:8  F401 [*] `os` imported but unused
   5:47 F401 [*] `airflow.jobs.scheduler_job_runner.SchedulerJobRunner` imported but unused
   8:38 F401 [*] `airflow.compat.functools.cached_property` imported but unused
  11:54 F401 [*] `airflow.providers.google.cloud.hooks.gcs.GCSHook` imported but unused
  14:28 F401 [*] `sqlalchemy.orm.Query` imported but unused

Found 6 errors.
[*] 5 potentially fixable with the --fix option.

Using the new environment variable works

❯ RUFF_OUTPUT_FORMAT=grouped cargo run --bin ruff -- check  . --no-cache
    Finished dev [unoptimized + debuginfo] target(s) in 0.10s
     Running `target/debug/ruff check . --no-cache`
crates/ruff_cli/resources/test/fixtures/cache_remove_old_files/source.py:
  4:1 F822 Undefined name `b` in `__all__`

crates/ruff_python_resolver/resources/test/airflow/airflow/api/common/mark_tasks.py:
   2:8  F401 [*] `os` imported but unused
   5:47 F401 [*] `airflow.jobs.scheduler_job_runner.SchedulerJobRunner` imported but unused
   8:38 F401 [*] `airflow.compat.functools.cached_property` imported but unused
  11:54 F401 [*] `airflow.providers.google.cloud.hooks.gcs.GCSHook` imported but unused
  14:28 F401 [*] `sqlalchemy.orm.Query` imported but unused

Found 6 errors.
[*] 5 potentially fixable with the --fix option.

Using both environment variables emits an error

❯ RUFF_FORMAT=text RUFF_OUTPUT_FORMAT=grouped cargo run --bin ruff -- check  . --no-cache
    Finished dev [unoptimized + debuginfo] target(s) in 0.10s
     Running `target/debug/ruff check . --no-cache`
error: the argument '--format <FORMAT>' cannot be used with '--output-format <OUTPUT_FORMAT>'

Usage: ruff check --no-cache <FILES>...

For more information, try '--help'.

Using the format option prints a warning but applies the format

[tool.ruff]
format = "grouped"
❯ cargo run --bin ruff -- check  . --no-cache
    Finished dev [unoptimized + debuginfo] target(s) in 0.14s
     Running `target/debug/ruff check . --no-cache`
warning: The option `format` has been deprecated to avoid ambiguity with Ruff's upcoming formatter. Use `format-output` instead.
crates/ruff_cli/resources/test/fixtures/cache_remove_old_files/source.py:
  4:1 F822 Undefined name `b` in `__all__`

crates/ruff_python_resolver/resources/test/airflow/airflow/api/common/mark_tasks.py:
   2:8  F401 [*] `os` imported but unused
   5:47 F401 [*] `airflow.jobs.scheduler_job_runner.SchedulerJobRunner` imported but unused
   8:38 F401 [*] `airflow.compat.functools.cached_property` imported but unused
  11:54 F401 [*] `airflow.providers.google.cloud.hooks.gcs.GCSHook` imported but unused
  14:28 F401 [*] `sqlalchemy.orm.Query` imported but unused

Found 6 errors.
[*] 5 potentially fixable with the --fix option.

Using the new output-format option applies the format

[tool.ruff]
output-format = "grouped"
❯ cargo run --bin ruff -- check  . --no-cache
    Finished dev [unoptimized + debuginfo] target(s) in 0.13s
     Running `target/debug/ruff check . --no-cache`
crates/ruff_cli/resources/test/fixtures/cache_remove_old_files/source.py:
  4:1 F822 Undefined name `b` in `__all__`

crates/ruff_python_resolver/resources/test/airflow/airflow/api/common/mark_tasks.py:
   2:8  F401 [*] `os` imported but unused
   5:47 F401 [*] `airflow.jobs.scheduler_job_runner.SchedulerJobRunner` imported but unused
   8:38 F401 [*] `airflow.compat.functools.cached_property` imported but unused
  11:54 F401 [*] `airflow.providers.google.cloud.hooks.gcs.GCSHook` imported but unused
  14:28 F401 [*] `sqlalchemy.orm.Query` imported but unused

Found 6 errors.
[*] 5 potentially fixable with the --fix option.

@MichaReiser
Copy link
Member Author

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

Copy link
Member

@konstin konstin left a comment

Choose a reason for hiding this comment

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

extra snapshot, otherwise i really like this!

@MichaReiser
Copy link
Member Author

@charliermarsh should we mark this PR as breaking or only when we remove the option entirely?

@MichaReiser MichaReiser added breaking Breaking API change cli Related to the command-line interface labels Sep 19, 2023
@MichaReiser MichaReiser marked this pull request as ready for review September 19, 2023 10:13
@github-actions
Copy link
Contributor

github-actions bot commented Sep 19, 2023

PR Check Results

Ecosystem

✅ ecosystem check detected no changes.

@charliermarsh
Copy link
Member

For how long do you anticipate leaving these deprecation warnings in place?

@charliermarsh should we mark this PR as breaking or only when we remove the option entirely?

Only when removing the option but we should call it out explicitly at the top of the release notes.

@MichaReiser MichaReiser removed the breaking Breaking API change label Sep 19, 2023
@MichaReiser MichaReiser merged commit bb4f7c6 into main Sep 20, 2023
16 checks passed
@MichaReiser MichaReiser deleted the rename-format-to-output-format branch September 20, 2023 13:19
renovate bot added a commit to allenporter/flux-local that referenced this pull request Sep 24, 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://docs.astral.sh/ruff)
([source](https://togithub.com/astral-sh/ruff),
[changelog](https://togithub.com/astral-sh/ruff/releases)) | `==0.0.290`
-> `==0.0.291` |
[![age](https://developer.mend.io/api/mc/badges/age/pypi/ruff/0.0.291?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/pypi/ruff/0.0.291?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/pypi/ruff/0.0.290/0.0.291?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/ruff/0.0.290/0.0.291?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>astral-sh/ruff (ruff)</summary>

###
[`v0.0.291`](https://togithub.com/astral-sh/ruff/releases/tag/v0.0.291)

[Compare
Source](https://togithub.com/astral-sh/ruff/compare/v0.0.290...v0.0.291)

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

#### What's Changed

##### Deprecations

**The `format` command-line argument and configuration option has been
renamed to `output-format`.** While Ruff will continue to respect
`format` when passed as a command-line argument or configuration option,
this backwards-compatible support will be dropped in a future release.
See:
[astral-sh/ruff#7514.

##### Rules

- \[`flake8-bandit`] Implement `S201`: `flask-debug-true` by
[@&#8203;mkniewallner](https://togithub.com/mkniewallner) in
[astral-sh/ruff#7503
- \[`flake8-bandit`] Implement `S507`: `ssh_no_host_key_verification` by
[@&#8203;mkniewallner](https://togithub.com/mkniewallner) in
[astral-sh/ruff#7528
- \[`flake8-logging`] Implement `LOG002`: `invalid-get-logger-argument`
by [@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[astral-sh/ruff#7399
- \[`flake8-logging`] Implement `LOG007`: `exception-without-exc-info`
by [@&#8203;qdegraaf](https://togithub.com/qdegraaf) in
[astral-sh/ruff#7410
- \[`refurb`] Implement `FURB140`: `reimplemented-starmap` by
[@&#8203;SavchenkoValeriy](https://togithub.com/SavchenkoValeriy) in
[astral-sh/ruff#7253
- \[`refurb`] Implement `FURB148`: `unnecessary-enumerate` by
[@&#8203;tjkuson](https://togithub.com/tjkuson) in
[astral-sh/ruff#7454
- \[`ruff`] Detect `asyncio.get_running_loop` calls in RUF006 by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#7562

##### Settings

- Show `--no-X` variants in CLI help by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#7504
- Rename `format` option to `output-format` by
[@&#8203;MichaReiser](https://togithub.com/MichaReiser) in
[astral-sh/ruff#7514
- Enable tab completion for `ruff rule` by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#7560

##### Bug Fixes

- Add padding to prevent some autofix errors by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#7461
- Remove parentheses when rewriting assert calls to statements by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#7464
- Avoid flagging starred elements in C402 by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#7466
- Extend `bad-dunder-method-name` to permit `attrs` dunders by
[@&#8203;tjkuson](https://togithub.com/tjkuson) in
[astral-sh/ruff#7472
- Avoid N802 violations for
[@&#8203;overload](https://togithub.com/overload) methods by
[@&#8203;JonathanPlasse](https://togithub.com/JonathanPlasse) in
[astral-sh/ruff#7498
- Avoid flagging starred expressions in UP007 by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#7505
- Ensure that LOG007 only triggers on `.exception()` calls by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#7524
- Use strict sorted and union for NoQA mapping insertion by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[astral-sh/ruff#7531
- Avoid inserting imports directly after continuation by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#7553
- Add padding in `PERF102` fixes by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#7554
- Avoid invalid fix for parenthesized values in F601 by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#7559
- Treat `os.error` as an `OSError` alias by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#7582
- Extend `bad-dunder-method-name` to permit `__html__` by
[@&#8203;jaap3](https://togithub.com/jaap3) in
[astral-sh/ruff#7492
- Fix stylist indentation with a formfeed by
[@&#8203;konstin](https://togithub.com/konstin) in
[astral-sh/ruff#7489

#### New Contributors

- [@&#8203;MicaelJarniac](https://togithub.com/MicaelJarniac) made their
first contribution in
[astral-sh/ruff#5498
- [@&#8203;maheshsaripalli9](https://togithub.com/maheshsaripalli9) made
their first contribution in
[astral-sh/ruff#7552
- [@&#8203;T-256](https://togithub.com/T-256) made their first
contribution in
[astral-sh/ruff#7585

**Full Changelog**:
astral-sh/ruff@v0.0.290...v0.0.291

</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://developer.mend.io/github/allenporter/flux-local).

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

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
shenanigansd added a commit to darbiadev/.github that referenced this pull request Sep 27, 2023
astral-sh/ruff#7514

Signed-off-by: Bradley Reynolds <bradley.reynolds@darbia.dev>
shenanigansd added a commit to darbiadev/.github that referenced this pull request Sep 27, 2023
astral-sh/ruff#7514

Signed-off-by: Bradley Reynolds <bradley.reynolds@darbia.dev>
akx added a commit to akx/ruff that referenced this pull request Oct 25, 2023
akx added a commit to akx/ruff that referenced this pull request Oct 25, 2023
akx added a commit to akx/ruff that referenced this pull request Oct 26, 2023
charliermarsh pushed a commit that referenced this pull request Oct 28, 2023
…tion warnings (#8203)

## Summary

Since `--format` was changed to `--output-format` for `check`, it feels
like it makes sense for the same to work for the auxiliary commands.

This 

* adds the same deprecation warning that used to be a thing in #7514
(and un-became a thing in #7984)

Fixes #7990.

## Test Plan

* `cargo run --bin=ruff -- rule --all --output-format=json` works
* `cargo run --bin=ruff -- rule --format=json` works with warnings
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.

Rename format option to output-format
3 participants