diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 05bf7cf..fff448e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,22 @@ on: pull_request: jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - 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 . + - name: Check formatting with Ruff + continue-on-error: true + run: ruff format --check . + test: name: ${{ matrix.os }} py${{ matrix.python-version }} runs-on: ${{ matrix.os }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 66a2b0b..3c1649b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -61,6 +61,20 @@ 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 . +``` + +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: diff --git a/pyproject.toml b/pyproject.toml index 404ee95..a91ebda 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", +]