-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Replace black/pylint/super-linter with ruff #2819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dguido
wants to merge
1
commit into
master
Choose a base branch
from
pr2-replace-linters-with-ruff
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| --- | ||
| name: Lint with Ruff | ||
|
|
||
| defaults: | ||
| run: | ||
| shell: bash | ||
|
|
||
| on: | ||
| push: | ||
| branches: [master, dev] | ||
| pull_request: | ||
| branches: [master, dev] | ||
| paths: | ||
| - "**/*.py" | ||
| - "**/*.yml" | ||
| - "**/*.yaml" | ||
| - "pyproject.toml" | ||
| - ".github/workflows/ruff.yml" | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| lint: | ||
| 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" | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Copilot Autofix
AI 25 days ago
To fix the problem, we need to explicitly set the
permissionsblock in the workflow. For this workflow, the only activities are linting the code and yaml files—no steps involve writing results back to the repository, interacting with issues, or creating PRs. Therefore, the minimal permission required iscontents: read. Thepermissions:key can be added either at the workflow root (affecting all jobs) or within a specific job (affecting only that job). Since there is only one job (lint), either is acceptable; best practice is at the workflow root for simplicity. To implement the change, add a block directly below the workflowname:on line 2:No new imports or custom methods are needed for this change.