From 14f1c6df6290e6a34bcb4f597b5d64a6be8c6af8 Mon Sep 17 00:00:00 2001 From: Asuka Minato Date: Sun, 4 Feb 2024 01:20:09 +0900 Subject: [PATCH 1/9] add ruff as deps --- bindings/python/pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/bindings/python/pyproject.toml b/bindings/python/pyproject.toml index 332669184eb3..f438719ca7b0 100644 --- a/bindings/python/pyproject.toml +++ b/bindings/python/pyproject.toml @@ -42,6 +42,7 @@ benchmark = [ ] docs = ["pdoc"] test = ["pytest", "python-dotenv", "pytest-asyncio"] +lint = ["ruff"] [project.urls] Documentation = "https://opendal.apache.org/docs/python/opendal.html" From f795fa72db94693e09a685f147038b64d26cace0 Mon Sep 17 00:00:00 2001 From: Asuka Minato Date: Sun, 4 Feb 2024 01:21:58 +0900 Subject: [PATCH 2/9] add ruff in yaml --- .github/actions/behavior_test_binding_python/action.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/behavior_test_binding_python/action.yaml b/.github/actions/behavior_test_binding_python/action.yaml index 72437b08fb34..a9cdd5bce288 100644 --- a/.github/actions/behavior_test_binding_python/action.yaml +++ b/.github/actions/behavior_test_binding_python/action.yaml @@ -43,6 +43,7 @@ runs: working-directory: bindings/python run: | source venv/bin/activate + ruff check . pytest -v tests env: OPENDAL_TEST: ${{ inputs.service }} From 0554f02ad9e1d0763cd239dec4e4de1c72a3f7ac Mon Sep 17 00:00:00 2001 From: Asuka Minato Date: Sun, 4 Feb 2024 01:38:41 +0900 Subject: [PATCH 3/9] add ruff in binding_python CI --- .github/workflows/bindings_python.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/bindings_python.yml b/.github/workflows/bindings_python.yml index 12c38b3c15db..778c9cea64ee 100644 --- a/.github/workflows/bindings_python.yml +++ b/.github/workflows/bindings_python.yml @@ -60,6 +60,10 @@ jobs: - uses: actions/checkout@v4 - name: Setup Rust toolchain uses: ./.github/actions/setup + - name: Ruff Check + uses: jpetrucciani/ruff-check@0.1.0 + with: + path: "bindings/python" - uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} @@ -82,6 +86,10 @@ jobs: - uses: actions/checkout@v4 - name: Setup Rust toolchain uses: ./.github/actions/setup + - name: Ruff Check + uses: jpetrucciani/ruff-check@0.1.0 + with: + path: "bindings/python" - uses: PyO3/maturin-action@v1 with: working-directory: "bindings/python" @@ -99,6 +107,10 @@ jobs: - uses: actions/checkout@v4 - name: Setup Rust toolchain uses: ./.github/actions/setup + - name: Ruff Check + uses: jpetrucciani/ruff-check@0.1.0 + with: + path: "bindings/python" - uses: PyO3/maturin-action@v1 with: working-directory: "bindings/python" From ad3a88053ecd377afc9ed2746e99cf690e55168c Mon Sep 17 00:00:00 2001 From: Asuka Minato Date: Sun, 4 Feb 2024 01:39:17 +0900 Subject: [PATCH 4/9] remove ruff from test_binding --- .github/actions/behavior_test_binding_python/action.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/actions/behavior_test_binding_python/action.yaml b/.github/actions/behavior_test_binding_python/action.yaml index a9cdd5bce288..72437b08fb34 100644 --- a/.github/actions/behavior_test_binding_python/action.yaml +++ b/.github/actions/behavior_test_binding_python/action.yaml @@ -43,7 +43,6 @@ runs: working-directory: bindings/python run: | source venv/bin/activate - ruff check . pytest -v tests env: OPENDAL_TEST: ${{ inputs.service }} From b520ab46c68fb269790364e25046ba9d70b25203 Mon Sep 17 00:00:00 2001 From: Asuka Minato Date: Sun, 4 Feb 2024 01:47:00 +0900 Subject: [PATCH 5/9] checking it in the sdist job && not use extra actions --- .github/workflows/bindings_python.yml | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/.github/workflows/bindings_python.yml b/.github/workflows/bindings_python.yml index 778c9cea64ee..98f67615946c 100644 --- a/.github/workflows/bindings_python.yml +++ b/.github/workflows/bindings_python.yml @@ -40,6 +40,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Lint + with: + command: ruff + args: check "bindings/python" - uses: PyO3/maturin-action@v1 with: working-directory: "bindings/python" @@ -60,10 +64,6 @@ jobs: - uses: actions/checkout@v4 - name: Setup Rust toolchain uses: ./.github/actions/setup - - name: Ruff Check - uses: jpetrucciani/ruff-check@0.1.0 - with: - path: "bindings/python" - uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} @@ -86,10 +86,6 @@ jobs: - uses: actions/checkout@v4 - name: Setup Rust toolchain uses: ./.github/actions/setup - - name: Ruff Check - uses: jpetrucciani/ruff-check@0.1.0 - with: - path: "bindings/python" - uses: PyO3/maturin-action@v1 with: working-directory: "bindings/python" @@ -107,10 +103,6 @@ jobs: - uses: actions/checkout@v4 - name: Setup Rust toolchain uses: ./.github/actions/setup - - name: Ruff Check - uses: jpetrucciani/ruff-check@0.1.0 - with: - path: "bindings/python" - uses: PyO3/maturin-action@v1 with: working-directory: "bindings/python" From 394d5ca9681d875d083cf5e9acd5b17767f1c11b Mon Sep 17 00:00:00 2001 From: Asuka Minato Date: Sun, 4 Feb 2024 02:33:38 +0900 Subject: [PATCH 6/9] use run in setup Since ruff is in pyproject.toml, I guess not `pip install` here is ok --- .github/workflows/bindings_python.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/bindings_python.yml b/.github/workflows/bindings_python.yml index 98f67615946c..09b2315d0add 100644 --- a/.github/workflows/bindings_python.yml +++ b/.github/workflows/bindings_python.yml @@ -40,10 +40,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Lint with: - command: ruff - args: check "bindings/python" + working-directory: "bindings/python" + run: | + ruff check . - uses: PyO3/maturin-action@v1 with: working-directory: "bindings/python" From eafa7b68c1f02c1143f020e8ad3e70e453b967d4 Mon Sep 17 00:00:00 2001 From: Asuka Minato Date: Sun, 4 Feb 2024 02:39:06 +0900 Subject: [PATCH 7/9] to new name --- .github/workflows/bindings_python.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/bindings_python.yml b/.github/workflows/bindings_python.yml index 09b2315d0add..6621950bf893 100644 --- a/.github/workflows/bindings_python.yml +++ b/.github/workflows/bindings_python.yml @@ -40,10 +40,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - with: - working-directory: "bindings/python" - run: | - ruff check . + - name: Ruff Check + working-directory: "bindings/python" + run: | + pip install ruff + ruff check . - uses: PyO3/maturin-action@v1 with: working-directory: "bindings/python" From 651143fd19ac0ec4b72d1ce319bead3447d81b32 Mon Sep 17 00:00:00 2001 From: Asuka Minato Date: Sun, 4 Feb 2024 02:48:36 +0900 Subject: [PATCH 8/9] ignore F403, F405 ref https://github.com/apache/opendal/pull/4135#issuecomment-1925410754 --- bindings/python/pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bindings/python/pyproject.toml b/bindings/python/pyproject.toml index f438719ca7b0..39a326c08179 100644 --- a/bindings/python/pyproject.toml +++ b/bindings/python/pyproject.toml @@ -53,3 +53,6 @@ Repository = "https://github.com/apache/opendal" features = ["pyo3/extension-module"] module-name = "opendal._opendal" python-source = "python" + +[tool.ruff.lint] +ignore = ["F403", "F405"] From 4bda90ebbd7a61aea25ff30415ef66ff7564257a Mon Sep 17 00:00:00 2001 From: Asuka Minato Date: Sun, 4 Feb 2024 03:09:12 +0900 Subject: [PATCH 9/9] try fix E402 --- .../benchmark/async_origin_s3_benchmark_with_gevent.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/bindings/python/benchmark/async_origin_s3_benchmark_with_gevent.py b/bindings/python/benchmark/async_origin_s3_benchmark_with_gevent.py index a2513c98685e..c5c9eb489c3c 100644 --- a/bindings/python/benchmark/async_origin_s3_benchmark_with_gevent.py +++ b/bindings/python/benchmark/async_origin_s3_benchmark_with_gevent.py @@ -17,19 +17,17 @@ import greenify -greenify.greenify() - from gevent import monkey -monkey.patch_all() - import timeit - import gevent from boto3 import client as boto3_client from mypy_boto3_s3 import S3Client from pydantic import BaseSettings +greenify.greenify() + +monkey.patch_all() class Config(BaseSettings): aws_region: str