Skip to content

Commit 52ee2d3

Browse files
committed
feat: Run flake8 via pre-commit
- Document pre-commit usage and per-user configuration - Correct a missing space in the contributing docs - Replace mention of yapf as formatter with Black - Check two previously not included files
1 parent 6c7f548 commit 52ee2d3

File tree

5 files changed

+16
-23
lines changed

5 files changed

+16
-23
lines changed

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,10 @@ repos:
1010
language: system
1111
stages: [commit]
1212
types: [python]
13+
14+
- id: flake8
15+
name: flake8
16+
entry: flake8
17+
language: system
18+
stages: [commit]
19+
types: [python]

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,19 @@ To run linters, code formatters, and test suites all together, use `test`:
7777

7878
### Code quality checks
7979

80-
PySTAC uses [flake8](http://flake8.pycqa.org/en/latest/) and [yapf](https://github.com/google/yapf) for code formatting and style checks.
81-
82-
To run the flake8 style checks:
80+
PySTAC uses [flake8](http://flake8.pycqa.org/en/latest/) and [Black](https://github.com/psf/black) for code formatting and style checks. To run both:
8381

8482
```
85-
> flake8 pystac tests
83+
> pre-commit run --all-files
8684
```
8785

88-
To format code:
86+
To run these automatically when committing files (runs only on the staged files):
8987

9088
```
91-
> yapf -ipr pystac tests
89+
> pre-commit install --hook-type=pre-commit --overwrite
9290
```
9391

94-
Note that you may have to use `yapf3` explicitly depending on your environment.
92+
To avoid running these checks when committing, use `git commit --no-verify`.
9593

9694
To check for spelling mistakes in modified files:
9795

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
sys.path.insert(0, os.path.abspath("."))
2121
sys.path.insert(0, os.path.abspath("../"))
22-
from pystac.version import __version__, STACVersion
22+
from pystac.version import __version__, STACVersion # noqa:E402
2323

2424
git_branch = (
2525
subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"])

docs/contributing.rst

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,10 @@ More details on using ``unittest`` are `here
4545
Code quality checks
4646
^^^^^^^^^^^^^^^^^^^
4747

48-
PySTAC uses `flake8 <http://flake8.pycqa.org/en/latest/>`_ and`black
48+
PySTAC uses `flake8 <http://flake8.pycqa.org/en/latest/>`_ and `black
4949
<https://github.com/psf/black>`_ for code formatting and style checks.
5050

51-
To run the flake8 style checks:
52-
53-
.. code-block:: bash
54-
55-
> flake8 pystac tests
56-
57-
To format code:
51+
To run both:
5852

5953
.. code-block:: bash
6054

scripts/lint

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,7 @@ echo
99
mypy docs pystac setup.py tests
1010

1111
echo
12-
echo " -- LINTING WITH FLAKE8 --"
13-
echo
14-
15-
flake8 pystac setup.py tests
16-
17-
echo
18-
echo " -- CHECKING FORMAT WITH BLACK --"
12+
echo " -- CHECKING WITH BLACK AND FLAKE8 --"
1913
echo
2014

2115
pre-commit run --all-files

0 commit comments

Comments
 (0)