diff --git a/.gitignore b/.gitignore index 29c4aff..b205af7 100644 --- a/.gitignore +++ b/.gitignore @@ -120,13 +120,10 @@ pygeoapi/db.sqlite3 # Backup files *~ -# Pre-commit hooks config file -.pre-commit-config.yaml - # Pycharm project files .idea # ES data folder .pygeoapi/docker/examples/elastic/ES/data .pygeoapi/docker/examples/mvt-elastic/ES/data -.pygeoapi/docker/examples/mvt-tippecanoe/ES/data \ No newline at end of file +.pygeoapi/docker/examples/mvt-tippecanoe/ES/data diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..a1ba6a7 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,19 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks + +files: '\.(py|sh|sql)$' + +repos: + +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + +- repo: https://github.com/pycqa/flake8 + rev: 7.0.0 + hooks: + - id: flake8 diff --git a/docs/source/development.rst b/docs/source/development.rst index bf8e4d0..106db84 100644 --- a/docs/source/development.rst +++ b/docs/source/development.rst @@ -106,3 +106,22 @@ Set the variable for the Spatialite library under OSX: .. _`GitHub Actions setup`: https://github.com/geopython/pygeoapi/blob/master/.github/workflows/main.yml + + +Using pre-commit +---------------- + +You may optionally use `pre-commit`_ in order to check for linting and other static issues +before committing changes. Pygeoapi's repo includes a ``.pre-commit.yml`` +file, check the pre-commit docs on how to set it up - in a nutshell: + +- pre-commit is mentioned in pygeoapi's ``requirements-dev.txt`` file, so it will be included + when you pip install those +- run ``pre-commit install`` once in order to install its git commit hooks. +- optionally, run ``pre-commit run --all-files``, which will run all pre-commit hooks for all files in the repo. + This also prepares the pre-commit environment. +- from now on, whenever you do a ``git commit``, the pre-commit hooks will run and the commit + will only be done if all checks pass + + +.. _pre-commit: diff --git a/requirements-dev.txt b/requirements-dev.txt index c64b4a0..00c76c7 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -25,3 +25,5 @@ wheel pyOpenSSL ndg-httpsclient pyasn1 + +pre-commit diff --git a/tests/data/hotosm_bdi_waterways.sql b/tests/data/hotosm_bdi_waterways.sql index b79092f..a9fcc13 100644 --- a/tests/data/hotosm_bdi_waterways.sql +++ b/tests/data/hotosm_bdi_waterways.sql @@ -42,42 +42,42 @@ COMMENT ON SCHEMA topology IS 'PostGIS Topology schema'; -- --- Name: hstore; Type: EXTENSION; Schema: -; Owner: +-- Name: hstore; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS hstore WITH SCHEMA public; -- --- Name: EXTENSION hstore; Type: COMMENT; Schema: -; Owner: +-- Name: EXTENSION hstore; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION hstore IS 'data type for storing sets of (key, value) pairs'; -- --- Name: postgis; Type: EXTENSION; Schema: -; Owner: +-- Name: postgis; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA public; -- --- Name: EXTENSION postgis; Type: COMMENT; Schema: -; Owner: +-- Name: EXTENSION postgis; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION postgis IS 'PostGIS geometry, geography, and raster spatial types and functions'; -- --- Name: postgis_topology; Type: EXTENSION; Schema: -; Owner: +-- Name: postgis_topology; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS postgis_topology WITH SCHEMA topology; -- --- Name: EXTENSION postgis_topology; Type: COMMENT; Schema: -; Owner: +-- Name: EXTENSION postgis_topology; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION postgis_topology IS 'PostGIS topology spatial types and functions'; @@ -15030,4 +15030,3 @@ REFRESH MATERIALIZED VIEW osm.hotosm_bdi_drains; -- -- PostgreSQL database dump complete -- - diff --git a/tests/data/oracle/init-db/01-create-user.sql b/tests/data/oracle/init-db/01-create-user.sql index 3f3d7a8..02d5894 100755 --- a/tests/data/oracle/init-db/01-create-user.sql +++ b/tests/data/oracle/init-db/01-create-user.sql @@ -2,4 +2,4 @@ CONNECT sys/oracle@XEPDB1 AS SYSDBA; CREATE USER geo_test IDENTIFIED BY geo_test QUOTA UNLIMITED ON USERS; -GRANT CONNECT, RESOURCE, DBA TO geo_test; \ No newline at end of file +GRANT CONNECT, RESOURCE, DBA TO geo_test;