Skip to content

Commit

Permalink
Added ruff checker
Browse files Browse the repository at this point in the history
Signed-off-by: Andreas Maier <[email protected]>
  • Loading branch information
andy-maier committed Sep 29, 2024
1 parent 51a1e2a commit beed68b
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ jobs:
RUN_TYPE: ${{ steps.set-run-type.outputs.result }}
run: |
make check
- name: Run ruff
env:
PACKAGE_LEVEL: ${{ matrix.package_level }}
RUN_TYPE: ${{ steps.set-run-type.outputs.result }}
run: |
make ruff
- name: Run pylint
env:
PACKAGE_LEVEL: ${{ matrix.package_level }}
Expand Down
27 changes: 27 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Ruff configuration file

# Exclude a variety of commonly ignored directories.
exclude = [
"build",
"dist",
]

# Keep in sync with flake8
line-length = 80

indent-width = 4

# Assume a particular minimum Python version
target-version = "py38"

[lint]

# Keep in sync with flake8
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]+?))$"
17 changes: 16 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,14 @@ safety_develop_policy_file := .safety-policy-develop.yml
# Flake8 config file
flake8_rc_file := .flake8

# Ruff config file
ruff_rc_file := .ruff.toml

# PyLint config file
pylint_rc_file := .pylintrc

# Packages whose dependencies are checked using pip-missing-reqs
check_reqs_packages := pip_check_reqs pipdeptree build pytest coverage coveralls flake8 pylint safety twine towncrier
check_reqs_packages := pip_check_reqs pipdeptree build pytest coverage coveralls flake8 ruff pylint safety twine towncrier

ifdef TESTCASES
pytest_opts := $(TESTOPTS) -k $(TESTCASES)
Expand All @@ -208,6 +211,7 @@ help:
@echo ' develop - Prepare the development environment by installing prerequisites'
@echo " check_reqs - Perform missing dependency checks"
@echo ' check - Run Flake8 on sources'
@echo " ruff - Run ruff on sources (an alternate lint tool)"
@echo ' pylint - Run PyLint on sources'
@echo " safety - Run Safety tool"
@echo ' test - Run tests (and test coverage)'
Expand Down Expand Up @@ -243,6 +247,10 @@ install: $(done_dir)/install_$(pymn)_$(PACKAGE_LEVEL).done
check: $(done_dir)/flake8_$(pymn)_$(PACKAGE_LEVEL).done
@echo '$@ done.'

.PHONY: ruff
ruff: $(done_dir)/ruff_$(pymn)_$(PACKAGE_LEVEL).done
@echo '$@ done.'

.PHONY: pylint
pylint: $(done_dir)/pylint_$(pymn)_$(PACKAGE_LEVEL).done
@echo '$@ done.'
Expand Down Expand Up @@ -379,6 +387,13 @@ $(done_dir)/flake8_$(pymn)_$(PACKAGE_LEVEL).done: $(done_dir)/develop_$(pymn)_$(
flake8 $(check_py_files)
echo "done" >$@

$(done_dir)/ruff_$(pymn)_$(PACKAGE_LEVEL).done: $(done_dir)/develop_$(pymn)_$(PACKAGE_LEVEL).done $(ruff_rc_file) $(check_py_files)
@echo "Makefile: Performing ruff checks with PACKAGE_LEVEL=$(PACKAGE_LEVEL)"
-$(call RM_FUNC,$@)
ruff check --unsafe-fixes --config $(ruff_rc_file) $(check_py_files)
echo "done" >$@
@echo "Makefile: Done performing ruff checks"

$(done_dir)/safety_develop_$(pymn)_$(PACKAGE_LEVEL).done: $(done_dir)/develop_$(pymn)_$(PACKAGE_LEVEL).done Makefile $(safety_develop_policy_file) minimum-constraints-develop.txt
@echo "Makefile: Running Safety for development packages (and tolerate safety issues when RUN_TYPE is normal or scheduled)"
-$(call RM_FUNC,$@)
Expand Down
2 changes: 2 additions & 0 deletions changes/58.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Added support for running the 'ruff' checker via "make ruff" and added that
to the test workflow.
3 changes: 3 additions & 0 deletions minimum-constraints-develop.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ pycodestyle==2.11.0
pyflakes==3.1.0
entrypoints==0.3.0

# Ruff checker (no imports, invoked via ruff script):
ruff==0.3.5

# Change log
towncrier==22.8.0
incremental==22.10.0
Expand Down
3 changes: 3 additions & 0 deletions requirements-develop.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ pycodestyle>=2.11.0
pyflakes>=3.1.0
entrypoints>=0.3.0

# Ruff checker (no imports, invoked via ruff script):
ruff>=0.3.5

# Change log
towncrier>=22.8.0

Expand Down

0 comments on commit beed68b

Please sign in to comment.