Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ruff and remove everything it replaces #68

Merged
merged 4 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -29,19 +29,13 @@ dependencies:
- pandas
# Developer tools
- assertpy
- autopep8
- black
- build
elevans marked this conversation as resolved.
Show resolved Hide resolved
- 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"]
Loading