Skip to content

Commit

Permalink
Merge pull request #68 from jschneidereit/jschneidereit/64-add-ruff
Browse files Browse the repository at this point in the history
Add ruff and remove everything it replaces
  • Loading branch information
elevans authored Aug 23, 2024
2 parents 8eadd12 + 2dcf3db commit d12410b
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 46 deletions.
20 changes: 4 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:

- uses: actions/setup-java@v3
with:
java-version: '8'
java-version: '11'
distribution: 'zulu'
cache: 'maven'

Expand All @@ -56,22 +56,10 @@ jobs:
- uses: actions/setup-python@v3

- name: Lint code
uses: psf/black@stable

- name: Flake code
run: |
python -m pip install flake8 Flake8-pyproject flake8-typing-imports
python -m flake8 src tests
- name: Check import ordering
uses: isort/isort-action@master
with:
configuration: --check-only

- name: Validate pyproject.toml
run: |
python -m pip install validate-pyproject[all]
python -m validate_pyproject pyproject.toml
python -m pip install ruff
ruff check
ruff format --check
conda-dev-test:
name: Conda Setup & Code Coverage
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ check:
lint: check
bin/lint.sh

fmt: check
bin/fmt.sh

test: check
bin/test.sh

Expand Down
11 changes: 11 additions & 0 deletions bin/fmt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

dir=$(dirname "$0")
cd "$dir/.."

exitCode=0
ruff check --fix
code=$?; test $code -eq 0 || exitCode=$code
ruff format
code=$?; test $code -eq 0 || exitCode=$code
exit $exitCode
8 changes: 2 additions & 6 deletions bin/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@ dir=$(dirname "$0")
cd "$dir/.."

exitCode=0
black src tests
ruff check
code=$?; test $code -eq 0 || exitCode=$code
isort src tests
code=$?; test $code -eq 0 || exitCode=$code
python -m flake8 src tests
code=$?; test $code -eq 0 || exitCode=$code
validate-pyproject pyproject.toml
ruff format --check
code=$?; test $code -eq 0 || exitCode=$code
exit $exitCode
10 changes: 2 additions & 8 deletions dev-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,13 @@ dependencies:
- pandas
# Developer tools
- assertpy
- autopep8
- black
- build
- flake8
- isort
- pytest
- pytest-cov
- ruff
- toml
# Project from source
- pip
- pip:
- git+https://github.com/ninia/jep.git@cfca63f8b3398daa6d2685428660dc4b2bfab67d
- flake8-pyproject
- flake8-typing-imports
- validate-pyproject[all]
- build
- -e .
28 changes: 12 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,14 @@ dependencies = [
# NB: Keep this in sync with dev-environment.yml!
dev = [
"assertpy",
"autopep8",
"black",
"build",
"flake8",
"flake8-pyproject",
"flake8-typing-imports",
"isort",
"jep",
"pytest",
"pytest-cov",
"numpy",
"pandas",
"toml",
"validate-pyproject[all]",
"ruff",
"toml"
]

[project.urls]
Expand All @@ -72,13 +66,15 @@ where = ["src"]
namespaces = false

# Thanks to Flake8-pyproject, we can configure flake8 here!
[tool.flake8]
exclude = ["bin", "build", "dist"]
[tool.ruff]
line-length = 88
src = ["src", "tests"]
include = ["pyproject.toml", "src/**/*.py", "tests/**/*.py"]
extend-exclude = ["bin", "build", "dist"]

[tool.ruff.lint]
extend-ignore = ["E203"]
# See https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#flake8
max-line-length = 88
min_python_version = "3.8"
per-file-ignores = "__init__.py:F401"

[tool.isort]
profile = "black"
[tool.ruff.lint.per-file-ignores]
# Ignore `E402` (import violations) in all `__init__.py` files, and in `path/to/file.py`.
"__init__.py" = ["E402", "F401"]

0 comments on commit d12410b

Please sign in to comment.