From cabab15b99e21897aa370ede1e2c04d522b328f5 Mon Sep 17 00:00:00 2001 From: Asuka Minato Date: Sun, 4 Feb 2024 03:18:33 +0900 Subject: [PATCH] feat(bindings/python): add ruff as linter (#4135) --- .github/workflows/bindings_python.yml | 5 +++++ .../benchmark/async_origin_s3_benchmark_with_gevent.py | 8 +++----- bindings/python/pyproject.toml | 4 ++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/bindings_python.yml b/.github/workflows/bindings_python.yml index 12c38b3c15db..6621950bf893 100644 --- a/.github/workflows/bindings_python.yml +++ b/.github/workflows/bindings_python.yml @@ -40,6 +40,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Ruff Check + working-directory: "bindings/python" + run: | + pip install ruff + ruff check . - uses: PyO3/maturin-action@v1 with: working-directory: "bindings/python" 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 diff --git a/bindings/python/pyproject.toml b/bindings/python/pyproject.toml index 332669184eb3..39a326c08179 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" @@ -52,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"]