Skip to content

Commit 4a4668e

Browse files
authored
Replace black, flake8 and isort for Ruff (#572)
Remove unused packages in `requirements-style.txt`, `environment.yml` and add Ruff to them. Update the `Makefile` targets. Remove `.flake8`. Add Ruff configuration to `pyproject.toml`. Apply fixes to comply with Ruff rules. Replace `l` and `m` loop vars for `i` and `j` in forward modelling nested for loops. Minor fixes to a few error messages. Revert "Ignore RST299 warning in tesseroid example (#571)" (commit 5471998). Remove mutable class attributes in equivalent sources: remove mutable class attributes for dispatching the predict and jacobian kernels depending on the choice for parallelization; obtain the desired kernel as needed in the `predict` and `jacobian` methods instead.
1 parent bbfa8f7 commit 4a4668e

File tree

79 files changed

+1465
-1329
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+1465
-1329
lines changed

.flake8

Lines changed: 0 additions & 46 deletions
This file was deleted.

MANIFEST.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ prune paper
77
prune tutorials
88
exclude .*.yml
99
exclude .*rc
10-
exclude .flake8
1110
exclude license_notice.py
1211
exclude Makefile
1312
exclude .gitignore

Makefile

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ help:
1313
@echo ""
1414
@echo " install install in editable mode"
1515
@echo " test run the test suite (including doctests) and report coverage"
16-
@echo " format run isort and black to automatically format the code"
17-
@echo " check run code style and quality checks (black, isort and flake8)"
16+
@echo " format run ruff to automatically format the code"
17+
@echo " check run code style and quality checks (ruff and burocrata)"
1818
@echo " build build source and wheel distributions"
1919
@echo " clean clean up build and generated files"
2020
@echo ""
2121

22-
.PHONY: build, install, test, test_coverage, test_numba, format, check, black, black-check, isort, isort-check, license, license-check, flake8, clean
22+
.PHONY: build, install, test, test_coverage, test_numba, format, check, check-format, check-style, check-actions, clean
2323

2424
build:
2525
python -m build .
@@ -43,19 +43,18 @@ test_numba:
4343
rm -rvf $(TESTDIR)
4444

4545
format:
46-
isort $(STYLE_CHECK_FILES)
47-
black $(STYLE_CHECK_FILES)
46+
ruff check --select I --fix $(STYLE_CHECK_FILES) # fix isort errors
47+
ruff format $(STYLE_CHECK_FILES)
4848
burocrata --extension=py $(STYLE_CHECK_FILES)
4949

50-
check: check-format check-style
50+
check: check-format check-style check-actions
5151

5252
check-format:
53-
isort --check $(STYLE_CHECK_FILES)
54-
black --check $(STYLE_CHECK_FILES)
55-
burocrata --check --extension=py $(STYLE_CHECK_FILES)
53+
ruff format --check $(STYLE_CHECK_STYLE)
54+
burocrata --check --extension=py $(STYLE_CHECK_STYLE)
5655

5756
check-style:
58-
flake8 $(STYLE_CHECK_FILES)
57+
ruff check $(STYLE_CHECK_FILES)
5958

6059
check-actions:
6160
zizmor $(GITHUB_ACTIONS)

doc/gallery_src/equivalent_sources/block_averaged_sources.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
shift beneath the median location obtained during the block-averaging process).
4040
The depth of the sources can be set through the ``depth`` parameter.
4141
"""
42+
4243
import ensaio
4344
import pandas as pd
4445
import pygmt

doc/gallery_src/equivalent_sources/cartesian.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
least-squares fitting process. The main disadvantage is the increased
3030
computational load (both in terms of time and memory).
3131
"""
32+
3233
import ensaio
3334
import pandas as pd
3435
import pygmt

doc/gallery_src/equivalent_sources/gradient_boosted.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
to use them on a small example.
2929
3030
"""
31+
3132
import boule as bl
3233
import ensaio
3334
import pandas as pd

doc/gallery_src/equivalent_sources/spherical.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
equivalent sources (:class:`harmonica.EquivalentSources`) while taking into
1919
account the curvature of the Earth.
2020
"""
21+
2122
import boule as bl
2223
import ensaio
2324
import numpy as np

doc/gallery_src/forward/point_gravity.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
grid given in Cartesian coordinates using the
1919
:func:`harmonica.point_gravity` function.
2020
"""
21+
2122
import pygmt
2223
import verde as vd
2324

doc/gallery_src/forward/prism_layer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
be used together with the :func:`harmonica.prism_gravity` to compute the
2222
gravitational effect of the layer.
2323
"""
24+
2425
import numpy as np
2526
import pygmt
2627
import verde as vd

doc/gallery_src/forward/prisms_topo_gravity.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
compute the gravity effect of the model on a regular grid of observation
1919
points.
2020
"""
21+
2122
import ensaio
2223
import pygmt
2324
import pyproj

0 commit comments

Comments
 (0)