From d39f8890905280df0e40381212b104350b47c044 Mon Sep 17 00:00:00 2001 From: Gagan Deep Date: Mon, 12 Aug 2024 22:08:12 +0530 Subject: [PATCH] [chores] Formatted code, updated CI configuration Use PostgreSQL 15 for testing --- .coveragerc | 3 - .github/dependabot.yml | 6 + .github/workflows/ci.yml | 46 ++-- CHANGES.rst | 211 ++++++++++++------ CONTRIBUTING.rst | 7 +- docker-compose.yml | 4 +- performance_tests.rst | 9 +- pyproject.toml | 22 ++ requirements-test.txt | 3 +- rest_framework_gis/fields.py | 2 +- setup.cfg | 7 - .../migrations/0001_initial.py | 1 - .../migrations/0002_nullable.py | 1 - .../migrations/0004_auto_20240228_2357.py | 1 - tox.ini | 3 +- 15 files changed, 213 insertions(+), 113 deletions(-) delete mode 100644 .coveragerc create mode 100644 pyproject.toml diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 2c81a869..00000000 --- a/.coveragerc +++ /dev/null @@ -1,3 +0,0 @@ -[run] -omit = - /*/__init__.py diff --git a/.github/dependabot.yml b/.github/dependabot.yml index db958279..f91a6bd1 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -11,3 +11,9 @@ updates: interval: "monthly" commit-message: prefix: "[deps] " + - package-ecosystem: "github-actions" # Check for GitHub Actions updates + directory: "/" + schedule: + interval: "monthly" # Check for updates weekly + commit-message: + prefix: "[ci] " diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2725c881..1c9d5627 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: services: postgres: - image: postgis/postgis:10-2.5 + image: postgis/postgis:15-3.4-alpine env: POSTGRES_PASSWORD: postgres POSTGRES_USER: postgres @@ -72,22 +72,22 @@ jobs: - python: 3.9 TOXENV: py39-django40-djangorestframework313 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} - name: Set up Python ${{ matrix.env.python }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.env.python }} + cache: 'pip' + cache-dependency-path: | + **/requirements*.txt - - name: Install system packages - run: | - sudo apt-get update - sudo apt-get install binutils libproj-dev gdal-bin -y - - - name: Install python dependencies + - name: Install Dependencies run: | + sudo apt -qq update + sudo apt -qq -y install binutils libproj-dev gdal-bin pip install -U pip wheel setuptools pip install -U -r requirements-test.txt pip install tox docutils pygments twine @@ -95,31 +95,29 @@ jobs: - name: Tests run: | tox -e ${{ matrix.env.TOXENV }} + coverage combine + coverage xml env: POSTGRES_HOST: localhost - name: Upload Coverage - run: coveralls --service=github - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COVERALLS_FLAG_NAME: | - python-${{ matrix.env.env }} - COVERALLS_PARALLEL: true + uses: coverallsapp/github-action@v2 + with: + parallel: true + format: cobertura + flag-name: python-${{ matrix.env.env }} + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: QA checks run: | - pip install "importlib-metadata<5.0" # remove when flake8 is upgraded ./run-qa-checks coveralls: - name: Finish Coveralls needs: build runs-on: ubuntu-latest - container: python:3-slim steps: - - name: Finished - run: | - pip3 install --upgrade coveralls - coveralls --finish - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Coveralls Finished + uses: coverallsapp/github-action@v2 + with: + parallel-finished: true diff --git a/CHANGES.rst b/CHANGES.rst index 9fda27e6..42b4c597 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -27,158 +27,241 @@ Version 0.18.0 [2022-01-07] Version 0.17.0 [2021-01-25] --------------------------- -- [feature] Added - `OpenAPI Schema Generation `_ - (`#219 `_) - special - thanks to `Dhaval Mehta `_ +- [feature] Added `OpenAPI Schema Generation + `_ + (`#219 + `_) - + special thanks to `Dhaval Mehta `_ Version 0.16.0 [2020-09-07] --------------------------- -- [fix] Added support for representation of empty geometries - (`#168 `_) -- [fix] Don't override the additional arguments passed as ``style`` to ``GeometryField`` -- [feature] Added `DistanceToPointOrderingFilter `_ - (`#210 `_) +- [fix] Added support for representation of empty geometries (`#168 + `_) +- [fix] Don't override the additional arguments passed as ``style`` to + ``GeometryField`` +- [feature] Added `DistanceToPointOrderingFilter + `_ + (`#210 + `_) - [deps] Added support for django 3.1 in the CI build - [deps] Dropped django 1.11 and Python 3.5 from the CI build, - compatibility may still work but it's not guaranteed anymore, please upgrade! -- [qa] Added QA checks to CI build - (`#230 `_) + compatibility may still work but it's not guaranteed anymore, please + upgrade! +- [qa] Added QA checks to CI build (`#230 + `_) Version 0.15.0 [2019-12-09] --------------------------- - Dropped Python 3.4 support -- `#190 `_: +- `#190 + `_: Added django 2.2 on test matrix -- `#199 `_: +- `#199 + `_: Dropped Django 2.0 support -- `#195 `_: +- `#195 + `_: Updated the way that ``to_representation`` removes already processed -- `#197 `_: +- `#197 + `_: Removed six dependency -- `#202 `_: +- `#202 + `_: Updated DRF to 3.10, removed support for previous DRF versions -- `#200 `_: +- `#200 + `_: Added Django 3.0 and Python 3.8 support Version 0.14.0 [2018-12-02] --------------------------- -- `#173 `_: - added support for django 2.1, DRF 3.9 and switched to django-filters >= 2.0 - (**which requires python >= 3.4**) -- `#178 `_: +- `#173 + `_: + added support for django 2.1, DRF 3.9 and switched to django-filters >= + 2.0 (**which requires python >= 3.4**) +- `#178 + `_: simplified ``setup.py`` and tox build Version 0.13.0 [2018-04-27] --------------------------- -- `#161 `_: +- `#161 + `_: added flag to reduce precision of ``GeometryField`` -- `#164 `_: +- `#164 + `_: added compatibility with django-rest-framework 3.8 Version 0.12.0 [2017-11-12] --------------------------- -- `#138 `_: +- `#138 + `_: added support for ``GeometryCollection`` fields -- `#146 `_: +- `#146 + `_: added compatibility with django-rest-framework 3.7 -- `#147 `_: +- `#147 + `_: added support to django 2.0 beta - dropped support for django 1.7, 1.8, 1.9 and 1.10 Version 0.11.2 [2017-05-22] --------------------------- -- `eb54fc0 `_: ``GeometryFilter`` now use ``BaseGeometryWidget`` -- `33a6418 `_: fixed tests for Django 1.11: ``Point`` comparison uses ``srid`` +- `eb54fc0 + `_: + ``GeometryFilter`` now use ``BaseGeometryWidget`` +- `33a6418 + `_: + fixed tests for Django 1.11: ``Point`` comparison uses ``srid`` Version 0.11.1 [2017-05-05] --------------------------- -- `#119 `_: Added support to "__all__" fields in serializer -- `#130 `_: Added compatibility with DRF 3.6 +- `#119 + `_: + Added support to "__all__" fields in serializer +- `#130 + `_: + Added compatibility with DRF 3.6 Version 0.11.0 [2016-11-22] --------------------------- -- `#106 `_: dropped support for django 1.7 -- `#117 `_: added support for django-filter 0.15 -- `6479949 `_: fixed tests for latest DRF 3.5 version -- `35e3b87 `_: added official support to django 1.10 +- `#106 + `_: + dropped support for django 1.7 +- `#117 + `_: + added support for django-filter 0.15 +- `6479949 + `_: + fixed tests for latest DRF 3.5 version +- `35e3b87 + `_: + added official support to django 1.10 Version 0.10.1 [2016-01-06] --------------------------- -- `#93 `_ skipped a few tests if spatialite DB backend is being used -- `#95 `_ fixed misunderstanding regarding 0.9.6 DRF compatibility in README -- `#96 `_ added missing assets in python package source tarball +- `#93 `_ + skipped a few tests if spatialite DB backend is being used +- `#95 `_ + fixed misunderstanding regarding 0.9.6 DRF compatibility in README +- `#96 `_ + added missing assets in python package source tarball Version 0.10.0 [2015-12-07] --------------------------- -- `#87 `_ dropped support for old django versions and python 2.6 +- `#87 `_ + dropped support for old django versions and python 2.6 Version 0.9.6 [2015-11-02] -------------------------- -- `#82 `_: avoid ``KeyError`` id field not in ``fields`` (bug introduced in 0.9.5) -- `fbaf9b1 `_: improved documentation for new default ``id_field`` behaviour -- `#84 `_: switched to ``assertAlmostEqual`` in ``test_post_location_list_EWKT`` to ease testing for debian package -- `#85 `_: fixed serialization of properties holding ``None`` values (bug introduced in 0.9.5) -- `#86 `_: updated advertised compatibility to include **python 3.5** +- `#82 + `_: + avoid ``KeyError`` id field not in ``fields`` (bug introduced in 0.9.5) +- `fbaf9b1 + `_: + improved documentation for new default ``id_field`` behaviour +- `#84 `_: + switched to ``assertAlmostEqual`` in ``test_post_location_list_EWKT`` to + ease testing for debian package +- `#85 `_: + fixed serialization of properties holding ``None`` values (bug + introduced in 0.9.5) +- `#86 `_: + updated advertised compatibility to include **python 3.5** Version 0.9.5 [2015-10-12] -------------------------- -- `#71 `_: added possibility to override GeoJSON properties in ``GeoFeatureModelSerializer`` -- `52e15a5 `_: Added default ``page_size_query_param`` in ``GeoJsonPagination`` +- `#71 `_: + added possibility to override GeoJSON properties in + ``GeoFeatureModelSerializer`` +- `52e15a5 + `_: + Added default ``page_size_query_param`` in ``GeoJsonPagination`` Version 0.9.4 [2015-09-08] -------------------------- -- `#68 `_: ensure not having drf-gis in ``INSTALLED_APPS`` works anyway -- `#76 `_: avoid pickle errors in ``GeoJsonDict`` -- `#75 `_: return ``GEOSGeometry`` instead of geojson property +- `#68 + `_: + ensure not having drf-gis in ``INSTALLED_APPS`` works anyway +- `#76 + `_: + avoid pickle errors in ``GeoJsonDict`` +- `#75 `_: + return ``GEOSGeometry`` instead of geojson property Version 0.9.3 [2015-07-22] -------------------------- -- `04fd1bf `_: Added ``GeoJsonPagination`` -- `fe47d86 `_: Improved ``ValidationError`` message of ``GeometryField`` -- `a3ddd3d `_: **Improved serialization performance between 25% and 29%** -- `fb6ed36 `_: ``GeoModelSerializer`` deprecated because obsolete -- `#66 `_: geometry now allows ``None`` values according to the **GeoJSON spec** -- `#67 `_: discern ``False`` or empty string values from ``None`` in ``GeoFeatureModelSerializer`` +- `04fd1bf + `_: + Added ``GeoJsonPagination`` +- `fe47d86 + `_: + Improved ``ValidationError`` message of ``GeometryField`` +- `a3ddd3d + `_: + **Improved serialization performance between 25% and 29%** +- `fb6ed36 + `_: + ``GeoModelSerializer`` deprecated because obsolete +- `#66 `_: + geometry now allows ``None`` values according to the **GeoJSON spec** +- `#67 `_: + discern ``False`` or empty string values from ``None`` in + ``GeoFeatureModelSerializer`` Version 0.9.2 [2015-07-15] -------------------------- -- `#59 `_: Added GeometrySerializerMethodField -- `3fa2354 `_: removed broken/obsolete/untested code +- `#59 `_: + Added GeometrySerializerMethodField +- `3fa2354 + `_: + removed broken/obsolete/untested code Version 0.9.1 [2015-06-28] -------------------------- -- `#63 `_: added compatibility with python 3.2 and updated compatibility table in README -- `#60 `_: ensure GeoJSON is rendered correctly in browsable API when using python 2 -- `#62 `_: updated django-rest-framework requirement to 3.1.3 +- `#63 + `_: + added compatibility with python 3.2 and updated compatibility table in + README +- `#60 `_: + ensure GeoJSON is rendered correctly in browsable API when using python + 2 +- `#62 + `_: + updated django-rest-framework requirement to 3.1.3 Version 0.9 [2015-05-31] ------------------------ -- `#55 `_: Fixed exception in ``DistanceToPointFilter`` in case of invalid point -- `#58 `_: Fixed handling of ``None`` values in ``GeoFeatureModelSerializer`` to avoid problems with ``FileField`` and ``ImageField`` -- `#57 `_: Added support for GeoJSON Bounding Boxes in ``GeoFeatureModelSerializer`` +- `#55 `_: + Fixed exception in ``DistanceToPointFilter`` in case of invalid point +- `#58 `_: + Fixed handling of ``None`` values in ``GeoFeatureModelSerializer`` to + avoid problems with ``FileField`` and ``ImageField`` +- `#57 `_: + Added support for GeoJSON Bounding Boxes in + ``GeoFeatureModelSerializer`` Version 0.8.2 [2015-04-29] -------------------------- -- `#53 `_: Added support for PATCH requests in ``GeoFeatureModelSerializer`` +- `#53 `_: + Added support for PATCH requests in ``GeoFeatureModelSerializer`` Version 0.8.1 [2015-03-25] -------------------------- diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index c2b5af6c..ff1484b9 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -1,5 +1,8 @@ Contributing ============ -Thanks for your interest! We love contributions, so please feel free to fix bugs, improve things, provide documentation. Just `follow the -guidelines `_ and submit a PR. +Thanks for your interest! We love contributions, so please feel free to +fix bugs, improve things, provide documentation. Just `follow the +guidelines +`_ and +submit a PR. diff --git a/docker-compose.yml b/docker-compose.yml index 98542c31..9248ad4d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,12 +20,12 @@ services: command: sh -c "pip install -e . && python ./tests/manage.py test tests/django_restframework_gis_tests && ./run-qa-checks" postgres: - image: mdillon/postgis:10-alpine + image: postgis/postgis:15-3.4-alpine environment: POSTGRES_PASSWORD: postgres POSTGRES_USER: postgres POSTGRES_DB: django_restframework_gis - ports: + ports: - 5432:5432 volumes: - postgres_data:/var/lib/postgresql/data diff --git a/performance_tests.rst b/performance_tests.rst index c1394b9b..fd542d88 100644 --- a/performance_tests.rst +++ b/performance_tests.rst @@ -1,12 +1,15 @@ Average of 5 measurements for python2 and python3. -Launch the performance test with:: +Launch the performance test with: + +:: cd tests ./manage.py test --keepdb django_restframework_gis_tests.test_performance -For more information regarding how the measurement is performed read the code in -`test_performance.py `__. +For more information regarding how the measurement is performed read the +code in `test_performance.py +`__. 0.9.2 ===== diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..81e80400 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,22 @@ +[tool.coverage.run] +source = ["rest_framework_gis"] +parallel = true +concurrency = ["multiprocessing"] +omit = [ + "rest_framework_gis/__init__.py", + "*/tests/*", + "*/migrations/*", +] + +[tool.docstrfmt] +extend_exclude = ["**/*.py", "README.rst"] + +[tool.isort] +known_third_party = ["django", "rest_framework"] +default_section = "THIRDPARTY" +line_length = 88 +multi_line_output = 3 +use_parentheses = true +include_trailing_comma = true +force_grid_wrap = 0 + diff --git a/requirements-test.txt b/requirements-test.txt index d08f5891..c95f1de4 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -2,5 +2,4 @@ psycopg2~=2.8.0 django-filter>=2.0 contexttimer # QA checks -openwisp-utils[qa]~=1.0.5 -packaging~=20.4 +openwisp-utils[qa] @ https://github.com/openwisp/openwisp-utils/tarball/master diff --git a/rest_framework_gis/fields.py b/rest_framework_gis/fields.py index 395ef508..d22a7e78 100644 --- a/rest_framework_gis/fields.py +++ b/rest_framework_gis/fields.py @@ -65,7 +65,7 @@ def to_internal_value(self, value): value = json.dumps(value) try: return GEOSGeometry(value) - except (GEOSException): + except GEOSException: raise ValidationError( _( 'Invalid format: string or unicode input unrecognized as GeoJSON, WKT EWKT or HEXEWKB.' diff --git a/setup.cfg b/setup.cfg index 9162d1dc..cc627d28 100644 --- a/setup.cfg +++ b/setup.cfg @@ -9,10 +9,3 @@ max-line-length = 110 # W504: line break after or after operator # W605: invalid escape sequence ignore = W605, W503, W504 - -[isort] -multi_line_output=3 -use_parentheses=True -include_trailing_comma=True -force_grid_wrap=0 -line_length=88 diff --git a/tests/django_restframework_gis_tests/migrations/0001_initial.py b/tests/django_restframework_gis_tests/migrations/0001_initial.py index 7458e470..f33b4b0c 100644 --- a/tests/django_restframework_gis_tests/migrations/0001_initial.py +++ b/tests/django_restframework_gis_tests/migrations/0001_initial.py @@ -7,7 +7,6 @@ class Migration(migrations.Migration): - initial = True dependencies = [] diff --git a/tests/django_restframework_gis_tests/migrations/0002_nullable.py b/tests/django_restframework_gis_tests/migrations/0002_nullable.py index 5f0d7530..06059ef5 100644 --- a/tests/django_restframework_gis_tests/migrations/0002_nullable.py +++ b/tests/django_restframework_gis_tests/migrations/0002_nullable.py @@ -5,7 +5,6 @@ class Migration(migrations.Migration): - dependencies = [ ('django_restframework_gis_tests', '0001_initial'), ] diff --git a/tests/django_restframework_gis_tests/migrations/0004_auto_20240228_2357.py b/tests/django_restframework_gis_tests/migrations/0004_auto_20240228_2357.py index ff0da97a..2d5888a8 100644 --- a/tests/django_restframework_gis_tests/migrations/0004_auto_20240228_2357.py +++ b/tests/django_restframework_gis_tests/migrations/0004_auto_20240228_2357.py @@ -5,7 +5,6 @@ class Migration(migrations.Migration): - dependencies = [ ('django_restframework_gis_tests', '0003_schema_models'), ] diff --git a/tox.ini b/tox.ini index 63f36f82..88680b59 100644 --- a/tox.ini +++ b/tox.ini @@ -13,8 +13,7 @@ setenv = DRFG_TEST_RUNNER=./tests/manage.py test pytest: DRFG_TEST_RUNNER=-m pytest commands = - coverage run --source=rest_framework_gis {env:DRFG_TEST_RUNNER} {posargs:tests/django_restframework_gis_tests} - travis: - coveralls + coverage run {env:DRFG_TEST_RUNNER} {posargs:tests/django_restframework_gis_tests} deps = django22: Django~=2.2.0