Skip to content

Commit f263b13

Browse files
weiji14seisman
andauthored
Replace flake8 with flakeheaven (#1847)
* Replace flake8 with flakeheaven * Install flakeheaven from conda-forge instead of pypi * Invalidate flakeheaven cache * Ignore pycodestyle and pyflakes errors in flakeheaven plugins section * Pin minimum flakeheaven version to 3.0.0 * Enforce pycodestyle E266 Too many leading '#' for block comment * Ignore pyflakes F401 'Module imported but unused' for __init__.py only Co-Authored-By: Dongdong Tian <[email protected]>
1 parent 35c2158 commit f263b13

File tree

8 files changed

+24
-17
lines changed

8 files changed

+24
-17
lines changed

.github/workflows/format-command.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
# Install formatting tools
2929
- name: Install formatting tools
3030
run: |
31-
pip install black blackdoc docformatter flake8 isort
31+
pip install black blackdoc docformatter flakeheaven isort
3232
sudo apt-get install dos2unix
3333
3434
# Run "make format" and commit the change to the PR branch

.github/workflows/style_checks.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ jobs:
2626

2727
- name: Install packages
2828
run: |
29-
pip install black blackdoc docformatter flake8 pylint isort
29+
pip install black blackdoc docformatter flakeheaven pylint isort
3030
sudo apt-get install dos2unix
3131
32-
- name: Formatting check (black, blackdoc, docformatter, flake8 and isort)
32+
- name: Formatting check (black, blackdoc, docformatter, flakeheaven and isort)
3333
run: make check
3434

3535
- name: Linting (pylint)

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ BLACK_FILES=$(PROJECT) setup.py doc/conf.py examples
88
BLACKDOC_OPTIONS=--line-length 79
99
DOCFORMATTER_FILES=$(PROJECT) setup.py doc/conf.py examples
1010
DOCFORMATTER_OPTIONS=--recursive --pre-summary-newline --make-summary-multi-line --wrap-summaries 79 --wrap-descriptions 79
11-
FLAKE8_FILES=$(PROJECT) setup.py doc/conf.py examples
11+
FLAKEHEAVEN_FILES=$(PROJECT) setup.py doc/conf.py examples
1212
LINT_FILES=$(PROJECT) setup.py doc/conf.py
1313

1414
help:
@@ -19,7 +19,7 @@ help:
1919
@echo " test run the test suite (including some doctests) and report coverage"
2020
@echo " fulltest run the test suite (including all doctests) and report coverage"
2121
@echo " format run black, blackdoc, docformatter and isort to automatically format the code"
22-
@echo " check run code style and quality checks (black, blackdoc, docformatter, flake8 and isort)"
22+
@echo " check run code style and quality checks (black, blackdoc, docformatter, flakeheaven and isort)"
2323
@echo " lint run pylint for a deeper (and slower) quality check"
2424
@echo " clean clean up build and generated files"
2525
@echo " distclean clean up build and generated files, including project metadata files"
@@ -64,7 +64,7 @@ check:
6464
docformatter --check $(DOCFORMATTER_OPTIONS) $(DOCFORMATTER_FILES)
6565
black --check $(BLACK_FILES)
6666
blackdoc --check $(BLACKDOC_OPTIONS) $(BLACK_FILES)
67-
flake8 $(FLAKE8_FILES)
67+
FLAKEHEAVEN_CACHE_TIMEOUT=0 flakeheaven lint $(FLAKEHEAVEN_FILES)
6868

6969
lint:
7070
pylint $(LINT_FILES)

doc/contributing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,14 +499,14 @@ words bridged only by consonants, such as `distcalc`, and `crossprofile`. This
499499
convention is not applied by the code checking tools, but the PyGMT maintainers
500500
will comment on any pull requests as needed.
501501

502-
We also use [flake8](http://flake8.pycqa.org/en/latest/) and
502+
We also use [flakeheaven](https://flakeheaven.readthedocs.io) and
503503
[pylint](https://pylint.pycqa.org/) to check the quality of the code and quickly catch
504504
common errors.
505505
The [`Makefile`](https://github.com/GenericMappingTools/pygmt/blob/main/Makefile)
506506
contains rules for running both checks:
507507

508508
```bash
509-
make check # Runs black, blackdoc, docformatter, flake8 and isort (in check mode)
509+
make check # Runs black, blackdoc, docformatter, flakeheaven and isort (in check mode)
510510
make lint # Runs pylint, which is a bit slower
511511
```
512512

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ dependencies:
2323
- black
2424
- blackdoc
2525
- docformatter
26-
- flake8
26+
- flakeheaven>=3
2727
- isort>=5
2828
- pylint
2929
# Dev dependencies (unit testing)

examples/gallery/embellishments/colorbar.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
fig = pygmt.Figure()
2727
fig.basemap(region=[0, 3, 6, 9], projection="x3c", frame=["af", "WSne+tColorbars"])
2828

29-
## Create a colorbar designed for seismic tomography - roma
29+
# Create a colorbar designed for seismic tomography - roma
3030
# Colorbar is placed at bottom center (BC) by default if no position is given
3131
fig.colorbar(cmap="roma", frame=["x+lVelocity", "y+lm/s"])
3232

33-
## Create a colorbar showing the scientific rainbow - batlow
33+
# Create a colorbar showing the scientific rainbow - batlow
3434
fig.colorbar(
3535
cmap="batlow",
3636
# Colorbar positioned at map coordinates (g) longitude/latitude 0.3/8.7,
@@ -41,7 +41,7 @@
4141
scale=100,
4242
)
4343

44-
## Create a colorbar suitable for surface topography - oleron
44+
# Create a colorbar suitable for surface topography - oleron
4545
fig.colorbar(
4646
cmap="oleron",
4747
# Colorbar position justified outside map frame (J) at Middle Right (MR),

pyproject.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ fallback_version = "999.999.999+unknown"
99
[tool.coverage.run]
1010
omit = ["*/tests/*", "*pygmt/__init__.py"]
1111

12+
[tool.flakeheaven]
13+
max_line_length = 88
14+
max_doc_length = 79
15+
show_source = true
16+
17+
[tool.flakeheaven.plugins]
18+
pycodestyle = ["+*", "-E501", "-W503"]
19+
pyflakes = ["+*"]
20+
21+
[tool.flakeheaven.exceptions."**/__init__.py"]
22+
pyflakes = ["-F401"]
23+
1224
[tool.pytest.ini_options]
1325
minversion = "6.0"
1426
addopts = "--verbose --durations=0 --durations-min=0.2 --doctest-modules --mpl --mpl-results-path=results"

setup.cfg

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

0 commit comments

Comments
 (0)