Skip to content

Conversation

@dguido
Copy link
Member

@dguido dguido commented Jan 5, 2026

Summary

Migrate from black/pylint to ruff for linting and code formatting.

Changes

Removed

  • .github/workflows/black.yml - black check workflow
  • .github/workflows/black_auto.yml - auto-fix workflow
  • .github/workflows/pylint.yml - pylint check workflow
  • .github/workflows/linter.yml - super-linter workflow
  • .github/workflows/matchers/pylint.json - pylint error matcher
  • .github/workflows/matchers/yamllint.json - yamllint error matcher

Added

  • .github/workflows/ruff.yml - ruff check workflow
  • .pre-commit-config.yaml - pre-commit hooks for local development
  • .yamllint - yamllint configuration

Modified

  • pyproject.toml - replaced [tool.black] and [tool.pylint] with [tool.ruff]
  • Makefile - updated lint and reformat targets to use ruff
  • CONTRIBUTING.md - updated linter documentation and added pre-commit section

Notes

  • The ruff config ignores many rules to avoid requiring code changes in this PR
  • Code formatting fixes will be in a follow-up PR
  • This PR can be merged independently or after the build system PR

Test plan

  • ruff check slither/ passes
  • yamllint .github/ passes
  • CI workflow runs successfully
  • pre-commit hooks work locally

🤖 Generated with Claude Code

- Remove black, black_auto, pylint, and linter workflows
- Remove pylint.json and yamllint.json matchers
- Add ruff.yml workflow for linting
- Add .pre-commit-config.yaml for local development
- Add .yamllint configuration for YAML linting
- Replace [tool.black] and [tool.pylint] with [tool.ruff] in pyproject.toml
- Update Makefile lint/reformat targets to use ruff
- Update CONTRIBUTING.md with ruff and pre-commit documentation

The ruff config ignores many rules to avoid code changes - these can be
enabled incrementally in follow-up PRs.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@dguido dguido requested review from elopez and smonicas as code owners January 5, 2026 18:58
Comment on lines 26 to 68
name: Lint Code
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Run Ruff linter
uses: astral-sh/ruff-action@v1
with:
args: "check slither/ tests/ scripts/"

# Formatting check disabled to avoid changes to existing code
# - name: Run Ruff formatter check
# run: |
# echo "::group::Checking formatting with Ruff"
# ruff format --check slither/ tests/ scripts/ || FORMAT_EXIT=$?
# echo "::endgroup::"
# if [ "${FORMAT_EXIT:-0}" -ne 0 ]; then
# echo "❌ Formatting check failed. Run 'make reformat' or 'ruff format' locally to fix formatting."
# exit $FORMAT_EXIT
# fi
# echo "✅ Formatting check passed"

- name: Set up Python for yamllint
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install and run yamllint
run: |
# Use uv for fast installation
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
uv tool install yamllint
echo "::group::Running yamllint"
uvx yamllint .github/ || YAML_EXIT=$?
echo "::endgroup::"
if [ "${YAML_EXIT:-0}" -ne 0 ]; then
echo "❌ YAML linting failed. Fix the YAML syntax errors shown above."
exit $YAML_EXIT
fi
echo "✅ YAML linting passed"

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 5 days ago

In general, the fix is to explicitly configure GITHUB_TOKEN permissions for the workflow or for the specific job, instead of relying on repository defaults. For a lint-only job that just checks code and YAML, contents: read is typically sufficient. This satisfies the principle of least privilege and the CodeQL recommendation.

For this specific workflow, the simplest and safest fix without changing functionality is to add a permissions block to the lint job, because that is the job CodeQL flagged. We can set contents: read, which allows the job to read repository contents (needed for actions/checkout@v4 to function) but prevents writes. No other permissions appear necessary for running Ruff and yamllint. Concretely, in .github/workflows/ruff.yml, under jobs: lint:, insert:

    permissions:
      contents: read

at an appropriate indentation level between name: Lint Code and runs-on: ubuntu-latest. No additional imports or external libraries are needed; this is purely a YAML configuration change.

Suggested changeset 1
.github/workflows/ruff.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml
--- a/.github/workflows/ruff.yml
+++ b/.github/workflows/ruff.yml
@@ -24,6 +24,8 @@
 jobs:
   lint:
     name: Lint Code
+    permissions:
+      contents: read
     runs-on: ubuntu-latest
 
     steps:
EOF
@@ -24,6 +24,8 @@
jobs:
lint:
name: Lint Code
permissions:
contents: read
runs-on: ubuntu-latest

steps:
Copilot is powered by AI and may make mistakes. Always verify output.
@smonicas smonicas changed the base branch from master to dev January 5, 2026 19:22
@smonicas smonicas merged commit fb20211 into dev Jan 6, 2026
45 of 46 checks passed
@smonicas smonicas deleted the migrate-to-ruff branch January 6, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants