From 5662f94ac19d3427403e8e1505cca7df1b328ce9 Mon Sep 17 00:00:00 2001 From: jschneidereit Date: Wed, 24 Jul 2024 21:06:48 -0700 Subject: [PATCH 1/4] add ruff and remove everything it replaces --- Makefile | 3 +++ bin/fmt.sh | 11 +++++++++++ bin/lint.sh | 8 ++------ dev-environment.yml | 8 +------- pyproject.toml | 28 ++++++++++++---------------- 5 files changed, 29 insertions(+), 29 deletions(-) create mode 100755 bin/fmt.sh 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 03444184..0f58783b 100644 --- a/dev-environment.yml +++ b/dev-environment.yml @@ -29,19 +29,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] - -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"] From 8e2eea4f68e6c7e88b9ad8288eadae7966bcdca8 Mon Sep 17 00:00:00 2001 From: jschneidereit Date: Thu, 25 Jul 2024 12:20:51 -0700 Subject: [PATCH 2/4] replace various clean code tools with ruff --- .github/workflows/build.yml | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a7c3422c..daeadfeb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 From 45cb7525eb7387a5347df2308b7c5297747d53f0 Mon Sep 17 00:00:00 2001 From: Edward Evans Date: Fri, 23 Aug 2024 11:16:15 -0500 Subject: [PATCH 3/4] Bump openjdk version to 11 This commit resolves an unusual bug where pytest fails to collect the results of the jep test, resulting in failing CI jobs. I was able to reproduce this locally, sometimes, with openjdk=8. There must be a race condition involved with the bug as it doesn't always fail. The crash is a seg fault. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index daeadfeb..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' From 2dcf3dbbd06f900cbe25b09e87d640356809fe1d Mon Sep 17 00:00:00 2001 From: Edward Evans Date: Fri, 23 Aug 2024 13:17:12 -0500 Subject: [PATCH 4/4] Move build dependency to pip section Because we are no longer using the anaconda default channel we need to obtain build from pypi. --- dev-environment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-environment.yml b/dev-environment.yml index 0f58783b..6d79470a 100644 --- a/dev-environment.yml +++ b/dev-environment.yml @@ -29,7 +29,6 @@ dependencies: - pandas # Developer tools - assertpy - - build - pytest - pytest-cov - ruff @@ -38,4 +37,5 @@ dependencies: - pip - pip: - git+https://github.com/ninia/jep.git@cfca63f8b3398daa6d2685428660dc4b2bfab67d + - build - -e .