This is an automated email from the ASF dual-hosted git repository. potiuk pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push: new 11c46fd2ec Upgrade to latest ruff and remove ISC001 warning from output (#36649) 11c46fd2ec is described below commit 11c46fd2ec165da32202b464be7c2df5cca4d6c0 Author: Jarek Potiuk <ja...@potiuk.com> AuthorDate: Sun Jan 7 20:02:08 2024 +0100 Upgrade to latest ruff and remove ISC001 warning from output (#36649) This PR upgrades to latest ruff, and removes the ISC001 warning that warns us against potential conflict between ruff and ruff-formatter when two strings in one line get concatenated. This warning makes sense if you run both ruff and formatting at the same time, but in our case we are doing it in two separate steps - one step is to run ruff linting and the second step is to run formatting and running formatting already runs after linting is complete. This warnign is pretty misleading as it distracts from real formatting issues you might have. There is - unfortunately - no standard way to remove the warning so we have to do it a little "around" - rather than running the pre-commit directly from ruff website, we run our local pre-commit with few lines of Python code that runs ruff through shell and greps out the ISC001 warning. We also force color to make sure the output is still coloured. --- .pre-commit-config.yaml | 32 ++-- STATIC_CODE_CHECKS.rst | 4 +- airflow/contrib/operators/__init__.py | 189 ++++++++++-------------- airflow/contrib/secrets/__init__.py | 2 +- airflow/contrib/sensors/__init__.py | 10 +- airflow/contrib/utils/__init__.py | 4 +- pyproject.toml | 2 +- scripts/ci/pre_commit/pre_commit_ruff_format.py | 26 ++++ setup.py | 2 +- 9 files changed, 131 insertions(+), 140 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4923e4e7ea..c850b3e701 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -173,18 +173,6 @@ repos: additional_dependencies: ['pyyaml'] pass_filenames: false require_serial: true - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.8 - hooks: - # Since ruff makes use of multiple cores we _purposefully_ don't run this in docker so it can use the - # host CPU to it's fullest - - id: ruff - name: ruff-lint - args: [--fix] - exclude: ^.*/.*_vendor/|^tests/dags/test_imports.py - - id: ruff-format - name: ruff-format - exclude: ^.*/.*_vendor/|^tests/dags/test_imports.py|^airflow/contrib/ - repo: https://github.com/asottile/blacken-docs rev: 1.16.0 hooks: @@ -300,6 +288,26 @@ repos: # changes quickly - especially when we want the early modifications from the first local group # to be applied before the non-local pre-commits are run hooks: + - id: ruff + name: Run 'ruff' for extremely fast Python linting + description: "Run 'ruff' for extremely fast Python linting" + entry: ruff check --force-exclude + language: python + types_or: [python, pyi] + args: [--fix] + require_serial: true + additional_dependencies: ["ruff==0.1.11"] + exclude: ^.*/.*_vendor/|^tests/dags/test_imports.py + - id: ruff-format + name: Run 'ruff format' for extremely fast Python formatting + description: "Run 'ruff format' for extremely fast Python formatting" + entry: ./scripts/ci/pre_commit/pre_commit_ruff_format.py + language: python + types_or: [python, pyi] + args: [] + require_serial: true + additional_dependencies: ["ruff==0.1.11"] + exclude: ^.*/.*_vendor/|^tests/dags/test_imports.py|^airflow/contrib/ - id: replace-bad-characters name: Replace bad characters entry: ./scripts/ci/pre_commit/pre_commit_replace_bad_characters.py diff --git a/STATIC_CODE_CHECKS.rst b/STATIC_CODE_CHECKS.rst index 7e093aa0c4..d4a87879f8 100644 --- a/STATIC_CODE_CHECKS.rst +++ b/STATIC_CODE_CHECKS.rst @@ -360,9 +360,9 @@ require Breeze Docker image to be built locally. +-----------------------------------------------------------+--------------------------------------------------------------+---------+ | rst-backticks | Check if RST files use double backticks for code | | +-----------------------------------------------------------+--------------------------------------------------------------+---------+ -| ruff | ruff-lint | | +| ruff | Run 'ruff' for extremely fast Python linting | | +-----------------------------------------------------------+--------------------------------------------------------------+---------+ -| ruff-format | ruff-format | | +| ruff-format | Run 'ruff format' for extremely fast Python formatting | | +-----------------------------------------------------------+--------------------------------------------------------------+---------+ | shellcheck | Check Shell scripts syntax correctness | | +-----------------------------------------------------------+--------------------------------------------------------------+---------+ diff --git a/airflow/contrib/operators/__init__.py b/airflow/contrib/operators/__init__.py index 0bfa8e6724..c2df414301 100644 --- a/airflow/contrib/operators/__init__.py +++ b/airflow/contrib/operators/__init__.py @@ -180,9 +180,8 @@ __deprecated_classes = { "DataprocDeleteClusterOperator": ( "airflow.providers.google.cloud.operators.dataproc.DataprocDeleteClusterOperator" ), - "DataprocInstantiateInlineWorkflowTemplateOperator": - "airflow.providers.google.cloud.operators.dataproc." - "DataprocInstantiateInlineWorkflowTemplateOperator", + "DataprocInstantiateInlineWorkflowTemplateOperator": "airflow.providers.google.cloud.operators.dataproc." + "DataprocInstantiateInlineWorkflowTemplateOperator", "DataprocInstantiateWorkflowTemplateOperator": ( "airflow.providers.google.cloud.operators.dataproc.DataprocInstantiateWorkflowTemplateOperator" ), @@ -240,9 +239,8 @@ __deprecated_classes = { "DataProcSparkSqlOperator": ( "airflow.providers.google.cloud.operators.dataproc.DataprocSubmitSparkSqlJobOperator" ), - "DataprocWorkflowTemplateInstantiateInlineOperator": - "airflow.providers.google.cloud.operators.dataproc." - "DataprocInstantiateInlineWorkflowTemplateOperator", + "DataprocWorkflowTemplateInstantiateInlineOperator": "airflow.providers.google.cloud.operators.dataproc." + "DataprocInstantiateInlineWorkflowTemplateOperator", "DataprocWorkflowTemplateInstantiateOperator": ( "airflow.providers.google.cloud.operators.dataproc.DataprocInstantiateWorkflowTemplateOperator" ), @@ -351,9 +349,8 @@ __deprecated_classes = { "ComputeEngineCopyInstanceTemplateOperator": ( "airflow.providers.google.cloud.operators.compute.ComputeEngineCopyInstanceTemplateOperator" ), - "ComputeEngineInstanceGroupUpdateManagerTemplateOperator": - "airflow.providers.google.cloud.operators.compute." - "ComputeEngineInstanceGroupUpdateManagerTemplateOperator", + "ComputeEngineInstanceGroupUpdateManagerTemplateOperator": "airflow.providers.google.cloud.operators.compute." + "ComputeEngineInstanceGroupUpdateManagerTemplateOperator", "ComputeEngineSetMachineTypeOperator": ( "airflow.providers.google.cloud.operators.compute.ComputeEngineSetMachineTypeOperator" ), @@ -364,9 +361,8 @@ __deprecated_classes = { "airflow.providers.google.cloud.operators.compute.ComputeEngineStopInstanceOperator" ), "GceBaseOperator": "airflow.providers.google.cloud.operators.compute.ComputeEngineBaseOperator", - "GceInstanceGroupManagerUpdateTemplateOperator": - "airflow.providers.google.cloud.operators.compute." - "ComputeEngineInstanceGroupUpdateManagerTemplateOperator", + "GceInstanceGroupManagerUpdateTemplateOperator": "airflow.providers.google.cloud.operators.compute." + "ComputeEngineInstanceGroupUpdateManagerTemplateOperator", "GceInstanceStartOperator": ( "airflow.providers.google.cloud.operators.compute.ComputeEngineStartInstanceOperator" ), @@ -513,30 +509,22 @@ __deprecated_classes = { ), }, "gcp_natural_language_operator": { - "CloudNaturalLanguageAnalyzeEntitiesOperator": - "airflow.providers.google.cloud.operators.natural_language." - "CloudNaturalLanguageAnalyzeEntitiesOperator", - "CloudNaturalLanguageAnalyzeEntitySentimentOperator": - "airflow.providers.google.cloud.operators.natural_language." - "CloudNaturalLanguageAnalyzeEntitySentimentOperator", - "CloudNaturalLanguageAnalyzeSentimentOperator": - "airflow.providers.google.cloud.operators.natural_language." - "CloudNaturalLanguageAnalyzeSentimentOperator", - "CloudNaturalLanguageClassifyTextOperator": - "airflow.providers.google.cloud.operators.natural_language." - "CloudNaturalLanguageClassifyTextOperator", - "CloudLanguageAnalyzeEntitiesOperator": - "airflow.providers.google.cloud.operators.natural_language." - "CloudNaturalLanguageAnalyzeEntitiesOperator", - "CloudLanguageAnalyzeEntitySentimentOperator": - "airflow.providers.google.cloud.operators.natural_language." - "CloudNaturalLanguageAnalyzeEntitySentimentOperator", - "CloudLanguageAnalyzeSentimentOperator": - "airflow.providers.google.cloud.operators.natural_language." - "CloudNaturalLanguageAnalyzeSentimentOperator", - "CloudLanguageClassifyTextOperator": - "airflow.providers.google.cloud.operators.natural_language." - "CloudNaturalLanguageClassifyTextOperator", + "CloudNaturalLanguageAnalyzeEntitiesOperator": "airflow.providers.google.cloud.operators.natural_language." + "CloudNaturalLanguageAnalyzeEntitiesOperator", + "CloudNaturalLanguageAnalyzeEntitySentimentOperator": "airflow.providers.google.cloud.operators.natural_language." + "CloudNaturalLanguageAnalyzeEntitySentimentOperator", + "CloudNaturalLanguageAnalyzeSentimentOperator": "airflow.providers.google.cloud.operators.natural_language." + "CloudNaturalLanguageAnalyzeSentimentOperator", + "CloudNaturalLanguageClassifyTextOperator": "airflow.providers.google.cloud.operators.natural_language." + "CloudNaturalLanguageClassifyTextOperator", + "CloudLanguageAnalyzeEntitiesOperator": "airflow.providers.google.cloud.operators.natural_language." + "CloudNaturalLanguageAnalyzeEntitiesOperator", + "CloudLanguageAnalyzeEntitySentimentOperator": "airflow.providers.google.cloud.operators.natural_language." + "CloudNaturalLanguageAnalyzeEntitySentimentOperator", + "CloudLanguageAnalyzeSentimentOperator": "airflow.providers.google.cloud.operators.natural_language." + "CloudNaturalLanguageAnalyzeSentimentOperator", + "CloudLanguageClassifyTextOperator": "airflow.providers.google.cloud.operators.natural_language." + "CloudNaturalLanguageClassifyTextOperator", }, "gcp_spanner_operator": { "SpannerDeleteDatabaseInstanceOperator": ( @@ -692,66 +680,46 @@ __deprecated_classes = { ), }, "gcp_transfer_operator": { - "CloudDataTransferServiceCancelOperationOperator": - "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." - "CloudDataTransferServiceCancelOperationOperator", - "CloudDataTransferServiceCreateJobOperator": - "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." - "CloudDataTransferServiceCreateJobOperator", - "CloudDataTransferServiceDeleteJobOperator": - "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." - "CloudDataTransferServiceDeleteJobOperator", - "CloudDataTransferServiceGCSToGCSOperator": - "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." - "CloudDataTransferServiceGCSToGCSOperator", - "CloudDataTransferServiceGetOperationOperator": - "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." - "CloudDataTransferServiceGetOperationOperator", - "CloudDataTransferServiceListOperationsOperator": - "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." - "CloudDataTransferServiceListOperationsOperator", - "CloudDataTransferServicePauseOperationOperator": - "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." - "CloudDataTransferServicePauseOperationOperator", - "CloudDataTransferServiceResumeOperationOperator": - "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." - "CloudDataTransferServiceResumeOperationOperator", - "CloudDataTransferServiceS3ToGCSOperator": - "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." - "CloudDataTransferServiceS3ToGCSOperator", - "CloudDataTransferServiceUpdateJobOperator": - "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." - "CloudDataTransferServiceUpdateJobOperator", - "GcpTransferServiceJobCreateOperator": - "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." - "CloudDataTransferServiceCreateJobOperator", - "GcpTransferServiceJobDeleteOperator": - "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." - "CloudDataTransferServiceDeleteJobOperator", - "GcpTransferServiceJobUpdateOperator": - "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." - "CloudDataTransferServiceUpdateJobOperator", - "GcpTransferServiceOperationCancelOperator": - "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." - "CloudDataTransferServiceCancelOperationOperator", - "GcpTransferServiceOperationGetOperator": - "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." - "CloudDataTransferServiceGetOperationOperator", - "GcpTransferServiceOperationPauseOperator": - "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." - "CloudDataTransferServicePauseOperationOperator", - "GcpTransferServiceOperationResumeOperator": - "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." - "CloudDataTransferServiceResumeOperationOperator", - "GcpTransferServiceOperationsListOperator": - "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." - "CloudDataTransferServiceListOperationsOperator", - "GoogleCloudStorageToGoogleCloudStorageTransferOperator": - "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." - "CloudDataTransferServiceGCSToGCSOperator", - "S3ToGoogleCloudStorageTransferOperator": - "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." - "CloudDataTransferServiceS3ToGCSOperator", + "CloudDataTransferServiceCancelOperationOperator": "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." + "CloudDataTransferServiceCancelOperationOperator", + "CloudDataTransferServiceCreateJobOperator": "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." + "CloudDataTransferServiceCreateJobOperator", + "CloudDataTransferServiceDeleteJobOperator": "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." + "CloudDataTransferServiceDeleteJobOperator", + "CloudDataTransferServiceGCSToGCSOperator": "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." + "CloudDataTransferServiceGCSToGCSOperator", + "CloudDataTransferServiceGetOperationOperator": "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." + "CloudDataTransferServiceGetOperationOperator", + "CloudDataTransferServiceListOperationsOperator": "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." + "CloudDataTransferServiceListOperationsOperator", + "CloudDataTransferServicePauseOperationOperator": "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." + "CloudDataTransferServicePauseOperationOperator", + "CloudDataTransferServiceResumeOperationOperator": "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." + "CloudDataTransferServiceResumeOperationOperator", + "CloudDataTransferServiceS3ToGCSOperator": "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." + "CloudDataTransferServiceS3ToGCSOperator", + "CloudDataTransferServiceUpdateJobOperator": "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." + "CloudDataTransferServiceUpdateJobOperator", + "GcpTransferServiceJobCreateOperator": "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." + "CloudDataTransferServiceCreateJobOperator", + "GcpTransferServiceJobDeleteOperator": "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." + "CloudDataTransferServiceDeleteJobOperator", + "GcpTransferServiceJobUpdateOperator": "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." + "CloudDataTransferServiceUpdateJobOperator", + "GcpTransferServiceOperationCancelOperator": "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." + "CloudDataTransferServiceCancelOperationOperator", + "GcpTransferServiceOperationGetOperator": "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." + "CloudDataTransferServiceGetOperationOperator", + "GcpTransferServiceOperationPauseOperator": "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." + "CloudDataTransferServicePauseOperationOperator", + "GcpTransferServiceOperationResumeOperator": "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." + "CloudDataTransferServiceResumeOperationOperator", + "GcpTransferServiceOperationsListOperator": "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." + "CloudDataTransferServiceListOperationsOperator", + "GoogleCloudStorageToGoogleCloudStorageTransferOperator": "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." + "CloudDataTransferServiceGCSToGCSOperator", + "S3ToGoogleCloudStorageTransferOperator": "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." + "CloudDataTransferServiceS3ToGCSOperator", }, "gcp_translate_operator": { "CloudTranslateTextOperator": ( @@ -767,15 +735,12 @@ __deprecated_classes = { ), }, "gcp_video_intelligence_operator": { - "CloudVideoIntelligenceDetectVideoExplicitContentOperator": - "airflow.providers.google.cloud.operators.video_intelligence." - "CloudVideoIntelligenceDetectVideoExplicitContentOperator", - "CloudVideoIntelligenceDetectVideoLabelsOperator": - "airflow.providers.google.cloud.operators.video_intelligence." - "CloudVideoIntelligenceDetectVideoLabelsOperator", - "CloudVideoIntelligenceDetectVideoShotsOperator": - "airflow.providers.google.cloud.operators.video_intelligence." - "CloudVideoIntelligenceDetectVideoShotsOperator", + "CloudVideoIntelligenceDetectVideoExplicitContentOperator": "airflow.providers.google.cloud.operators.video_intelligence." + "CloudVideoIntelligenceDetectVideoExplicitContentOperator", + "CloudVideoIntelligenceDetectVideoLabelsOperator": "airflow.providers.google.cloud.operators.video_intelligence." + "CloudVideoIntelligenceDetectVideoLabelsOperator", + "CloudVideoIntelligenceDetectVideoShotsOperator": "airflow.providers.google.cloud.operators.video_intelligence." + "CloudVideoIntelligenceDetectVideoShotsOperator", }, "gcp_vision_operator": { "CloudVisionAddProductToProductSetOperator": ( @@ -945,9 +910,7 @@ __deprecated_classes = { "JiraOperator": "airflow.providers.atlassian.jira.operators.jira.JiraOperator", }, "kubernetes_pod_operator": { - "KubernetesPodOperator": ( - "airflow.providers.cncf.kubernetes.operators.pod.KubernetesPodOperator" - ), + "KubernetesPodOperator": ("airflow.providers.cncf.kubernetes.operators.pod.KubernetesPodOperator"), }, "mlengine_operator": { "MLEngineManageModelOperator": ( @@ -997,9 +960,8 @@ __deprecated_classes = { "OpsgenieAlertOperator": "airflow.providers.opsgenie.operators.opsgenie.OpsgenieCreateAlertOperator", }, "oracle_to_azure_data_lake_transfer": { - "OracleToAzureDataLakeOperator": - "airflow.providers.microsoft.azure.transfers." - "oracle_to_azure_data_lake.OracleToAzureDataLakeOperator", + "OracleToAzureDataLakeOperator": "airflow.providers.microsoft.azure.transfers." + "oracle_to_azure_data_lake.OracleToAzureDataLakeOperator", }, "oracle_to_oracle_transfer": { "OracleToOracleOperator": ( @@ -1056,9 +1018,8 @@ __deprecated_classes = { "S3ToGCSOperator": "airflow.providers.google.cloud.transfers.s3_to_gcs.S3ToGCSOperator", }, "s3_to_gcs_transfer_operator": { - "CloudDataTransferServiceS3ToGCSOperator": - "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." - "CloudDataTransferServiceS3ToGCSOperator", + "CloudDataTransferServiceS3ToGCSOperator": "airflow.providers.google.cloud.operators.cloud_storage_transfer_service." + "CloudDataTransferServiceS3ToGCSOperator", }, "s3_to_sftp_operator": { "S3ToSFTPOperator": "airflow.providers.amazon.aws.transfers.s3_to_sftp.S3ToSFTPOperator", diff --git a/airflow/contrib/secrets/__init__.py b/airflow/contrib/secrets/__init__.py index 7498cf0fc5..d97107bfed 100644 --- a/airflow/contrib/secrets/__init__.py +++ b/airflow/contrib/secrets/__init__.py @@ -26,7 +26,7 @@ from airflow.utils.deprecation_tools import add_deprecated_classes warnings.warn( "This module is deprecated. Please use airflow.providers.*.secrets.", RemovedInAirflow3Warning, - stacklevel=2 + stacklevel=2, ) __deprecated_classes = { diff --git a/airflow/contrib/sensors/__init__.py b/airflow/contrib/sensors/__init__.py index 9d9d1c1557..811263de75 100644 --- a/airflow/contrib/sensors/__init__.py +++ b/airflow/contrib/sensors/__init__.py @@ -85,12 +85,10 @@ __deprecated_classes = { "FTPSSensor": "airflow.providers.ftp.sensors.ftp.FTPSSensor", }, "gcp_transfer_sensor": { - "CloudDataTransferServiceJobStatusSensor": - "airflow.providers.google.cloud.sensors.cloud_storage_transfer_service." - "CloudDataTransferServiceJobStatusSensor", - "GCPTransferServiceWaitForJobStatusSensor": - "airflow.providers.google.cloud.sensors.cloud_storage_transfer_service." - "CloudDataTransferServiceJobStatusSensor", + "CloudDataTransferServiceJobStatusSensor": "airflow.providers.google.cloud.sensors.cloud_storage_transfer_service." + "CloudDataTransferServiceJobStatusSensor", + "GCPTransferServiceWaitForJobStatusSensor": "airflow.providers.google.cloud.sensors.cloud_storage_transfer_service." + "CloudDataTransferServiceJobStatusSensor", }, "gcs_sensor": { "GCSObjectExistenceSensor": "airflow.providers.google.cloud.sensors.gcs.GCSObjectExistenceSensor", diff --git a/airflow/contrib/utils/__init__.py b/airflow/contrib/utils/__init__.py index c24b7a24e9..0202a1c7c1 100644 --- a/airflow/contrib/utils/__init__.py +++ b/airflow/contrib/utils/__init__.py @@ -24,9 +24,7 @@ from airflow.exceptions import RemovedInAirflow3Warning from airflow.utils.deprecation_tools import add_deprecated_classes warnings.warn( - "This module is deprecated. Please use `airflow.utils`.", - RemovedInAirflow3Warning, - stacklevel=2 + "This module is deprecated. Please use `airflow.utils`.", RemovedInAirflow3Warning, stacklevel=2 ) __deprecated_classes = { diff --git a/pyproject.toml b/pyproject.toml index cab623dd1b..cf64a13b3b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,7 +65,7 @@ extend-select = [ "ISC", # Checks for implicit literal string concatenation (auto-fixable) "B006", # Checks for uses of mutable objects as function argument defaults. ] -extend-ignore = [ +ignore = [ "D203", "D212", "D213", diff --git a/scripts/ci/pre_commit/pre_commit_ruff_format.py b/scripts/ci/pre_commit/pre_commit_ruff_format.py new file mode 100755 index 0000000000..f7f9f0f599 --- /dev/null +++ b/scripts/ci/pre_commit/pre_commit_ruff_format.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +from __future__ import annotations + +import os +import subprocess + +ruff_format_cmd = "ruff format --force-exclude 2>&1 | grep -v '`ISC001`. To avoid unexpected behavior'" +envcopy = os.environ.copy() +envcopy["CLICOLOR_FORCE"] = "1" +subprocess.run(ruff_format_cmd, shell=True, check=True, env=envcopy) diff --git a/setup.py b/setup.py index a5f29d694e..60fcf88724 100644 --- a/setup.py +++ b/setup.py @@ -470,7 +470,7 @@ _devel_only_sentry = [ _devel_only_static_checks = [ "pre-commit", "black", - "ruff>=0.0.219", + "ruff==0.1.11", "yamllint", ]