diff --git a/.github/workflows/format-command.yml b/.github/workflows/format-command.yml index 025b34b676e..941596d5335 100644 --- a/.github/workflows/format-command.yml +++ b/.github/workflows/format-command.yml @@ -28,7 +28,7 @@ jobs: # Install formatting tools - name: Install formatting tools run: | - pip install black blackdoc docformatter flake8 isort + pip install black blackdoc docformatter flakeheaven isort sudo apt-get install dos2unix # Run "make format" and commit the change to the PR branch diff --git a/.github/workflows/style_checks.yaml b/.github/workflows/style_checks.yaml index 6ba4ba24186..a07bf6d77e6 100644 --- a/.github/workflows/style_checks.yaml +++ b/.github/workflows/style_checks.yaml @@ -26,10 +26,10 @@ jobs: - name: Install packages run: | - pip install black blackdoc docformatter flake8 pylint isort + pip install black blackdoc docformatter flakeheaven pylint isort sudo apt-get install dos2unix - - name: Formatting check (black, blackdoc, docformatter, flake8 and isort) + - name: Formatting check (black, blackdoc, docformatter, flakeheaven and isort) run: make check - name: Linting (pylint) diff --git a/Makefile b/Makefile index 30b78c92093..0ce1377ec6b 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ BLACK_FILES=$(PROJECT) setup.py doc/conf.py examples BLACKDOC_OPTIONS=--line-length 79 DOCFORMATTER_FILES=$(PROJECT) setup.py doc/conf.py examples DOCFORMATTER_OPTIONS=--recursive --pre-summary-newline --make-summary-multi-line --wrap-summaries 79 --wrap-descriptions 79 -FLAKE8_FILES=$(PROJECT) setup.py doc/conf.py examples +FLAKEHEAVEN_FILES=$(PROJECT) setup.py doc/conf.py examples LINT_FILES=$(PROJECT) setup.py doc/conf.py help: @@ -19,7 +19,7 @@ help: @echo " test run the test suite (including some doctests) and report coverage" @echo " fulltest run the test suite (including all doctests) and report coverage" @echo " format run black, blackdoc, docformatter and isort to automatically format the code" - @echo " check run code style and quality checks (black, blackdoc, docformatter, flake8 and isort)" + @echo " check run code style and quality checks (black, blackdoc, docformatter, flakeheaven and isort)" @echo " lint run pylint for a deeper (and slower) quality check" @echo " clean clean up build and generated files" @echo " distclean clean up build and generated files, including project metadata files" @@ -64,7 +64,7 @@ check: docformatter --check $(DOCFORMATTER_OPTIONS) $(DOCFORMATTER_FILES) black --check $(BLACK_FILES) blackdoc --check $(BLACKDOC_OPTIONS) $(BLACK_FILES) - flake8 $(FLAKE8_FILES) + FLAKEHEAVEN_CACHE_TIMEOUT=0 flakeheaven lint $(FLAKEHEAVEN_FILES) lint: pylint $(LINT_FILES) diff --git a/doc/contributing.md b/doc/contributing.md index 2a8b5b71815..2e831f00dc4 100644 --- a/doc/contributing.md +++ b/doc/contributing.md @@ -499,14 +499,14 @@ words bridged only by consonants, such as `distcalc`, and `crossprofile`. This convention is not applied by the code checking tools, but the PyGMT maintainers will comment on any pull requests as needed. -We also use [flake8](http://flake8.pycqa.org/en/latest/) and +We also use [flakeheaven](https://flakeheaven.readthedocs.io) and [pylint](https://pylint.pycqa.org/) to check the quality of the code and quickly catch common errors. The [`Makefile`](https://github.com/GenericMappingTools/pygmt/blob/main/Makefile) contains rules for running both checks: ```bash -make check # Runs black, blackdoc, docformatter, flake8 and isort (in check mode) +make check # Runs black, blackdoc, docformatter, flakeheaven and isort (in check mode) make lint # Runs pylint, which is a bit slower ``` diff --git a/environment.yml b/environment.yml index 4ba51be4fce..d3ed43a02b4 100644 --- a/environment.yml +++ b/environment.yml @@ -23,7 +23,7 @@ dependencies: - black - blackdoc - docformatter - - flake8 + - flakeheaven>=3 - isort>=5 - pylint # Dev dependencies (unit testing) diff --git a/examples/gallery/embellishments/colorbar.py b/examples/gallery/embellishments/colorbar.py index b6320261fbc..edfbdd5ecb6 100644 --- a/examples/gallery/embellishments/colorbar.py +++ b/examples/gallery/embellishments/colorbar.py @@ -26,11 +26,11 @@ fig = pygmt.Figure() fig.basemap(region=[0, 3, 6, 9], projection="x3c", frame=["af", "WSne+tColorbars"]) -## Create a colorbar designed for seismic tomography - roma +# Create a colorbar designed for seismic tomography - roma # Colorbar is placed at bottom center (BC) by default if no position is given fig.colorbar(cmap="roma", frame=["x+lVelocity", "y+lm/s"]) -## Create a colorbar showing the scientific rainbow - batlow +# Create a colorbar showing the scientific rainbow - batlow fig.colorbar( cmap="batlow", # Colorbar positioned at map coordinates (g) longitude/latitude 0.3/8.7, @@ -41,7 +41,7 @@ scale=100, ) -## Create a colorbar suitable for surface topography - oleron +# Create a colorbar suitable for surface topography - oleron fig.colorbar( cmap="oleron", # Colorbar position justified outside map frame (J) at Middle Right (MR), diff --git a/pyproject.toml b/pyproject.toml index 401d8cf5b68..a74b65d7345 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,6 +9,18 @@ fallback_version = "999.999.999+unknown" [tool.coverage.run] omit = ["*/tests/*", "*pygmt/__init__.py"] +[tool.flakeheaven] +max_line_length = 88 +max_doc_length = 79 +show_source = true + +[tool.flakeheaven.plugins] +pycodestyle = ["+*", "-E501", "-W503"] +pyflakes = ["+*"] + +[tool.flakeheaven.exceptions."**/__init__.py"] +pyflakes = ["-F401"] + [tool.pytest.ini_options] minversion = "6.0" addopts = "--verbose --durations=0 --durations-min=0.2 --doctest-modules --mpl --mpl-results-path=results" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 2c09e8bed23..00000000000 --- a/setup.cfg +++ /dev/null @@ -1,5 +0,0 @@ -[flake8] -ignore = E203, E266, E501, W503, F401, E741 -max-line-length = 88 -#max-complexity = 10 -max-doc-length = 79