Skip to content

Commit

Permalink
pre-commit: switch from pylint and black to ruff
Browse files Browse the repository at this point in the history
problem: pylint doesn't run under pre-commit properly, and both black
and pylint are slow

solution: switch to ruff, which is very, very fast and implements both
as well as isort, also run it so this will pass (which is why unused
imports are removed here). Also remove the rule from the gh actions
setup so we don't run both.
  • Loading branch information
trws committed Aug 20, 2024
1 parent 95046e2 commit b579e52
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 27 deletions.
16 changes: 0 additions & 16 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,6 @@ jobs:
- name: format and linting checks
run: pre-commit run --all-files --show-diff-on-failure

python-lint:
name: python lint
runs-on: ubuntu-20.04
steps:
- uses: actions/setup-python@v5
with:
python-version: 3.8
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: install pylint
run: python3 -m pip install 'pylint==2.4.4' --force-reinstall
- name: run pylint
run: ./scripts/pylint

generate-matrix:
# https://stackoverflow.com/questions/59977364
name: Generate build matrix
Expand Down
15 changes: 9 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ repos:
- id: trailing-whitespace
- id: mixed-line-ending

- repo: local
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.1
hooks:
- id: black
name: black
language: python
types: [python]
entry: black
# Run the linter.
- id: ruff
types_or: [ python, pyi ]
args: [ --fix ]
# Run the formatter.
- id: ruff-format
types_or: [ python, pyi ]

- repo: https://github.com/pre-commit/mirrors-clang-format
# this is the release of 18.1.6
Expand Down
18 changes: 18 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Same as Black.
line-length = 88
indent-width = 4

# Assume Python 3.8
target-version = "py38"

[lint]
# Enable Pyflakes (`F`), style handled by formatting, ruff includes black
select = ["E4", "E7", "E9", "F"]
ignore = []

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
1 change: 0 additions & 1 deletion src/test/generate-matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Generate a build matrix for use with github workflows
#

from copy import deepcopy
import json
import os
import re
Expand Down
2 changes: 0 additions & 2 deletions t/python/t10001-resourcegraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

from fluxion.resourcegraph.V1 import (
FluxionResourceGraphV1,
FluxionResourcePoolV1,
FluxionResourceRelationshipV1,
)

RV1 = {
Expand Down
1 change: 0 additions & 1 deletion t/scripts/flux-jsonschemalint.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#

import argparse
import errno
import json
import jsonschema

Expand Down
1 change: 1 addition & 0 deletions t/scripts/run_timeout.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
"""run command with a timeout, timeout as a float is first argument, rest are command"""

import sys
import os
import signal
Expand Down
4 changes: 3 additions & 1 deletion t/scripts/y2j.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/false
# Usage: flux python y2j <in.yaml >out.json

import sys, yaml, json
import sys
import yaml
import json

try:
obj = yaml.safe_load(sys.stdin)
Expand Down

0 comments on commit b579e52

Please sign in to comment.