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

[flake8-simplify] Mark fixes as unsafe (SIM201, SIM202) #15626

Merged
merged 3 commits into from
Jan 21, 2025

Conversation

InSyncWithFoo
Copy link
Contributor

Summary

Resolves #15619.

Test Plan

cargo nextest run and cargo insta test.

Copy link
Contributor

github-actions bot commented Jan 21, 2025

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+0 -0 violations, +0 -32 fixes in 4 projects; 51 projects unchanged)

apache/airflow (+0 -0 violations, +0 -26 fixes)

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

+ airflow/models/baseoperator.py:167:38: SIM201 Use `sentinel != _sentinel` instead of `not sentinel == _sentinel`
- airflow/models/baseoperator.py:167:38: SIM201 [*] Use `sentinel != _sentinel` instead of `not sentinel == _sentinel`
+ airflow/models/dag.py:822:44: SIM201 Use `ti.state != State.NONE` instead of `not ti.state == State.NONE`
- airflow/models/dag.py:822:44: SIM201 [*] Use `ti.state != State.NONE` instead of `not ti.state == State.NONE`
+ airflow/www/views.py:5625:12: SIM201 Use `os.environ.get("AIRFLOW_ENV", None) != "development"` instead of `not os.environ.get("AIRFLOW_ENV", None) == "development"`
- airflow/www/views.py:5625:12: SIM201 [*] Use `os.environ.get("AIRFLOW_ENV", None) != "development"` instead of `not os.environ.get("AIRFLOW_ENV", None) == "development"`
+ dev/breeze/src/airflow_breeze/params/shell_params.py:358:35: SIM201 Use `self.project_name != "pre-commit"` instead of `not self.project_name == "pre-commit"`
- dev/breeze/src/airflow_breeze/params/shell_params.py:358:35: SIM201 [*] Use `self.project_name != "pre-commit"` instead of `not self.project_name == "pre-commit"`
+ dev/breeze/src/airflow_breeze/params/shell_params.py:708:17: SIM201 Use `self.backend != POSTGRES_BACKEND` instead of `not self.backend == POSTGRES_BACKEND`
- dev/breeze/src/airflow_breeze/params/shell_params.py:708:17: SIM201 [*] Use `self.backend != POSTGRES_BACKEND` instead of `not self.backend == POSTGRES_BACKEND`
+ dev/breeze/src/airflow_breeze/utils/parallel.py:400:11: SIM201 Use `len(completed_list) != total_number_of_results` instead of `not len(completed_list) == total_number_of_results`
- dev/breeze/src/airflow_breeze/utils/parallel.py:400:11: SIM201 [*] Use `len(completed_list) != total_number_of_results` instead of `not len(completed_list) == total_number_of_results`
+ providers/src/airflow/providers/cncf/kubernetes/triggers/pod.py:204:16: SIM201 Use `pod.status.phase != "Pending"` instead of `not pod.status.phase == "Pending"`
- providers/src/airflow/providers/cncf/kubernetes/triggers/pod.py:204:16: SIM201 [*] Use `pod.status.phase != "Pending"` instead of `not pod.status.phase == "Pending"`
+ providers/tests/amazon/aws/executors/ecs/test_ecs_executor.py:1045:12: SIM201 Use `set_task_state != State.REMOVED` instead of `not set_task_state == State.REMOVED`
- providers/tests/amazon/aws/executors/ecs/test_ecs_executor.py:1045:12: SIM201 [*] Use `set_task_state != State.REMOVED` instead of `not set_task_state == State.REMOVED`
+ providers/tests/amazon/aws/system/utils/test_helpers.py:129:16: SIM201 Use `result != env_id` instead of `not result == env_id`
- providers/tests/amazon/aws/system/utils/test_helpers.py:129:16: SIM201 [*] Use `result != env_id` instead of `not result == env_id`
+ providers/tests/system/docker/example_docker_copy_data.py:64:45: SIM201 Use `task_output != ""` instead of `not task_output == ""`
- providers/tests/system/docker/example_docker_copy_data.py:64:45: SIM201 [*] Use `task_output != ""` instead of `not task_output == ""`
+ scripts/ci/pre_commit/generate_airflow_diagrams.py:45:38: SIM201 Use `hash_file.read_text().strip() != str(checksum).strip()` instead of `not hash_file.read_text().strip() == str(checksum).strip()`
- scripts/ci/pre_commit/generate_airflow_diagrams.py:45:38: SIM201 [*] Use `hash_file.read_text().strip() != str(checksum).strip()` instead of `not hash_file.read_text().strip() == str(checksum).strip()`
+ scripts/in_container/run_provider_yaml_files_check.py:127:12: SIM201 Use `provider["state"] != "suspended"` instead of `not provider["state"] == "suspended"`
- scripts/in_container/run_provider_yaml_files_check.py:127:12: SIM201 [*] Use `provider["state"] != "suspended"` instead of `not provider["state"] == "suspended"`
+ tests/serialization/test_serialized_objects.py:83:16: SIM201 Use `elem.func.value.id != "cls"` instead of `not elem.func.value.id == "cls"`
- tests/serialization/test_serialized_objects.py:83:16: SIM201 [*] Use `elem.func.value.id != "cls"` instead of `not elem.func.value.id == "cls"`

binary-husky/gpt_academic (+0 -0 violations, +0 -2 fixes)

+ crazy_functions/vector_fns/vector_database.py:314:12: SIM201 Use `self.current_id != id` instead of `not self.current_id == id`
- crazy_functions/vector_fns/vector_database.py:314:12: SIM201 [*] Use `self.current_id != id` instead of `not self.current_id == id`

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

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

+ src/bokeh/server/views/ws.py:168:12: SIM201 Use `len(subprotocols) != 2` instead of `not len(subprotocols) == 2`
- src/bokeh/server/views/ws.py:168:12: SIM201 [*] Use `len(subprotocols) != 2` instead of `not len(subprotocols) == 2`

latchbio/latch (+0 -0 violations, +0 -2 fixes)

+ src/latch_cli/services/sync.py:142:12: SIM201 Use `dest[-1] != "/"` instead of `not dest[-1] == "/"`
- src/latch_cli/services/sync.py:142:12: SIM201 [*] Use `dest[-1] != "/"` instead of `not dest[-1] == "/"`

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
SIM201 32 0 0 0 32

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+0 -0 violations, +0 -32 fixes in 4 projects; 51 projects unchanged)

apache/airflow (+0 -0 violations, +0 -26 fixes)

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

+ airflow/models/baseoperator.py:167:38: SIM201 Use `sentinel != _sentinel` instead of `not sentinel == _sentinel`
- airflow/models/baseoperator.py:167:38: SIM201 [*] Use `sentinel != _sentinel` instead of `not sentinel == _sentinel`
+ airflow/models/dag.py:822:44: SIM201 Use `ti.state != State.NONE` instead of `not ti.state == State.NONE`
- airflow/models/dag.py:822:44: SIM201 [*] Use `ti.state != State.NONE` instead of `not ti.state == State.NONE`
+ airflow/www/views.py:5625:12: SIM201 Use `os.environ.get("AIRFLOW_ENV", None) != "development"` instead of `not os.environ.get("AIRFLOW_ENV", None) == "development"`
- airflow/www/views.py:5625:12: SIM201 [*] Use `os.environ.get("AIRFLOW_ENV", None) != "development"` instead of `not os.environ.get("AIRFLOW_ENV", None) == "development"`
+ dev/breeze/src/airflow_breeze/params/shell_params.py:358:35: SIM201 Use `self.project_name != "pre-commit"` instead of `not self.project_name == "pre-commit"`
- dev/breeze/src/airflow_breeze/params/shell_params.py:358:35: SIM201 [*] Use `self.project_name != "pre-commit"` instead of `not self.project_name == "pre-commit"`
+ dev/breeze/src/airflow_breeze/params/shell_params.py:708:17: SIM201 Use `self.backend != POSTGRES_BACKEND` instead of `not self.backend == POSTGRES_BACKEND`
- dev/breeze/src/airflow_breeze/params/shell_params.py:708:17: SIM201 [*] Use `self.backend != POSTGRES_BACKEND` instead of `not self.backend == POSTGRES_BACKEND`
+ dev/breeze/src/airflow_breeze/utils/parallel.py:400:11: SIM201 Use `len(completed_list) != total_number_of_results` instead of `not len(completed_list) == total_number_of_results`
- dev/breeze/src/airflow_breeze/utils/parallel.py:400:11: SIM201 [*] Use `len(completed_list) != total_number_of_results` instead of `not len(completed_list) == total_number_of_results`
+ providers/src/airflow/providers/cncf/kubernetes/triggers/pod.py:204:16: SIM201 Use `pod.status.phase != "Pending"` instead of `not pod.status.phase == "Pending"`
- providers/src/airflow/providers/cncf/kubernetes/triggers/pod.py:204:16: SIM201 [*] Use `pod.status.phase != "Pending"` instead of `not pod.status.phase == "Pending"`
+ providers/tests/amazon/aws/executors/ecs/test_ecs_executor.py:1045:12: SIM201 Use `set_task_state != State.REMOVED` instead of `not set_task_state == State.REMOVED`
- providers/tests/amazon/aws/executors/ecs/test_ecs_executor.py:1045:12: SIM201 [*] Use `set_task_state != State.REMOVED` instead of `not set_task_state == State.REMOVED`
+ providers/tests/amazon/aws/system/utils/test_helpers.py:129:16: SIM201 Use `result != env_id` instead of `not result == env_id`
- providers/tests/amazon/aws/system/utils/test_helpers.py:129:16: SIM201 [*] Use `result != env_id` instead of `not result == env_id`
+ providers/tests/system/docker/example_docker_copy_data.py:64:45: SIM201 Use `task_output != ""` instead of `not task_output == ""`
- providers/tests/system/docker/example_docker_copy_data.py:64:45: SIM201 [*] Use `task_output != ""` instead of `not task_output == ""`
+ scripts/ci/pre_commit/generate_airflow_diagrams.py:45:38: SIM201 Use `hash_file.read_text().strip() != str(checksum).strip()` instead of `not hash_file.read_text().strip() == str(checksum).strip()`
- scripts/ci/pre_commit/generate_airflow_diagrams.py:45:38: SIM201 [*] Use `hash_file.read_text().strip() != str(checksum).strip()` instead of `not hash_file.read_text().strip() == str(checksum).strip()`
+ scripts/in_container/run_provider_yaml_files_check.py:127:12: SIM201 Use `provider["state"] != "suspended"` instead of `not provider["state"] == "suspended"`
- scripts/in_container/run_provider_yaml_files_check.py:127:12: SIM201 [*] Use `provider["state"] != "suspended"` instead of `not provider["state"] == "suspended"`
+ tests/serialization/test_serialized_objects.py:83:16: SIM201 Use `elem.func.value.id != "cls"` instead of `not elem.func.value.id == "cls"`
- tests/serialization/test_serialized_objects.py:83:16: SIM201 [*] Use `elem.func.value.id != "cls"` instead of `not elem.func.value.id == "cls"`

binary-husky/gpt_academic (+0 -0 violations, +0 -2 fixes)

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

+ crazy_functions/vector_fns/vector_database.py:314:12: SIM201 Use `self.current_id != id` instead of `not self.current_id == id`
- crazy_functions/vector_fns/vector_database.py:314:12: SIM201 [*] Use `self.current_id != id` instead of `not self.current_id == id`

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

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

+ src/bokeh/server/views/ws.py:168:12: SIM201 Use `len(subprotocols) != 2` instead of `not len(subprotocols) == 2`
- src/bokeh/server/views/ws.py:168:12: SIM201 [*] Use `len(subprotocols) != 2` instead of `not len(subprotocols) == 2`

latchbio/latch (+0 -0 violations, +0 -2 fixes)

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

+ src/latch_cli/services/sync.py:142:12: SIM201 Use `dest[-1] != "/"` instead of `not dest[-1] == "/"`
- src/latch_cli/services/sync.py:142:12: SIM201 [*] Use `dest[-1] != "/"` instead of `not dest[-1] == "/"`

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
SIM201 32 0 0 0 32

@MichaReiser
Copy link
Member

Could you add a Fix safety section explaining why the fix is unsafe. It will help users to decide if they want to opt-in to this fix or not.

@MichaReiser MichaReiser added the fixes Related to suggested fixes for violations label Jan 21, 2025
Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

This looks good, thanks

@MichaReiser MichaReiser merged commit fce4adf into astral-sh:main Jan 21, 2025
21 checks passed
@InSyncWithFoo InSyncWithFoo deleted the SIM201 branch January 21, 2025 17:34
dcreager added a commit that referenced this pull request Jan 21, 2025
* main:
  Separate grouped and ungrouped nodes more clearly in AST generator (#15646)
  [`flake8-simplify`] Mark fixes as unsafe (`SIM201`, `SIM202`) (#15626)
  [red-knot] mdtest runner: include stderr for crashing tests (#15644)
  Change `EnvironmentOptions::venv-path` to `Option<SystemPathBuf>` (#15631)
  [`flake8-type-checking`] Fix some safe fixes being labeled unsafe (#15638)
  feat: Update RUF055 to do var == value (#15605)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixes Related to suggested fixes for violations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SIM201 and SIM202 fixes should be marked unsafe
2 participants