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

refactor: Compile time enforcement that all top level lint options are checked for deprecation #12037

Merged
merged 1 commit into from
Jun 26, 2024

Conversation

MichaReiser
Copy link
Member

Summary

Small refactor that uses Rust's destructuring to enforce that all top-level lint options are checked for deprecation.

This should also make it less likely that new options are added to the LintCommonOptions struct, because it would feel strange to add a deprecation message for a just newly introduced option.

Test Plan

cargo build

@MichaReiser MichaReiser changed the base branch from main to ruff-0.5 June 26, 2024 07:03
@MichaReiser MichaReiser added the internal An internal refactor or improvement label Jun 26, 2024
Copy link
Contributor

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+587 -36560 violations, +0 -0 fixes in 21 projects; 29 projects unchanged)

DisnakeDev/disnake (+4 -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
+ 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 (+1 -0 violations, +0 -0 fixes)

+ tests/particles/test_exceptions.py:1040:16: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks

apache/airflow (+182 -25349 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
... 24625 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/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
... 539 additional changes omitted for rule ANN102
+ 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/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/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/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))`
+ airflow/utils/pydantic.py:60:13: D107 Missing docstring in `__init__`
- airflow/utils/pydantic.py:60:13: D107 Missing docstring in `__init__`
+ 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
... 25497 additional changes omitted for project

bokeh/bokeh (+40 -4126 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
+ release/system.py:43:18: S602 `subprocess` call with `shell=True` identified, security issue
- release/system.py:43:34: S602 `subprocess` call with `shell=True` identified, security issue
... 4156 additional changes omitted for project

demisto/content (+124 -231 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/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
- Packs/Base/Scripts/DBotMLFetchData/DBotMLFetchData.py:187:23: PLR1701 Merge `isinstance` calls: `isinstance(x, bool | str)`
- Packs/Base/Scripts/DBotMLFetchData/DBotMLFetchData.py:192:37: PLR1701 Merge `isinstance` calls: `isinstance(v, bool | str)`
... 345 additional changes omitted for project

freedomofpress/securedrop (+2 -3 violations, +0 -0 fixes)

- admin/securedrop_admin/__init__.py:598:12: E721 Do not compare types, use `isinstance()`
- admin/securedrop_admin/__init__.py:600:12: E721 Do not compare types, use `isinstance()`
- admin/securedrop_admin/__init__.py:604:12: E721 Do not compare types, use `isinstance()`
+ 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`)

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

Changes by rule (12 rules affected)

code total + violation - violation + fix - fix
ANN101 35381 0 35381 0 0
ANN102 674 0 674 0 0
E721 556 312 244 0 0
S603 454 227 227 0 0
S610 22 22 0 0 0
S602 21 11 10 0 0
S604 16 8 8 0 0
PLR1701 11 0 11 0 0
S605 8 4 4 0 0
D107 2 1 1 0 0
RUF100 1 1 0 0 0
RUF024 1 1 0 0 0

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+251 -260 violations, +0 -0 fixes in 6 projects; 44 projects unchanged)

apache/airflow (+171 -174 violations, +0 -0 fixes)

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

+ 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
+ airflow/cli/commands/internal_api_command.py:179:22: S603 `subprocess` call: check for execution of untrusted input
... 296 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/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
+ dev/breeze/src/airflow_breeze/commands/kubernetes_commands.py:1106:13: S604 Function call with `shell=True` parameter identified, security issue
... 10 additional changes omitted for rule S604
+ 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
+ hatch_build.py:673:13: S602 `subprocess` call with `shell=True` identified, security issue
- hatch_build.py:673:59: S602 `subprocess` call with `shell=True` identified, security issue
+ scripts/ci/pre_commit/ruff_format.py:26:1: S602 `subprocess` call with `shell=True` identified, security issue
- scripts/ci/pre_commit/ruff_format.py:26:33: S602 `subprocess` call with `shell=True` identified, security issue
+ tests/dags/test_on_kill.py:44:13: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell`
- tests/dags/test_on_kill.py:44:23: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell`
+ tests/system/providers/amazon/aws/example_emr_eks.py:102:13: S602 `subprocess` call with `shell=True` identified, security issue
... 10 additional changes omitted for rule S602
- tests/task/task_runner/test_standard_task_runner.py:340:19: S605 Starting a process with a shell, possible injection detected
... 2 additional changes omitted for rule S605
... 314 additional changes omitted for project

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

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

+ 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
+ release/system.py:43:18: S602 `subprocess` call with `shell=True` identified, security issue
- release/system.py:43:34: S602 `subprocess` call with `shell=True` identified, security issue
- scripts/hooks/install.py:5:20: S603 `subprocess` call: check for execution of untrusted input
+ scripts/hooks/install.py:5:5: S603 `subprocess` call: check for execution of untrusted input
+ scripts/hooks/protect_branches.py:10:22: S603 `subprocess` call: check for execution of untrusted input
- scripts/hooks/protect_branches.py:10:26: S603 `subprocess` call: check for execution of untrusted input
... 69 additional changes omitted for rule S603
... 68 additional changes omitted for project

demisto/content (+0 -8 violations, +0 -0 fixes)

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

- Packs/ANYRUN/Integrations/ANYRUN/ANYRUN.py:196:16: PLR1701 Merge `isinstance` calls: `isinstance(val, dict | list)`
- Packs/AWS-GuardDuty/Integrations/AWSGuardDutyEventCollector/AWSGuardDutyEventCollector.py:33:12: PLR1701 Merge `isinstance` calls: `isinstance(obj, date | datetime)`
- Packs/Base/Scripts/DBotMLFetchData/DBotMLFetchData.py:187:23: PLR1701 Merge `isinstance` calls: `isinstance(x, bool | str)`
- Packs/Base/Scripts/DBotMLFetchData/DBotMLFetchData.py:192:37: PLR1701 Merge `isinstance` calls: `isinstance(v, bool | str)`
- Packs/Base/Scripts/DBotTrainClustering/DBotTrainClustering.py:422:8: PLR1701 Merge `isinstance` calls: `isinstance(obj, list | str)`
- Packs/BluecatAddressManager/Integrations/BluecatAddressManager/BluecatAddressManager.py:256:12: PLR1701 Merge `isinstance` calls
- Packs/ExpanseV2/Scripts/ExpanseEvidenceDynamicSection/ExpanseEvidenceDynamicSection.py:15:8: PLR1701 Merge `isinstance` calls: `isinstance(v, float | int | str)`
- Packs/TOPdesk/Integrations/TOPdesk/TOPdesk.py:577:16: PLR1701 Merge `isinstance` calls: `isinstance(value, bool | str)`

freedomofpress/securedrop (+2 -0 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`)

rotki/rotki (+3 -3 violations, +0 -0 fixes)

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

+ packaging/docker/entrypoint.py:144:11: S603 `subprocess` call: check for execution of untrusted input
- packaging/docker/entrypoint.py:144:28: S603 `subprocess` call: check for execution of untrusted input
- packaging/docker/entrypoint.py:166:26: S603 `subprocess` call: check for execution of untrusted input
+ packaging/docker/entrypoint.py:166:9: S603 `subprocess` call: check for execution of untrusted input
- packaging/docker/entrypoint.py:174:52: S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell`
+ packaging/docker/entrypoint.py:174:9: S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell`

zulip/zulip (+37 -37 violations, +0 -0 fixes)

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

+ scripts/lib/check_rabbitmq_queue.py:143:26: S603 `subprocess` call: check for execution of untrusted input
- scripts/lib/check_rabbitmq_queue.py:144:9: S603 `subprocess` call: check for execution of untrusted input
+ scripts/lib/check_rabbitmq_queue.py:160:23: S603 `subprocess` call: check for execution of untrusted input
- scripts/lib/check_rabbitmq_queue.py:161:9: S603 `subprocess` call: check for execution of untrusted input
+ scripts/lib/hash_reqs.py:38:12: S603 `subprocess` call: check for execution of untrusted input
- scripts/lib/hash_reqs.py:38:36: S603 `subprocess` call: check for execution of untrusted input
+ scripts/lib/puppet_cache.py:25:30: S603 `subprocess` call: check for execution of untrusted input
- scripts/lib/puppet_cache.py:27:9: S603 `subprocess` call: check for execution of untrusted input
+ scripts/lib/setup_venv.py:179:31: S603 `subprocess` call: check for execution of untrusted input
- scripts/lib/setup_venv.py:179:55: S603 `subprocess` call: check for execution of untrusted input
... 64 additional changes omitted for project

Changes by rule (6 rules affected)

code total + violation - violation + fix - fix
S603 454 227 227 0 0
S602 21 11 10 0 0
S604 16 8 8 0 0
PLR1701 11 0 11 0 0
S605 8 4 4 0 0
RUF100 1 1 0 0 0

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@MichaReiser MichaReiser merged commit 2bfa34a into ruff-0.5 Jun 26, 2024
39 checks passed
@MichaReiser MichaReiser deleted the top-level-lint-options-deprecation-check branch June 26, 2024 07:40
MichaReiser added a commit that referenced this pull request Jun 27, 2024
MichaReiser added a commit that referenced this pull request Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal An internal refactor or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants