Skip to content

Commit 8e7f8fc

Browse files
Added pre-commit config file (#1508)
* Added .pre-commit-config.yaml file * Initial pass of pre-commit with its default rules and flake8 * Revert "Initial pass of pre-commit with its default rules and flake8" This reverts commit 86d39e9. * Made pre-commit only act on code files * Added sql to the pre-commit file pattern * Initial pass of pre-commit
1 parent c5353d8 commit 8e7f8fc

File tree

6 files changed

+48
-12
lines changed

6 files changed

+48
-12
lines changed

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,10 @@ pygeoapi/db.sqlite3
120120
# Backup files
121121
*~
122122

123-
# Pre-commit hooks config file
124-
.pre-commit-config.yaml
125-
126123
# Pycharm project files
127124
.idea
128125

129126
# ES data folder
130127
.pygeoapi/docker/examples/elastic/ES/data
131128
.pygeoapi/docker/examples/mvt-elastic/ES/data
132-
.pygeoapi/docker/examples/mvt-tippecanoe/ES/data
129+
.pygeoapi/docker/examples/mvt-tippecanoe/ES/data

.pre-commit-config.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
4+
files: '\.(py|sh|sql)$'
5+
6+
repos:
7+
8+
- repo: https://github.com/pre-commit/pre-commit-hooks
9+
rev: v3.2.0
10+
hooks:
11+
- id: trailing-whitespace
12+
- id: end-of-file-fixer
13+
- id: check-yaml
14+
- id: check-added-large-files
15+
16+
- repo: https://github.com/pycqa/flake8
17+
rev: 7.0.0
18+
hooks:
19+
- id: flake8

docs/source/development.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,22 @@ Set the variable for the Spatialite library under OSX:
106106
107107
108108
.. _`GitHub Actions setup`: https://github.com/geopython/pygeoapi/blob/master/.github/workflows/main.yml
109+
110+
111+
Using pre-commit
112+
----------------
113+
114+
You may optionally use `pre-commit`_ in order to check for linting and other static issues
115+
before committing changes. Pygeoapi's repo includes a ``.pre-commit.yml``
116+
file, check the pre-commit docs on how to set it up - in a nutshell:
117+
118+
- pre-commit is mentioned in pygeoapi's ``requirements-dev.txt`` file, so it will be included
119+
when you pip install those
120+
- run ``pre-commit install`` once in order to install its git commit hooks.
121+
- optionally, run ``pre-commit run --all-files``, which will run all pre-commit hooks for all files in the repo.
122+
This also prepares the pre-commit environment.
123+
- from now on, whenever you do a ``git commit``, the pre-commit hooks will run and the commit
124+
will only be done if all checks pass
125+
126+
127+
.. _pre-commit:

requirements-dev.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@ wheel
2525
pyOpenSSL
2626
ndg-httpsclient
2727
pyasn1
28+
29+
pre-commit

tests/data/hotosm_bdi_waterways.sql

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,42 +42,42 @@ COMMENT ON SCHEMA topology IS 'PostGIS Topology schema';
4242

4343

4444
--
45-
-- Name: hstore; Type: EXTENSION; Schema: -; Owner:
45+
-- Name: hstore; Type: EXTENSION; Schema: -; Owner:
4646
--
4747

4848
CREATE EXTENSION IF NOT EXISTS hstore WITH SCHEMA public;
4949

5050

5151
--
52-
-- Name: EXTENSION hstore; Type: COMMENT; Schema: -; Owner:
52+
-- Name: EXTENSION hstore; Type: COMMENT; Schema: -; Owner:
5353
--
5454

5555
COMMENT ON EXTENSION hstore IS 'data type for storing sets of (key, value) pairs';
5656

5757

5858
--
59-
-- Name: postgis; Type: EXTENSION; Schema: -; Owner:
59+
-- Name: postgis; Type: EXTENSION; Schema: -; Owner:
6060
--
6161

6262
CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA public;
6363

6464

6565
--
66-
-- Name: EXTENSION postgis; Type: COMMENT; Schema: -; Owner:
66+
-- Name: EXTENSION postgis; Type: COMMENT; Schema: -; Owner:
6767
--
6868

6969
COMMENT ON EXTENSION postgis IS 'PostGIS geometry, geography, and raster spatial types and functions';
7070

7171

7272
--
73-
-- Name: postgis_topology; Type: EXTENSION; Schema: -; Owner:
73+
-- Name: postgis_topology; Type: EXTENSION; Schema: -; Owner:
7474
--
7575

7676
CREATE EXTENSION IF NOT EXISTS postgis_topology WITH SCHEMA topology;
7777

7878

7979
--
80-
-- Name: EXTENSION postgis_topology; Type: COMMENT; Schema: -; Owner:
80+
-- Name: EXTENSION postgis_topology; Type: COMMENT; Schema: -; Owner:
8181
--
8282

8383
COMMENT ON EXTENSION postgis_topology IS 'PostGIS topology spatial types and functions';
@@ -15030,4 +15030,3 @@ REFRESH MATERIALIZED VIEW osm.hotosm_bdi_drains;
1503015030
--
1503115031
-- PostgreSQL database dump complete
1503215032
--
15033-

tests/data/oracle/init-db/01-create-user.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ CONNECT sys/oracle@XEPDB1 AS SYSDBA;
22

33
CREATE USER geo_test IDENTIFIED BY geo_test QUOTA UNLIMITED ON USERS;
44

5-
GRANT CONNECT, RESOURCE, DBA TO geo_test;
5+
GRANT CONNECT, RESOURCE, DBA TO geo_test;

0 commit comments

Comments
 (0)