diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a7c3422c..924b789a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,7 +36,7 @@ jobs: - uses: actions/setup-java@v3 with: - java-version: '8' + java-version: '11' distribution: 'zulu' cache: 'maven' @@ -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 diff --git a/Makefile b/Makefile index a2eaae67..5827c144 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,9 @@ check: lint: check bin/lint.sh +fmt: check + bin/fmt.sh + test: check bin/test.sh diff --git a/bin/fmt.sh b/bin/fmt.sh new file mode 100755 index 00000000..cd04d02e --- /dev/null +++ b/bin/fmt.sh @@ -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 diff --git a/bin/lint.sh b/bin/lint.sh index 3d90d260..8ad9456a 100755 --- a/bin/lint.sh +++ b/bin/lint.sh @@ -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 diff --git a/dev-environment.yml b/dev-environment.yml index 67379769..38729e64 100644 --- a/dev-environment.yml +++ b/dev-environment.yml @@ -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 . diff --git a/pyproject.toml b/pyproject.toml index 56679eb4..5c0c3eb2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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] @@ -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"]