diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 51b50a0..0000000 --- a/.flake8 +++ /dev/null @@ -1,2 +0,0 @@ -[flake8] -max-line-length = 100 \ No newline at end of file diff --git a/.github/maintainers_guide.md b/.github/maintainers_guide.md index d222f4a..67d1d44 100644 --- a/.github/maintainers_guide.md +++ b/.github/maintainers_guide.md @@ -47,10 +47,10 @@ This project contains an [`.editorconfig`](../.editorconfig) file. It is used by ### Linting & Formatting ```zsh -# Run flake8 & prettier from root directory for linting +# Run ruff & prettier from root directory for linting ./scripts/lint.sh -# Run black & prettier from root directory for code formatting +# Run ruff & prettier from root directory for code formatting ./scripts/format.sh ``` diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 9b2b016..114e8e4 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -31,7 +31,7 @@ jobs: - name: Install dependencies run: | pip install -U . - - name: Lint with flake8 & Prettier + - name: Lint with ruff & Prettier run: | bash scripts/lint.sh diff --git a/AGENTS.md b/AGENTS.md index 9c119ac..9f62d65 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -20,10 +20,10 @@ pip install -U -e . # Run a single test file ./scripts/test.sh tests/test_manifest_v2_schema.py -# Lint (flake8 for Python, Prettier for JSON) +# Lint (ruff for Python, Prettier for JSON) ./scripts/lint.sh -# Format (black for Python, Prettier for JSON) +# Format (ruff for Python, Prettier for JSON) ./scripts/format.sh ``` @@ -37,7 +37,7 @@ Tests validate manifests against the schema using `jsonschema.validate()`. Each ## Style -- Python: black, line length 100, flake8 +- Python: ruff (lint + format), line length 100, config in `pyproject.toml` - JSON: Prettier, 2-space indent, LF line endings (see `.editorconfig`) - Tests use pytest with `GIVEN/WHEN/THEN` comment structure diff --git a/pyproject.toml b/pyproject.toml index 865e499..1307b7a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,8 +6,7 @@ license = "MIT" license-files = ["LICENSE"] authors = [{ name = "Slack Technologies, LLC", email = "opensource@slack.com" }] dependencies = [ - "flake8==7.4.1", - "black==26.5.1", + "ruff==0.16.4", "pytest==9.1.1", "jsonschema==4.26.0", ] @@ -15,9 +14,29 @@ dependencies = [ [tool.setuptools] packages = ["tests"] -[tool.black] +[tool.ruff] line-length = 100 +[tool.ruff.lint] +select = ["E", "W", "F", "D"] +ignore = [ + # missing-docstring: do not add docstrings where none exist + "D100", + "D101", + "D102", + "D103", + "D104", + "D105", + "D106", + "D107", +] + +[tool.ruff.lint.pydocstyle] +convention = "google" + +[tool.ruff.format] +docstring-code-format = true + [tool.pytest.ini_options] testpaths = ["tests"] log_file = "logs/pytest.log" diff --git a/scripts/format.sh b/scripts/format.sh index d86a57b..6ea7f51 100755 --- a/scripts/format.sh +++ b/scripts/format.sh @@ -1,7 +1,8 @@ #!/bin/bash -# ./scripts/run_flake8.sh +# ./scripts/format.sh script_dir=$(dirname $0) cd ${script_dir}/.. && \ - black tests/ && \ + ruff check --fix tests/ && \ + ruff format tests/ && \ npx prettier --write schemas/**/*.json *.json tests/**/*.json diff --git a/scripts/install_all_and_run_tests.sh b/scripts/install_all_and_run_tests.sh index 1929862..9d43ff3 100755 --- a/scripts/install_all_and_run_tests.sh +++ b/scripts/install_all_and_run_tests.sh @@ -12,11 +12,9 @@ pip install -U -e . if [[ $test_target != "" ]] then - black tests/ && \ - npx prettier --write schemas/**/*.json *.json tests/**/*.json && \ + ./scripts/format.sh && \ pytest $1 else - black tests/ && \ - npx prettier --write schemas/**/*.json *.json tests/**/*.json && \ + ./scripts/format.sh && \ pytest fi diff --git a/scripts/lint.sh b/scripts/lint.sh index d8596d6..23f7d56 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -1,7 +1,8 @@ #!/bin/bash -# ./scripts/run_flake8.sh +# ./scripts/lint.sh script_dir=$(dirname $0) cd ${script_dir}/.. && \ - flake8 tests/ && \ + ruff check tests/ && \ + ruff format --check tests/ && \ npx prettier --check schemas/**/*.json *.json tests/**/*.json diff --git a/scripts/test.sh b/scripts/test.sh index effee5f..0734b77 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -10,8 +10,8 @@ test_target="$1" if [[ $test_target != "" ]] then - black tests/ && \ + ./scripts/format.sh && \ pytest -vv $1 else - black tests/ && pytest -vv + ./scripts/format.sh && pytest -vv fi