From 6ed8d8ec10e4bd22689f2d90b871f1f7ea710295 Mon Sep 17 00:00:00 2001 From: zhangyuyang Date: Fri, 21 Aug 2026 10:05:07 +0800 Subject: [PATCH 1/3] ci: add automated Ruff linting and formatting Signed-off-by: zhangyuyang --- .github/workflows/ci.yml | 11 +++++++++++ CONTRIBUTING.md | 10 ++++++++++ pyproject.toml | 21 +++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8d8ad82..a2edb83 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,17 @@ on: pull_request: jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.13" + - run: pip install -e ".[dev]" + - run: ruff check . + - run: ruff format --check . + test: runs-on: ubuntu-latest strategy: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 66a2b0b..c358276 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -61,6 +61,16 @@ python -m pytest -q Supported Python: 3.9+. +### Linting and formatting + +Install the development dependencies, then run Ruff before opening a pull +request: + +```bash +ruff check . +ruff format --check . +``` + ## Curriculum Changes Every exercise is five artifacts that must stay in sync: diff --git a/pyproject.toml b/pyproject.toml index 074cd1d..66c3915 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,6 +58,7 @@ Documentation = "https://pythonlings.abhik.ai/" dev = [ "pytest>=7.0", "pytest-asyncio>=0.21", + "ruff==0.16.4", ] [project.scripts] @@ -77,3 +78,23 @@ packages = ["pythonlings"] asyncio_mode = "auto" asyncio_default_fixture_loop_scope = "function" testpaths = ["tests"] + +[tool.ruff] +line-length = 80 +target-version = "py39" +include = ["*.py", "*.pyi", "pyproject.toml"] +extend-exclude = [ + "exercises", + "solutions", + "tests/fixtures", +] + +[tool.ruff.lint] +select = [ + "E4", + "E7", + "E9", + "E501", + "F", + "I", +] From c77b9791442facabca44b6c10ef31b1c2663d6fd Mon Sep 17 00:00:00 2001 From: zhangyuyang Date: Fri, 21 Aug 2026 11:14:06 +0800 Subject: [PATCH 2/3] ci: run Ruff checks in advisory mode --- .github/workflows/ci.yml | 9 ++++++--- CONTRIBUTING.md | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a2edb83..a940e7d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,9 +13,12 @@ jobs: - uses: actions/setup-python@v5 with: python-version: "3.13" - - run: pip install -e ".[dev]" - - run: ruff check . - - run: ruff format --check . + - name: Check lint with Ruff + continue-on-error: true + run: ruff check . + - name: Check formatting with Ruff + continue-on-error: true + run: ruff format --check . test: runs-on: ubuntu-latest diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c358276..3c1649b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -71,6 +71,10 @@ ruff check . ruff format --check . ``` +Ruff currently runs in advisory mode while existing violations are addressed +incrementally. New and modified Python files should follow its lint and format +output. + ## Curriculum Changes Every exercise is five artifacts that must stay in sync: From 3cef482377467ffa2a97d35992d569afa8c140ac Mon Sep 17 00:00:00 2001 From: zhangyuyang Date: Sat, 22 Aug 2026 16:17:38 +0800 Subject: [PATCH 3/3] ci: install development dependencies before Ruff checks --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a940e7d..f336101 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,8 @@ jobs: - uses: actions/setup-python@v5 with: python-version: "3.13" + - name: Install development dependencies + run: python -m pip install -e ".[dev]" - name: Check lint with Ruff continue-on-error: true run: ruff check .