diff --git a/.github/workflows/fmt.yml b/.github/workflows/fmt.yml new file mode 100644 index 00000000..265ab493 --- /dev/null +++ b/.github/workflows/fmt.yml @@ -0,0 +1,23 @@ +name: fmt + +on: + pull_request: + types: [opened, synchronize] + merge_group: + types: [checks_requested] + +jobs: + ruff: + runs-on: + group: databricks-protected-runner-group + labels: linux-ubuntu-latest + + steps: + - name: Checkout repository and submodules + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Run ruff + uses: astral-sh/ruff-action@31a518504640beb4897d0b9f9e50a2a9196e75ba # v3.0.1 + with: + version: "0.9.1" + args: "format --check" diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..b25701b2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.ruff_cache diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 00000000..6845a35c --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,8 @@ +[format] +exclude = [ + # Templates are responsible for formatting at the source. + "dbt_sql/*", + "default_python/*", + "default_sql/*", + "mlops_stacks/*", +] diff --git a/contrib/data_engineering/scripts/add_asset.py b/contrib/data_engineering/scripts/add_asset.py index 72991a81..1a20ae53 100644 --- a/contrib/data_engineering/scripts/add_asset.py +++ b/contrib/data_engineering/scripts/add_asset.py @@ -11,7 +11,10 @@ def init_bundle(asset_type: AssetType) -> None: - cmd = f"databricks bundle init https://github.com/databricks/bundle-examples --template-dir contrib/templates/data-engineering/assets/{asset_type} " + " ".join(sys.argv[2:]) + cmd = ( + f"databricks bundle init https://github.com/databricks/bundle-examples --template-dir contrib/templates/data-engineering/assets/{asset_type} " + + " ".join(sys.argv[2:]) + ) subprocess.run(cmd, shell=True) diff --git a/contrib/templates/data-engineering/template/{{.project_name}}/scripts/add_asset.py b/contrib/templates/data-engineering/template/{{.project_name}}/scripts/add_asset.py index 72991a81..1a20ae53 100644 --- a/contrib/templates/data-engineering/template/{{.project_name}}/scripts/add_asset.py +++ b/contrib/templates/data-engineering/template/{{.project_name}}/scripts/add_asset.py @@ -11,7 +11,10 @@ def init_bundle(asset_type: AssetType) -> None: - cmd = f"databricks bundle init https://github.com/databricks/bundle-examples --template-dir contrib/templates/data-engineering/assets/{asset_type} " + " ".join(sys.argv[2:]) + cmd = ( + f"databricks bundle init https://github.com/databricks/bundle-examples --template-dir contrib/templates/data-engineering/assets/{asset_type} " + + " ".join(sys.argv[2:]) + ) subprocess.run(cmd, shell=True) diff --git a/contrib/templates/streamlit-app/template/{{.project_name}}/app/app.py b/contrib/templates/streamlit-app/template/{{.project_name}}/app/app.py index 8cec20ae..ba338ed2 100644 --- a/contrib/templates/streamlit-app/template/{{.project_name}}/app/app.py +++ b/contrib/templates/streamlit-app/template/{{.project_name}}/app/app.py @@ -5,9 +5,9 @@ import pandas as pd # Ensure environment variable is set correctly -assert os.getenv( - "DATABRICKS_WAREHOUSE_ID" -), "DATABRICKS_WAREHOUSE_ID must be set in app.yaml." +assert os.getenv("DATABRICKS_WAREHOUSE_ID"), ( + "DATABRICKS_WAREHOUSE_ID must be set in app.yaml." +) def sqlQuery(query: str) -> pd.DataFrame: diff --git a/knowledge_base/job_with_multiple_wheels/my_custom_wheel1/src/my_custom_wheel1/__init__.py b/knowledge_base/job_with_multiple_wheels/my_custom_wheel1/src/my_custom_wheel1/__init__.py index 79981ae4..7b614d08 100644 --- a/knowledge_base/job_with_multiple_wheels/my_custom_wheel1/src/my_custom_wheel1/__init__.py +++ b/knowledge_base/job_with_multiple_wheels/my_custom_wheel1/src/my_custom_wheel1/__init__.py @@ -3,5 +3,7 @@ """ Function to be called by [my_custom_wheel2]. """ + + def hello(): cowsay.cow("Hello, world!") diff --git a/knowledge_base/job_with_multiple_wheels/my_custom_wheel2/src/my_custom_wheel2/__init__.py b/knowledge_base/job_with_multiple_wheels/my_custom_wheel2/src/my_custom_wheel2/__init__.py index 51b098ad..02569d40 100644 --- a/knowledge_base/job_with_multiple_wheels/my_custom_wheel2/src/my_custom_wheel2/__init__.py +++ b/knowledge_base/job_with_multiple_wheels/my_custom_wheel2/src/my_custom_wheel2/__init__.py @@ -3,5 +3,7 @@ """ Function that calls into [my_custom_wheel1]. """ + + def hello(): my_custom_wheel1.hello() diff --git a/knowledge_base/job_with_multiple_wheels/src/call_wheel.py b/knowledge_base/job_with_multiple_wheels/src/call_wheel.py index 45ba8989..26a6bbab 100644 --- a/knowledge_base/job_with_multiple_wheels/src/call_wheel.py +++ b/knowledge_base/job_with_multiple_wheels/src/call_wheel.py @@ -1,4 +1,4 @@ import my_custom_wheel2 -if __name__ == '__main__': +if __name__ == "__main__": my_custom_wheel2.hello() diff --git a/knowledge_base/private_wheel_packages/src/main.py b/knowledge_base/private_wheel_packages/src/main.py index 06d5e490..ef3a0e61 100644 --- a/knowledge_base/private_wheel_packages/src/main.py +++ b/knowledge_base/private_wheel_packages/src/main.py @@ -2,5 +2,5 @@ # include an arbitrary wheel file in your bundle directory, deploy it, and use it from within your code. import cowsay -if __name__ == '__main__': - cowsay.cow('Hello, world!') +if __name__ == "__main__": + cowsay.cow("Hello, world!") diff --git a/knowledge_base/python_wheel_poetry/src/python_wheel_poetry/hello.py b/knowledge_base/python_wheel_poetry/src/python_wheel_poetry/hello.py index 5a0d7c3a..6e4200da 100644 --- a/knowledge_base/python_wheel_poetry/src/python_wheel_poetry/hello.py +++ b/knowledge_base/python_wheel_poetry/src/python_wheel_poetry/hello.py @@ -10,5 +10,7 @@ The value is the path to the function that is called when the command is run. The key is referred to in the `python_wheel_task` section in `databricks.yml`. """ + + def hello(): cowsay.cow("Hello, world!")