Skip to content

Commit

Permalink
Use ruff to format codes so remove black (#2819)
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman authored Nov 20, 2023
1 parent bfb00fb commit 519fd03
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/format-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
# Install formatting tools
- name: Install formatting tools
run: |
python -m pip install black blackdoc docformatter ruff
python -m pip install blackdoc docformatter ruff
python -m pip list
sudo apt-get install dos2unix
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/style_checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ jobs:

- name: Install packages
run: |
python -m pip install black blackdoc docformatter pylint ruff
python -m pip install blackdoc docformatter pylint ruff
python -m pip list
sudo apt-get install dos2unix
- name: Formatting check (black, blackdoc, docformatter, ruff)
- name: Formatting check (blackdoc, docformatter, ruff)
run: make check

- name: Linting (pylint)
Expand Down
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ help:
@echo " fulltest run the test suite (including all doctests)"
@echo " doctest run the doctests only"
@echo " test_no_images run the test suite (including all doctests) but skip image comparisons"
@echo " format run black, blackdoc, docformatter and ruff to automatically format the code"
@echo " check run code style and quality checks (black, blackdoc, docformatter, ruff)"
@echo " format run blackdoc, docformatter and ruff to automatically format the code"
@echo " check run code style and quality checks (blackdoc, docformatter, ruff)"
@echo " codespell run codespell to check common misspellings"
@echo " lint run pylint for a deeper (and slower) quality check"
@echo " clean clean up build and generated files"
Expand Down Expand Up @@ -61,14 +61,12 @@ test_no_images: _runtest

format:
docformatter --in-place $(FORMAT_FILES)
black $(FORMAT_FILES)
blackdoc $(FORMAT_FILES)
ruff check --fix $(FORMAT_FILES)
ruff format $(FORMAT_FILES)

check:
docformatter --check $(FORMAT_FILES)
black --check $(FORMAT_FILES)
blackdoc --check $(FORMAT_FILES)
ruff check $(FORMAT_FILES)
ruff format --check $(FORMAT_FILES)
Expand Down
7 changes: 3 additions & 4 deletions doc/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ the `pygmt/src/` and `pygmt/datasets/` folders. **All docstrings** should follow
All functions/classes/methods should have docstrings with a full description of all
arguments and return values.

While the maximum line length for code is automatically set by Black, docstrings
While the maximum line length for code is automatically set by ruff, docstrings
must be formatted manually. To play nicely with Jupyter and IPython, **keep docstrings
limited to 79 characters** per line.

Expand Down Expand Up @@ -473,12 +473,11 @@ code, be sure to follow the general guidelines in the

We use some tools to format the code so we don't have to think about it:

- [Black](https://github.com/psf/black)
- [blackdoc](https://github.com/keewis/blackdoc)
- [docformatter](https://github.com/myint/docformatter)
- [ruff](https://docs.astral.sh/ruff)

Black and blackdoc loosely follows the [PEP8](http://pep8.org) guide but with a few
These tools loosely follow the [PEP8](http://pep8.org) guide but with a few
differences. Regardless, you won't have to worry about formatting the code yourself.
Before committing, run it to automatically format your code:

Expand Down Expand Up @@ -513,7 +512,7 @@ The [`Makefile`](https://github.com/GenericMappingTools/pygmt/blob/main/Makefile
contains rules for running both checks:

```bash
make check # Runs black, blackdoc, docformatter, ruff (in check mode)
make check # Runs blackdoc, docformatter, ruff (in check mode)
make lint # Runs pylint, which is a bit slower
```

Expand Down
1 change: 0 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ dependencies:
- make
- pip
# Dev dependencies (style checks)
- black
- blackdoc
- codespell
- docformatter>=1.7.2
Expand Down

0 comments on commit 519fd03

Please sign in to comment.