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

Ruff 0.5 #12005

Merged
merged 30 commits into from
Jun 27, 2024
Merged

Ruff 0.5 #12005

merged 30 commits into from
Jun 27, 2024

Conversation

MichaReiser
Copy link
Member

@MichaReiser MichaReiser commented Jun 24, 2024

Summary

Feature branch for Ruff 0.5.

Changes

Stabilization

Issues

WARN: Don't squash merge this PR.

TODO

  • Drop the empty Start Ruff 0.5 commit

@MichaReiser MichaReiser added this to the v0.5.0 milestone Jun 24, 2024
Copy link
Contributor

github-actions bot commented Jun 24, 2024

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+3256 -38485 violations, +0 -0 fixes in 30 projects; 20 projects unchanged)

DisnakeDev/disnake (+6 -0 violations, +0 -0 fixes)

+ disnake/ext/commands/params.py:807:12: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ disnake/state.py:456:13: PLW0133 Missing `raise` statement on exception
+ disnake/state.py:476:13: PLW0133 Missing `raise` statement on exception
+ tests/ext/commands/test_params.py:143:16: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ tests/ext/commands/test_params.py:146:16: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ tests/ext/commands/test_params.py:214:16: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks

RasaHQ/rasa (+12 -0 violations, +0 -0 fixes)

+ .github/tests/test_validate_gpus.py:26:12: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ rasa/shared/utils/io.py:66:16: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ rasa/shared/utils/io.py:68:16: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ rasa/shared/utils/io.py:93:12: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ tests/cli/test_utils.py:458:13: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ tests/cli/test_utils.py:513:12: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ tests/conftest.py:891:16: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ tests/core/test_actions.py:2811:16: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ tests/shared/core/test_domain.py:1856:13: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ tests/shared/core/training_data/story_reader/test_yaml_story_reader.py:272:12: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
... 2 additional changes omitted for project

alteryx/featuretools (+3 -0 violations, +0 -0 fixes)

+ featuretools/tests/entityset_tests/test_es.py:714:12: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ featuretools/tests/entityset_tests/test_serialization.py:130:12: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ featuretools/tests/entityset_tests/test_serialization.py:131:12: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks

PlasmaPy/PlasmaPy (+13 -0 violations, +0 -0 fixes)

+ src/plasmapy/analysis/nullpoint.py:29:1: PLW0604 `global` at module level is redundant
+ src/plasmapy/dispersion/analytical/two_fluid_.py:316:9: PLC2401 Variable name `ω` contains a non-ASCII character
+ src/plasmapy/dispersion/numerical/kinetic_alfven_.py:234:9: PLC2401 Variable name `θ` contains a non-ASCII character
+ src/plasmapy/formulary/radiation.py:123:5: PLC2401 Variable name `ω` contains a non-ASCII character
+ src/plasmapy/formulary/radiation.py:124:5: PLC2401 Variable name `ω_pe` contains a non-ASCII character
+ src/plasmapy/formulary/relativity.py:187:5: PLC2401 Variable name `γ` contains a non-ASCII character
+ src/plasmapy/formulary/relativity.py:496:30: PLC2401 Argument name `γ` contains a non-ASCII character
... 4 additional changes omitted for rule PLC2401
+ tests/dispersion/test_dispersion_functions.py:10:25: PLC2403 Module alias `π` contains a non-ASCII character
+ tests/dispersion/test_dispersion_functions.py:11:36: PLC2403 Module alias `Γ` contains a non-ASCII character
+ tests/particles/test_exceptions.py:1040:16: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
... 3 additional changes omitted for project

apache/airflow (+2089 -26780 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --no-preview --select ALL

- airflow/api/auth/backend/kerberos_auth.py:69:18: ANN101 Missing type annotation for `self` in method
- airflow/api/client/api_client.py:28:18: ANN101 Missing type annotation for `self` in method
- airflow/api/client/api_client.py:34:21: ANN101 Missing type annotation for `self` in method
- airflow/api/client/api_client.py:46:20: ANN101 Missing type annotation for `self` in method
- airflow/api/client/api_client.py:53:18: ANN101 Missing type annotation for `self` in method
- airflow/api/client/api_client.py:60:19: ANN101 Missing type annotation for `self` in method
... 24632 additional changes omitted for rule ANN101
- airflow/callbacks/callback_requests.py:57:19: ANN102 Missing type annotation for `cls` in classmethod
- airflow/callbacks/callback_requests.py:95:19: ANN102 Missing type annotation for `cls` in classmethod
+ airflow/cli/commands/dag_command.py:309:14: S603 `subprocess` call: check for execution of untrusted input
- airflow/cli/commands/dag_command.py:309:31: S603 `subprocess` call: check for execution of untrusted input
+ airflow/cli/commands/info_command.py:199:18: S603 `subprocess` call: check for execution of untrusted input
- airflow/cli/commands/info_command.py:199:35: S603 `subprocess` call: check for execution of untrusted input
+ airflow/cli/commands/internal_api_command.py:166:17: S603 `subprocess` call: check for execution of untrusted input
- airflow/cli/commands/internal_api_command.py:166:34: S603 `subprocess` call: check for execution of untrusted input
... 297 additional changes omitted for rule S603
- airflow/cli/commands/standalone_command.py:51:20: ANN102 Missing type annotation for `cls` in classmethod
+ airflow/cli/commands/task_command.py:702:38: PLR1704 Redefining argument with the local name `session`
+ airflow/configuration.py:1315:13: SIM103 Return the condition `not value is None` directly
+ airflow/dag_processing/manager.py:1268:9: SIM103 Return the condition `not self._num_run < self._max_runs` directly
- airflow/dag_processing/manager.py:498:9: ANN102 Missing type annotation for `cls` in classmethod
- airflow/dag_processing/processor.py:422:21: ANN102 Missing type annotation for `cls` in classmethod
- airflow/dag_processing/processor.py:803:21: ANN102 Missing type annotation for `cls` in classmethod
... 541 additional changes omitted for rule ANN102
+ airflow/decorators/base.py:157:13: PLR1704 Redefining argument with the local name `task_id`
+ airflow/example_dags/example_kubernetes_executor.py:132:35: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell`
- airflow/example_dags/example_kubernetes_executor.py:132:45: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell`
+ airflow/example_dags/example_kubernetes_executor.py:94:27: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell`
- airflow/example_dags/example_kubernetes_executor.py:94:37: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell`
+ airflow/jobs/backfill_job_runner.py:923:13: FURB187 [*] Use of assignment of `reversed` on list `dagrun_infos`
+ airflow/models/abstractoperator.py:439:12: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ airflow/models/abstractoperator.py:441:14: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ airflow/models/abstractoperator.py:443:14: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ airflow/models/taskinstance.py:671:5: SIM103 Return the condition `not isinstance(value, (bytearray, bytes, str))` directly
+ airflow/operators/python.py:74:5: SIM103 Return the condition directly
+ airflow/providers/airbyte/triggers/airbyte.py:120:9: SIM103 Return the condition directly
+ airflow/providers/amazon/aws/hooks/s3.py:649:13: SIM103 Return the negated condition directly
... 30 additional changes omitted for rule SIM103
... 28835 additional changes omitted for project

aws/aws-sam-cli (+1 -0 violations, +0 -0 fixes)

+ samcli/local/docker/lambda_container.py:157:9: PLR2044 [*] Line with empty comment

bokeh/bokeh (+213 -4275 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --no-preview --select ALL

- examples/output/apis/autoload_static.py:32:20: ANN101 Missing type annotation for `self` in method
- examples/output/apis/autoload_static.py:34:13: ANN101 Missing type annotation for `self` in method
- examples/output/apis/autoload_static.py:41:20: ANN101 Missing type annotation for `self` in method
- examples/output/apis/autoload_static.py:43:13: ANN101 Missing type annotation for `self` in method
+ examples/output/apis/server_document/flask_server.py:45:17: S603 `subprocess` call: check for execution of untrusted input
- examples/output/apis/server_document/flask_server.py:46:5: S603 `subprocess` call: check for execution of untrusted input
- examples/server/api/tornado_embed.py:15:13: ANN101 Missing type annotation for `self` in method
- examples/server/app/server_auth/auth.py:27:13: ANN101 Missing type annotation for `self` in method
... 4003 additional changes omitted for rule ANN101
+ examples/server/app/server_auth/auth.py:40:9: SIM103 Return the condition `bool(username == "bokeh" and password == "bokeh")` directly
+ examples/topics/stats/sinaplot.py:42:19: SIM300 [*] Yoda condition detected
... 4478 additional changes omitted for project

demisto/content (+579 -564 violations, +0 -0 fixes)

+ .github/github_workflow_scripts/utils_test.py:228:16: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ .github/github_workflow_scripts/utils_test.py:303:16: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
+ Packs/AHA/Integrations/AHA/AHA_test.py:89:12: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
- Packs/ANYRUN/Integrations/ANYRUN/ANYRUN.py:196:16: PLR1701 Merge `isinstance` calls: `isinstance(val, dict | list)`
+ Packs/ARIAPacketIntelligence/Integrations/ARIAPacketIntelligence/ARIAPacketIntelligence.py:763:9: SIM103 Return the negated condition directly
+ Packs/ARIAPacketIntelligence/Integrations/ARIAPacketIntelligence/ARIAPacketIntelligence.py:778:9: SIM103 Return the condition `self._valid(self.rcs)` directly
- Packs/AWS-GuardDuty/Integrations/AWSGuardDutyEventCollector/AWSGuardDutyEventCollector.py:33:12: PLR1701 Merge `isinstance` calls: `isinstance(obj, date | datetime)`
- Packs/AWS-GuardDuty/Integrations/AWSGuardDutyEventCollector/AWSGuardDutyEventCollector_test.py:355:12: E721 Do not compare types, use `isinstance()`
+ Packs/AWS-GuardDuty/Integrations/AWSGuardDutyEventCollector/AWSGuardDutyEventCollector_test.py:355:12: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
- Packs/AWS-GuardDuty/Integrations/AWSGuardDutyEventCollector/AWSGuardDutyEventCollector_test.py:356:12: E721 Do not compare types, use `isinstance()`
... 342 additional changes omitted for rule E721
... 1133 additional changes omitted for project

... Truncated remaining completed project reports due to GitHub comment length restrictions

Changes by rule (32 rules affected)

code total + violation - violation + fix - fix
ANN101 35387 0 35387 0 0
SIM300 4308 2403 1905 0 0
ANN102 676 0 676 0 0
E721 560 312 248 0 0
S603 454 227 227 0 0
SIM103 157 157 0 0 0
PLR1704 36 36 0 0 0
S610 22 22 0 0 0
S602 21 11 10 0 0
S604 16 8 8 0 0
FURB167 15 15 0 0 0
FURB105 12 12 0 0 0
PLR1701 11 0 11 0 0
PLR2044 10 10 0 0 0
PLC2401 9 9 0 0 0
S605 8 4 4 0 0
PERF403 6 6 0 0 0
FURB129 6 6 0 0 0
RUF100 6 2 4 0 0
PLR1736 3 3 0 0 0
PLW0133 2 2 0 0 0
PLC2403 2 2 0 0 0
D107 2 1 1 0 0
PLE0704 2 2 0 0 0
E999 2 0 2 0 0
E402 2 0 2 0 0
PLW0604 1 1 0 0 0
FURB187 1 1 0 0 0
FURB136 1 1 0 0 0
FURB177 1 1 0 0 0
PLW0128 1 1 0 0 0
RUF024 1 1 0 0 0

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+3094 -3094 violations, +0 -0 fixes in 16 projects; 1 project error; 33 projects unchanged)

aiven/aiven-client (+1 -1 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

- aiven/client/argx.py:111:57: PLR6201 Use a `set` literal when testing for membership
+ aiven/client/argx.py:111:57: PLR6201 Use a set literal when testing for membership

PlasmaPy/PlasmaPy (+67 -67 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

- src/plasmapy/dispersion/analytical/mhd_waves_.py:121:26: PLR6201 Use a `set` literal when testing for membership
+ src/plasmapy/dispersion/analytical/mhd_waves_.py:121:26: PLR6201 Use a set literal when testing for membership
- src/plasmapy/dispersion/analytical/mhd_waves_.py:131:30: PLR6201 Use a `set` literal when testing for membership
+ src/plasmapy/dispersion/analytical/mhd_waves_.py:131:30: PLR6201 Use a set literal when testing for membership
- src/plasmapy/dispersion/analytical/stix_.py:192:24: PLR6201 Use a `set` literal when testing for membership
+ src/plasmapy/dispersion/analytical/stix_.py:192:24: PLR6201 Use a set literal when testing for membership
... 107 additional changes omitted for rule PLR6201
+ src/plasmapy/dispersion/analytical/two_fluid_.py:316:9: PLC2401 Variable name `ω` contains a non-ASCII character
- src/plasmapy/dispersion/analytical/two_fluid_.py:316:9: PLC2401 Variable name `ω` contains a non-ASCII character, consider renaming it
+ src/plasmapy/dispersion/numerical/kinetic_alfven_.py:234:9: PLC2401 Variable name `θ` contains a non-ASCII character
- src/plasmapy/dispersion/numerical/kinetic_alfven_.py:234:9: PLC2401 Variable name `θ` contains a non-ASCII character, consider renaming it
... 124 additional changes omitted for project

apache/airflow (+2325 -2328 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL

- airflow/__init__.py:98:65: PLR6201 Use a `set` literal when testing for membership
+ airflow/__init__.py:98:65: PLR6201 Use a set literal when testing for membership
- airflow/__main__.py:49:31: PLR6201 Use a `set` literal when testing for membership
+ airflow/__main__.py:49:31: PLR6201 Use a set literal when testing for membership
- airflow/__main__.py:56:31: PLR6201 Use a `set` literal when testing for membership
+ airflow/__main__.py:56:31: PLR6201 Use a set literal when testing for membership
... 643 additional changes omitted for rule PLR6201
+ airflow/cli/commands/dag_command.py:309:14: S603 `subprocess` call: check for execution of untrusted input
- airflow/cli/commands/dag_command.py:309:31: S603 `subprocess` call: check for execution of untrusted input
+ airflow/cli/commands/info_command.py:199:18: S603 `subprocess` call: check for execution of untrusted input
- airflow/cli/commands/info_command.py:199:35: S603 `subprocess` call: check for execution of untrusted input
+ airflow/cli/commands/internal_api_command.py:166:17: S603 `subprocess` call: check for execution of untrusted input
- airflow/cli/commands/internal_api_command.py:166:34: S603 `subprocess` call: check for execution of untrusted input
... 297 additional changes omitted for rule S603
+ airflow/example_dags/example_kubernetes_executor.py:132:35: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell`
- airflow/example_dags/example_kubernetes_executor.py:132:45: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell`
+ airflow/example_dags/example_kubernetes_executor.py:94:27: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell`
- airflow/example_dags/example_kubernetes_executor.py:94:37: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell`
+ airflow/providers/apache/beam/hooks/beam.py:575:25: S604 Function call with `shell=True` parameter identified, security issue
- airflow/providers/apache/beam/hooks/beam.py:577:13: S604 Function call with `shell=True` parameter identified, security issue
+ airflow/providers/arangodb/sensors/arangodb.py:54:16: SIM300 [*] Yoda condition detected
- airflow/providers/arangodb/sensors/arangodb.py:54:16: SIM300 [*] Yoda conditions are discouraged, use `records != 0` instead
+ airflow/providers/google/cloud/sensors/dataproc.py:118:14: SIM300 [*] Yoda condition detected
- airflow/providers/google/cloud/sensors/dataproc.py:118:14: SIM300 [*] Yoda conditions are discouraged, use `state == JobStatus.State.DONE` instead
+ airflow/providers/google/cloud/sensors/dataproc.py:121:14: SIM300 [*] Yoda condition detected
- airflow/providers/google/cloud/sensors/dataproc.py:121:14: SIM300 [*] Yoda conditions are discouraged, use `state == JobStatus.State.ATTEMPT_FAILURE` instead
... 3649 additional changes omitted for rule SIM300
- airflow/providers/microsoft/azure/hooks/msgraph.py:327:12: PLR1701 [*] Merge `isinstance` calls: `isinstance(data, (BytesIO, bytes, str))`
- airflow/serialization/pydantic/dag.py:45:9: PLR1701 [*] Merge `isinstance` calls
- airflow/serialization/pydantic/taskinstance.py:70:8: PLR1701 [*] Merge `isinstance` calls: `isinstance(x, (BaseOperator, MappedOperator))`
+ dev/breeze/src/airflow_breeze/commands/kubernetes_commands.py:1082:13: S604 Function call with `shell=True` parameter identified, security issue
- dev/breeze/src/airflow_breeze/commands/kubernetes_commands.py:1091:17: S604 Function call with `shell=True` parameter identified, security issue
+ dev/breeze/src/airflow_breeze/commands/kubernetes_commands.py:1094:13: S604 Function call with `shell=True` parameter identified, security issue
- dev/breeze/src/airflow_breeze/commands/kubernetes_commands.py:1103:17: S604 Function call with `shell=True` parameter identified, security issue
... 11 additional changes omitted for rule S604
+ dev/breeze/src/airflow_breeze/utils/parallel.py:297:57: PLR1736 [*] List index lookup in `enumerate()` loop
- dev/breeze/src/airflow_breeze/utils/parallel.py:297:57: PLR1736 [*] Unnecessary lookup of list item by index
+ dev/breeze/src/airflow_breeze/utils/parallel.py:299:40: PLR1736 [*] List index lookup in `enumerate()` loop
- dev/breeze/src/airflow_breeze/utils/parallel.py:299:40: PLR1736 [*] Unnecessary lookup of list item by index
+ hatch_build.py:660:13: S602 `subprocess` call with `shell=True` identified, security issue
- hatch_build.py:660:59: S602 `subprocess` call with `shell=True` identified, security issue
... 4616 additional changes omitted for project

aws/aws-sam-cli (+42 -42 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

- samcli/cli/main.py:89:27: PLR6201 Use a `set` literal when testing for membership
+ samcli/cli/main.py:89:27: PLR6201 Use a set literal when testing for membership
- samcli/cli/types.py:58:56: PLR6201 Use a `set` literal when testing for membership
+ samcli/cli/types.py:58:56: PLR6201 Use a set literal when testing for membership
- samcli/cli/types.py:58:84: PLR6201 Use a `set` literal when testing for membership
+ samcli/cli/types.py:58:84: PLR6201 Use a set literal when testing for membership
- samcli/commands/_utils/custom_options/hook_name_option.py:46:28: PLR6201 Use a `set` literal when testing for membership
+ samcli/commands/_utils/custom_options/hook_name_option.py:46:28: PLR6201 Use a set literal when testing for membership
- samcli/commands/_utils/template.py:162:34: PLR6201 Use a `set` literal when testing for membership
+ samcli/commands/_utils/template.py:162:34: PLR6201 Use a set literal when testing for membership
... 74 additional changes omitted for project

bokeh/bokeh (+228 -228 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL

- examples/output/apis/file_html.py:39:48: PLR6201 Use a `set` literal when testing for membership
+ examples/output/apis/file_html.py:39:48: PLR6201 Use a set literal when testing for membership
+ examples/output/apis/server_document/flask_server.py:45:17: S603 `subprocess` call: check for execution of untrusted input
- examples/output/apis/server_document/flask_server.py:46:5: S603 `subprocess` call: check for execution of untrusted input
- examples/plotting/sprint.py:23:48: PLR6201 Use a `set` literal when testing for membership
+ examples/plotting/sprint.py:23:48: PLR6201 Use a set literal when testing for membership
+ examples/topics/stats/sinaplot.py:42:19: SIM300 [*] Yoda condition detected
- examples/topics/stats/sinaplot.py:42:19: SIM300 [*] Yoda conditions are discouraged, use `month == df.MONTH` instead
- release/checks.py:69:30: PLR6201 Use a `set` literal when testing for membership
+ release/checks.py:69:30: PLR6201 Use a set literal when testing for membership
... 51 additional changes omitted for rule PLR6201
... 446 additional changes omitted for project

freedomofpress/securedrop (+42 -40 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

+ devops/scripts/verify-mo.py:116:16: S602 `subprocess` call with `shell=True` identified, security issue
+ devops/scripts/verify-mo.py:120:26: RUF100 [*] Unused `noqa` directive (unused: `S602`)
- devops/scripts/verify-mo.py:140:35: PLR6201 Use a `set` literal when testing for membership
+ devops/scripts/verify-mo.py:140:35: PLR6201 Use a set literal when testing for membership
- molecule/ansible-config/tests/test_play_configuration.py:34:25: PLR6201 Use a `set` literal when testing for membership
+ molecule/ansible-config/tests/test_play_configuration.py:34:25: PLR6201 Use a set literal when testing for membership
- securedrop/manage.py:170:22: PLR6201 Use a `set` literal when testing for membership
+ securedrop/manage.py:170:22: PLR6201 Use a set literal when testing for membership
... 75 additional changes omitted for rule PLR6201
... 74 additional changes omitted for project

fronzbot/blinkpy (+3 -3 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

- blinkpy/auth.py:150:35: PLR6201 Use a `set` literal when testing for membership
+ blinkpy/auth.py:150:35: PLR6201 Use a set literal when testing for membership
- blinkpy/camera.py:144:41: PLR6201 Use a `set` literal when testing for membership
+ blinkpy/camera.py:144:41: PLR6201 Use a set literal when testing for membership
- blinkpy/camera.py:157:25: PLR6201 Use a `set` literal when testing for membership
+ blinkpy/camera.py:157:25: PLR6201 Use a set literal when testing for membership

... Truncated remaining completed project reports due to GitHub comment length restrictions

demisto/content (error)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in `pyproject.toml`:
  - 'ignore' -> 'lint.ignore'
  - 'select' -> 'lint.select'
  - 'unfixable' -> 'lint.unfixable'
  - 'per-file-ignores' -> 'lint.per-file-ignores'
warning: `PGH001` has been remapped to `S307`.
warning: `PGH002` has been remapped to `G010`.
warning: `PLR1701` has been remapped to `SIM101`.
ruff failed
  Cause: Selection of deprecated rule `E999` is not allowed when preview is enabled.

Changes by rule (11 rules affected)

code total + violation - violation + fix - fix
SIM300 3980 1990 1990 0 0
PLR6201 1676 838 838 0 0
S603 454 227 227 0 0
S602 21 11 10 0 0
PLC2401 18 9 9 0 0
S604 16 8 8 0 0
S605 8 4 4 0 0
PLR1736 6 3 3 0 0
PLC2403 4 2 2 0 0
PLR1701 3 0 3 0 0
RUF100 2 2 0 0 0

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

ℹ️ ecosystem check encountered format errors. (no format changes; 1 project error)

demisto/content (error)

ruff format --preview --exclude Packs/ThreatQ/Integrations/ThreatQ/ThreatQ.py

warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in `pyproject.toml`:
  - 'ignore' -> 'lint.ignore'
  - 'select' -> 'lint.select'
  - 'unfixable' -> 'lint.unfixable'
  - 'per-file-ignores' -> 'lint.per-file-ignores'
warning: `PGH001` has been remapped to `S307`.
warning: `PGH002` has been remapped to `G010`.
warning: `PLR1701` has been remapped to `SIM101`.
ruff failed
  Cause: Selection of deprecated rule `E999` is not allowed when preview is enabled.

Copy link

codspeed-hq bot commented Jun 24, 2024

CodSpeed Performance Report

Merging #12005 will degrade performances by 5.2%

Comparing ruff-0.5 (8ccbf1a) with main (55f4812)

Summary

❌ 2 (👁 2) regressions
✅ 28 untouched benchmarks

Benchmarks breakdown

Benchmark main ruff-0.5 Change
👁 linter/all-rules[large/dataset.py] 15.5 ms 16.3 ms -4.47%
👁 linter/all-rules[unicode/pypinyin.py] 2.1 ms 2.3 ms -5.2%

@Skylion007
Copy link
Contributor

Any rules are planning upgrading to stable? Like some of the refurb rules?

@charliermarsh
Copy link
Member

Yeah we do plan to stabilize some rules in this release.

Comment on lines +240 to +258
targets = [
"aarch64-apple-darwin",
"aarch64-pc-windows-msvc",
"aarch64-unknown-linux-gnu",
"aarch64-unknown-linux-musl",
"arm-unknown-linux-musleabihf",
"armv7-unknown-linux-gnueabihf",
"armv7-unknown-linux-musleabihf",
"i686-pc-windows-msvc",
"i686-unknown-linux-gnu",
"i686-unknown-linux-musl",
"powerpc64-unknown-linux-gnu",
"powerpc64le-unknown-linux-gnu",
"s390x-unknown-linux-gnu",
"x86_64-apple-darwin",
"x86_64-pc-windows-msvc",
"x86_64-unknown-linux-gnu",
"x86_64-unknown-linux-musl",
]
Copy link
Member Author

Choose a reason for hiding this comment

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

@charliermarsh does ruff now support more targets than before? ;)

@zanieb zanieb added the no-build Skip release artifact builds on this pull request label Jun 26, 2024
WindowGenerator and others added 23 commits June 27, 2024 13:30
## Summary

This rule removes `PLR1701` and redirects it to `SIM101`.

In addition to that, the `SIM101` autofix has been fixed to add padding
if required.

### `PLR1701` has bugs

It also seems that the implementation of `PLR1701` is incorrect in
multiple scenarios. For example, the following code snippet:
```py
# There are two _different_ variables `a` and `b`
if isinstance(a, int) or isinstance(b, bool) or isinstance(a, float):
    pass
# There's another condition `or 1`
if isinstance(self.k, int) or isinstance(self.k, float) or 1:
    pass
```
is fixed to:
```py
# Fixed to only considering variable `a`
if isinstance(a, (float, int)):
    pass
# The additional condition is not present in the fix
if isinstance(self.k, (float, int)):
    pass
```

Playground: https://play.ruff.rs/6cfbdfb7-f183-43b0-b59e-31e728b34190

## Documentation Preview

### `PLR1701`

<img width="1397" alt="Screenshot 2024-06-25 at 11 14 40"
src="https://github.com/astral-sh/ruff/assets/67177269/779ee84d-7c4d-4bb8-a3a4-c2b23a313eba">

## Test Plan

Remove the test cases for `PLR1701`, port the padding test case to
`SIM101` and update the snapshot.
…` (`E721`) (#11220)

## Summary

Stabilizes `E721` behavior implemented in #7905.

The functionality change in `E721` was implemented in #7905, released in
[v0.1.2](https://github.com/astral-sh/ruff/releases/tag/v0.1.2). And
seems functionally stable since #9676, without an explicit release but
would correspond to
[v0.2.0](https://github.com/astral-sh/ruff/releases/tag/v0.2.0). So the
deprecated functionally should be removable in the next minor release.

resolves: #6465
## Summary

This PR migrates our release workflow to
[`cargo-dist`](https://github.com/axodotdev/cargo-dist). The primary
motivation here is that we want to ship dedicated installers for Ruff
that work across platforms, and `cargo-dist` gives us those installers
out-of-the-box. The secondary motivation is that `cargo-dist` formalizes
some of the patterns that we've built up over time in our own release
process.

At a high level:

- The `release.yml` file is generated by `cargo-dist` with `cargo dist
generate`. It doesn't contain any modifications vis-a-vis the generated
file. (If it's edited out of band from generation, the release fails.)
- Our customizations are inserted as custom steps within the
`cargo-dist` workflow. Specifically, `build-binaries` builds the wheels
and packages them into binaries (as on `main`), while `build-docker.yml`
builds the Docker image. `publish-pypi.yml` publishes the wheels to
PyPI. This is effectively our `release.yaml` (on `main`), broken down
into individual workflows rather than steps within a single workflow.

### Changes from `main`

The workflow is _nearly_ unchanged. We kick off a release manually via
the GitHub Action by providing a tag. If the tag doesn't match the
`Cargo.toml`, the release fails. If the tag matches an already-existing
release, the release fails.

The release proceeds by (in order):

0. Doing some upfront validation via `cargo-dist`.
1. Creating the wheels and archives.
2. Building and pushing the Docker image.
3. Publishing to PyPI (if it's not a "dry run").
4. Creating the GitHub Release (if it's not a "dry run").
5. Notifying `ruff-pre-commit` (if it's not a "dry run").

There are a few changes in the workflow as compared to `main`:

- **We no longer validate the SHA** (just the tag). It's not an input to
the job. The Axo team is considering whether / how to support this.
- **Releases are now published directly** (rather than as draft). Again,
the Axo team is considering whether / how to support this. The downside
of drafts is that the URLs aren't stable, so the installers don't work
_as long as the release is in draft_. This is fine for our workflow. It
seems like the Axo team will add it.
- Releases already contain the latest entry from the changelog (we don't
need to copy it over). This "Just Works", which is nice, though we'll
still want to edit them to add contributors.

There are also a few **breaking changes** for consumers of the binaries:

- **We no longer include the version tag in the file name**. This
enables users to install via `/latest` URLs on GitHub, and is part of
the cargo-dist paradigm.
- **Archives now include an extra level of nesting,** which you can
remove with `--strip-components=1` when untarring.

Here's an example release that I created -- I omitted all the artifacts
since I was just testing a workflow, so none of the installers or links
work, but it gives you a sense for what the release looks like:
https://github.com/charliermarsh/cargodisttest/releases/tag/0.1.13.

### Test Plan

I ran a successful release to completion last night, and installed Ruff
via the installer:

![Screenshot 2024-01-17 at 12 12
53 AM](https://github.com/astral-sh/ruff/assets/1309177/a5334466-2ca3-4279-a453-e912a0805df2)

![Screenshot 2024-01-17 at 12 12
48 AM](https://github.com/astral-sh/ruff/assets/1309177/63ac969e-69a1-488c-8367-4cb783526ca7)

The piece I'm least confident about is the Docker push. We build the
image, but the push fails in my test repo since I haven't wired up the
credentials.
The motivation for this rule is solid; it's been in preview for a long
time; the implementation and tests seem sound; there are no open issues
regarding it, and as far as I can tell there never have been any.

The only issue I see is that the docs don't really describe the rule
accurately right now; I fix that in this PR.
…dless-bool` (`SIM103`) (#12048)

## Summary

See: #10414.

This is a good and intuitive change; we just put it in preview because
it expanded scope a bit.
…632`) (#12049)

## Summary

See: #8607. Rare but
uncontroversial.
…error (#11901)

## Summary

This PR updates the way syntax errors are handled throughout the linter.

The main change is that it's now not considered as a rule which involves
the following changes:
* Update `Message` to be an enum with two variants - one for diagnostic
message and the other for syntax error message
* Provide methods on the new message enum to query information required
by downstream usages

This means that the syntax errors cannot be hidden / disabled via any
disablement methods. These are:
1. Configuration via `select`, `ignore`, `per-file-ignores`, and their
`extend-*` variants
	```console
$ cargo run -- check ~/playground/ruff/src/lsp.py --extend-select=E999
--no-preview --no-cache
	    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.10s
Running `target/debug/ruff check /Users/dhruv/playground/ruff/src/lsp.py
--extend-select=E999 --no-preview --no-cache`
warning: Rule `E999` is deprecated and will be removed in a future
release. Syntax errors will always be shown regardless of whether this
rule is selected or not.
/Users/dhruv/playground/ruff/src/lsp.py:1:8: F401 [*] `abc` imported but
unused
	  |
	1 | import abc
	  |        ^^^ F401
	2 | from pathlib import Path
	3 | import os
	  |
	  = help: Remove unused import: `abc`
	```
3. Command-line flags via `--select`, `--ignore`, `--per-file-ignores`,
and their `--extend-*` variants
	```console
$ cargo run -- check ~/playground/ruff/src/lsp.py --no-cache
--config=~/playground/ruff/pyproject.toml
	    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.11s
Running `target/debug/ruff check /Users/dhruv/playground/ruff/src/lsp.py
--no-cache --config=/Users/dhruv/playground/ruff/pyproject.toml`
warning: Rule `E999` is deprecated and will be removed in a future
release. Syntax errors will always be shown regardless of whether this
rule is selected or not.
/Users/dhruv/playground/ruff/src/lsp.py:1:8: F401 [*] `abc` imported but
unused
	  |
	1 | import abc
	  |        ^^^ F401
	2 | from pathlib import Path
	3 | import os
	  |
	  = help: Remove unused import: `abc`
	```

This also means that the **output format** needs to be updated:
1. The `code`, `noqa_row`, `url` fields in the JSON output is optional
(`null` for syntax errors)
2. Other formats are changed accordingly
For each format, a new test case specific to syntax errors have been
added. Please refer to the snapshot output for the exact format for
syntax error message.

The output of the `--statistics` flag will have a blank entry for syntax
errors:
```
315     F821    [ ] undefined-name
119             [ ] syntax-error
103     F811    [ ] redefined-while-unused
```

The **language server** is updated to consider the syntax errors by
convert them into LSP diagnostic format separately.

### Preview

There are no quick fixes provided to disable syntax errors. This will
automatically work for `ruff-lsp` because the `noqa_row` field will be
`null` in that case.
<img width="772" alt="Screenshot 2024-06-26 at 14 57 08"
src="https://github.com/astral-sh/ruff/assets/67177269/aaac827e-4777-4ac8-8c68-eaf9f2c36774">

Even with `noqa` comment, the syntax error is displayed:
<img width="763" alt="Screenshot 2024-06-26 at 14 59 51"
src="https://github.com/astral-sh/ruff/assets/67177269/ba1afb68-7eaf-4b44-91af-6d93246475e2">

Rule documentation page:
<img width="1371" alt="Screenshot 2024-06-26 at 16 48 07"
src="https://github.com/astral-sh/ruff/assets/67177269/524f01df-d91f-4ac0-86cc-40e76b318b24">


## Test Plan

- [x] Disablement methods via config shows a warning
	- [x] `select`, `extend-select`
	- [ ] ~`ignore`~ _doesn't show any message_
- [ ] ~`per-file-ignores`, `extend-per-file-ignores`~ _doesn't show any
message_
- [x] Disablement methods via command-line flag shows a warning
	- [x] `--select`, `--extend-select`
	- [ ] ~`--ignore`~ _doesn't show any message_
- [ ] ~`--per-file-ignores`, `--extend-per-file-ignores`~ _doesn't show
any message_
- [x] File with syntax errors should exit with code 1
- [x] Language server
	- [x] Should show diagnostics for syntax errors
	- [x] Should not recommend a quick fix edit for adding `noqa` comment
	- [x] Same for `ruff-lsp`

resolves: #8447
## Summary

Follow-up to #11901 

This PR avoids displaying the syntax errors as log message now that the
`E999` diagnostic cannot be disabled.

For context on why this was added, refer to
#2505. Basically, we would allow
ignoring the syntax error diagnostic because certain syntax feature
weren't supported back then like `match` statement. And, if a user
ignored `E999`, Ruff would give no feedback if the source code contained
any syntax error. So, this log message was a way to indicate to the user
even if `E999` was disabled.

The current state of the parser is such that (a) it matches with the
latest grammar and (b) it's easy to add support for any new syntax.

**Note:** This PR doesn't remove the `DisplayParseError` struct because
it's still being used by the formatter.

## Test Plan

Update existing snapshots from the integration tests.
## Summary

Follow-up to #11902

This PR simplifies the `LinterResult` struct by avoiding the generic and
not store the `ParseError`.

This is possible because the callers already have access to the
`ParseError` via the `Parsed` output. This also means that we can
simplify the return type of `check_path` and avoid the generic `T` on
`LinterResult`.

## Test Plan

`cargo insta test`
## Summary

Follow-up from #11901 

This PR adds a new server setting to show / hide syntax errors.

## Test Plan

### VS Code

Using astral-sh/ruff-vscode#504 with the
following config:

```json
{
  "ruff.nativeServer": true,
  "ruff.path": ["/Users/dhruv/work/astral/ruff/target/debug/ruff"],
  "ruff.showSyntaxErrors": true
}
```

First, set `ruff.showSyntaxErrors` to `true`:
<img width="1177" alt="Screenshot 2024-06-27 at 08 34 58"
src="https://github.com/astral-sh/ruff/assets/67177269/5d77547a-a908-4a00-8714-7c00784e8679">

And then set it to `false`:
<img width="1185" alt="Screenshot 2024-06-27 at 08 35 19"
src="https://github.com/astral-sh/ruff/assets/67177269/9720f089-f10c-420b-a2c1-2bbb2245be35">

### Neovim

Using the following Ruff server config:

```lua
require('lspconfig').ruff.setup {
  init_options = {
    settings = {
      showSyntaxErrors = false,
    },
  },
}
```

First, set `showSyntaxErrors` to `true`:
<img width="1279" alt="Screenshot 2024-06-27 at 08 28 03"
src="https://github.com/astral-sh/ruff/assets/67177269/e694e231-91ba-47f8-8e8a-ad2e82b85a45">

And then set it to `false`:
<img width="1284" alt="Screenshot 2024-06-27 at 08 28 20"
src="https://github.com/astral-sh/ruff/assets/67177269/25b86a57-02b1-44f7-9f65-cf5fdde93b0c">
…ant" collections (`SIM300`) (#12050)

Co-authored-by: Alex Waygood <[email protected]>
Copy link
Member

@dhruvmanila dhruvmanila left a comment

Choose a reason for hiding this comment

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

🚀

@MichaReiser MichaReiser merged commit 04c8597 into main Jun 27, 2024
29 checks passed
@MichaReiser MichaReiser deleted the ruff-0.5 branch June 27, 2024 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-build Skip release artifact builds on this pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants