[Git][debian-gis-team/python-geojson][master] 4 commits: New upstream version 3.1.0

Bas Couwenberg (@sebastic) gitlab at salsa.debian.org
Mon Nov 6 04:38:44 GMT 2023



Bas Couwenberg pushed to branch master at Debian GIS Project / python-geojson


Commits:
39e7aac5 by Bas Couwenberg at 2023-11-06T05:27:08+01:00
New upstream version 3.1.0
- - - - -
a1a190b8 by Bas Couwenberg at 2023-11-06T05:27:08+01:00
Update upstream source from tag 'upstream/3.1.0'

Update to upstream version '3.1.0'
with Debian dir 5b935a166454c730791aaebef995a85948fcd696
- - - - -
0213f6a9 by Bas Couwenberg at 2023-11-06T05:27:22+01:00
New upstream release.

- - - - -
7dfdb3d1 by Bas Couwenberg at 2023-11-06T05:36:50+01:00
Use pytest for tests.

- - - - -


18 changed files:

- + .flake8
- + .github/workflows/lint.yml
- .github/workflows/test.yml
- .gitignore
- .pre-commit-config.yaml
- CHANGELOG.rst
- README.rst
- debian/changelog
- debian/control
- debian/rules
- geojson/_version.py
- geojson/examples.py
- geojson/feature.py
- geojson/utils.py
- setup.py
- tests/data.geojson
- tests/test_utils.py
- tox.ini


Changes:

=====================================
.flake8
=====================================
@@ -0,0 +1,2 @@
+[flake8]
+max-line-length = 100


=====================================
.github/workflows/lint.yml
=====================================
@@ -0,0 +1,19 @@
+name: Lint
+
+on: [push, pull_request, workflow_dispatch]
+
+permissions:
+  contents: read
+
+jobs:
+  lint:
+    runs-on: ubuntu-latest
+
+    steps:
+      - uses: actions/checkout at v3
+
+      - uses: actions/setup-python at v4
+        with:
+          python-version: "3.x"
+
+      - uses: pre-commit/action at v3.0.0


=====================================
.github/workflows/test.yml
=====================================
@@ -1,14 +1,17 @@
 name: Test
 
-on: [push, pull_request]
+on: [push, pull_request, workflow_dispatch]
+
+env:
+  FORCE_COLOR: 1
 
 jobs:
   build:
     runs-on: ubuntu-latest
     strategy:
-      max-parallel: 6
+      fail-fast: false
       matrix:
-        python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', 'pypy-3.8']
+        python-version: ['pypy3.9', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
 
     steps:
     - uses: actions/checkout at v3
@@ -17,30 +20,18 @@ jobs:
       uses: actions/setup-python at v4
       with:
         python-version: ${{ matrix.python-version }}
-
-    - name: Get pip cache dir
-      id: pip-cache
-      run: |
-        echo "::set-output name=dir::$(pip cache dir)"
-
-    - name: Cache
-      uses: actions/cache at v3
-      with:
-        path: ${{ steps.pip-cache.outputs.dir }}
-        key:
-          ${{ matrix.os }}-${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.py') }}
-        restore-keys: |
-          ${{ matrix.os }}-${{ matrix.python-version }}-v1-
+        allow-prereleases: true
+        cache: pip
+        cache-dependency-path: tox.ini
 
     - name: Install dependencies
       run: |
         python -m pip install --upgrade pip
-        python -m pip install --upgrade codecov
+        python -m pip install --upgrade tox
 
     - name: Tests
       run: |
-        coverage run --branch --source=geojson setup.py test
-        coverage xml
+          tox -e py
 
     - name: Upload coverage
       uses: codecov/codecov-action at v3


=====================================
.gitignore
=====================================
@@ -6,3 +6,7 @@ sdist/
 *.egg-info/
 *.egg
 .tox/
+.coverage
+coverage.xml
+.idea
+.venv*


=====================================
.pre-commit-config.yaml
=====================================
@@ -2,8 +2,21 @@ repos:
   - repo: https://github.com/pre-commit/pre-commit-hooks
     rev: v4.4.0
     hooks:
+      - id: check-case-conflict
       - id: check-merge-conflict
       - id: check-yaml
+      - id: end-of-file-fixer
+      - id: trailing-whitespace
+
+  - repo: https://github.com/tox-dev/tox-ini-fmt
+    rev: 1.3.1
+    hooks:
+      - id: tox-ini-fmt
+
+  - repo: https://github.com/PyCQA/flake8
+    rev: 6.1.0
+    hooks:
+      - id: flake8
 
 ci:
   autoupdate_schedule: quarterly


=====================================
CHANGELOG.rst
=====================================
@@ -2,15 +2,34 @@ Changes
 =======
 
 
-3.0.1 (2022-02-15)
+3.1.0
+----------
+
+- Add support for Python 3.12
+
+  - https://github.com/jazzband/geojson/pull/222
+  - https://github.com/jazzband/geojson/pull/211
+
+- CI improvements
+
+  - https://github.com/jazzband/geojson/pull/217
+  - https://github.com/jazzband/geojson/pull/212
+  - https://github.com/jazzband/geojson/pull/207
+
+- Unit test improvements
+
+  - https://github.com/jazzband/geojson/pull/215
+  - https://github.com/jazzband/geojson/pull/210
+  - https://github.com/jazzband/geojson/pull/209
+
+3.0.1 (2023-02-15)
 ------------------
 
 - Add Support for Python 3.11.x minor revisions
 
   - https://github.com/jazzband/geojson/pull/198
 
-
-3.0.0 (2022-01-26)
+3.0.0 (2023-01-26)
 ------------------
 
 - Support for Python versions 3.7-3.11 (Python 2 no longer supported)


=====================================
README.rst
=====================================
@@ -26,7 +26,7 @@ This Python library contains:
 Installation
 ------------
 
-geojson is compatible with Python 3.7 - 3.11. The recommended way to install is via pip_:
+geojson is compatible with Python 3.7 - 3.12. The recommended way to install is via pip_:
 
 .. code::
 
@@ -288,7 +288,7 @@ coordinates to 6 decimal places (roughly 0.1 meters) by default and can be custo
   {"coordinates": [-115.12341234, 37.12341234], "type": "Point"}
 
 
-Precision can be set at the package level by setting `geojson.geometry.DEFAULT_PRECISION` 
+Precision can be set at the package level by setting `geojson.geometry.DEFAULT_PRECISION`
 
 
 .. code:: python
@@ -410,7 +410,7 @@ Development
 -----------
 
 To build this project, run :code:`python setup.py build`.
-To run the unit tests, run :code:`python setup.py test`.
+To run the unit tests, run :code:`python -m pip install tox && tox`.
 To run the style checks, run :code:`flake8` (install `flake8` if needed).
 
 Credits


=====================================
debian/changelog
=====================================
@@ -1,14 +1,16 @@
-python-geojson (3.0.1-2) UNRELEASED; urgency=medium
+python-geojson (3.1.0-1) UNRELEASED; urgency=medium
 
   * Team upload.
+  * New upstream release.
   * Bump debhelper compat to 13.
   * Use autopkgtest-pkg-pybuild testsuite.
   * Enable Salsa CI.
   * Remove generated files in clean target.
     (closes: #1048468)
   * Switch to dh-sequence-*.
+  * Use pytest for tests.
 
- -- Bas Couwenberg <sebastic at debian.org>  Tue, 13 Jun 2023 10:04:41 +0200
+ -- Bas Couwenberg <sebastic at debian.org>  Mon, 06 Nov 2023 05:27:13 +0100
 
 python-geojson (3.0.1-1) unstable; urgency=medium
 


=====================================
debian/control
=====================================
@@ -7,6 +7,7 @@ Build-Depends: debhelper-compat (= 13),
                dh-python,
                dh-sequence-python3,
                python3-all,
+               python3-pytest,
                python3-setuptools
 Standards-Version: 4.6.2
 Vcs-Browser: https://salsa.debian.org/debian-gis-team/python-geojson


=====================================
debian/rules
=====================================
@@ -5,6 +5,8 @@ export LC_ALL=C.UTF-8
 export LANG=C.UTF-8
 
 export PYBUILD_NAME=geojson
+export PYBUILD_TEST_PYTEST=1
+export PYBUILD_TEST_ARGS=-vv
 
 %:
 	dh  $@ --buildsystem pybuild


=====================================
geojson/_version.py
=====================================
@@ -1,2 +1,2 @@
-__version__ = "3.0.1"
+__version__ = "3.1.0"
 __version_info__ = tuple(map(int, __version__.split(".")))


=====================================
geojson/examples.py
=====================================
@@ -1,3 +1,9 @@
+"""
+SimpleWebFeature is a working example of a class that satisfies the Python geo
+interface.
+"""
+
+
 class SimpleWebFeature:
 
     """
@@ -36,12 +42,6 @@ class SimpleWebFeature:
 
     __geo_interface__ = property(as_dict)
 
-    """
-    Create an instance of SimpleWebFeature from a dict, o. If o does not
-    match a Python feature object, simply return o. This function serves as a
-    json decoder hook. See coding.load().
-    """
-
 
 def create_simple_web_feature(o):
     """


=====================================
geojson/feature.py
=====================================
@@ -1,8 +1,3 @@
-"""
-SimpleWebFeature is a working example of a class that satisfies the Python geo
-interface.
-"""
-
 from geojson.base import GeoJSON
 
 


=====================================
geojson/utils.py
=====================================
@@ -209,11 +209,11 @@ def generate_random(featureType, numberVertices=3,
         return Polygon([points])
 
     def clip(x, min, max):
-        if(min > max):
+        if min > max:
             return x
-        elif(x < min):
+        elif x < min:
             return min
-        elif(x > max):
+        elif x > max:
             return max
         else:
             return x
@@ -226,3 +226,5 @@ def generate_random(featureType, numberVertices=3,
 
     if featureType == 'Polygon':
         return createPoly()
+
+    raise ValueError(f"featureType: {featureType} is not supported.")


=====================================
setup.py
=====================================
@@ -16,18 +16,9 @@ else:
     raise RuntimeError(f"Unable to find version string in {VERSIONFILE}.")
 
 
-def test_suite():
-    import doctest
-    import unittest
-
-    suite = unittest.TestLoader().discover("tests")
-    suite.addTest(doctest.DocFileSuite("README.rst"))
-    return suite
-
-
 major_version, minor_version = sys.version_info[:2]
-if not (major_version == 3 and 7 <= minor_version <= 11):
-    sys.stderr.write("Sorry, only Python 3.7 - 3.11 are "
+if not (major_version == 3 and 7 <= minor_version <= 12):
+    sys.stderr.write("Sorry, only Python 3.7 - 3.12 are "
                      "supported at this time.\n")
     exit(1)
 
@@ -47,8 +38,7 @@ setup(
     package_dir={"geojson": "geojson"},
     package_data={"geojson": ["*.rst"]},
     install_requires=[],
-    test_suite="setup.test_suite",
-    python_requires=">=3.7, <3.12",
+    python_requires=">=3.7",
     classifiers=[
         "Development Status :: 5 - Production/Stable",
         "Intended Audience :: Developers",
@@ -62,6 +52,7 @@ setup(
         "Programming Language :: Python :: 3.9",
         "Programming Language :: Python :: 3.10",
         "Programming Language :: Python :: 3.11",
+        "Programming Language :: Python :: 3.12",
         "Topic :: Scientific/Engineering :: GIS",
     ]
 )


=====================================
tests/data.geojson
=====================================
@@ -1,7 +1,7 @@
 {
    "properties": {
       "Ã": "Ã"
-   }, 
+   },
    "type": "Feature",
    "geometry": null
 }


=====================================
tests/test_utils.py
=====================================
@@ -6,7 +6,7 @@ import random
 import unittest
 
 import geojson
-from geojson.utils import generate_random
+from geojson.utils import generate_random, map_geometries
 
 
 def generate_bbox():
@@ -32,6 +32,17 @@ def check_polygon_bbox(polygon, bbox):
     return True
 
 
+def check_point_bbox(point, bbox):
+    min_lon, min_lat, max_lon, max_lat = bbox
+    eps = 1e-3
+    if (
+        min_lon - eps <= point["coordinates"][0] <= max_lon + eps
+        and min_lat - eps <= point["coordinates"][1] <= max_lat + eps
+    ):
+        return True
+    return False
+
+
 class TestGenerateRandom(unittest.TestCase):
     def test_simple_polygon(self):
         for _ in range(5000):
@@ -48,3 +59,41 @@ class TestGenerateRandom(unittest.TestCase):
             self.assertIsInstance(result, geojson.geometry.Polygon)
             self.assertTrue(geojson.geometry.check_polygon(result))
             self.assertTrue(check_polygon_bbox(result, bbox))
+
+    def test_bbox_point(self):
+        for _ in range(5000):
+            bbox = generate_bbox()
+            result = generate_random("Point", boundingBox=bbox)
+            self.assertIsInstance(result, geojson.geometry.Point)
+            self.assertTrue(geojson.geometry.check_point(result))
+            self.assertTrue(check_point_bbox(result, bbox))
+
+    def test_raise_value_error(self):
+        with self.assertRaises(ValueError):
+            generate_random("MultiPolygon")
+
+
+class TestMapGeometries(unittest.TestCase):
+    def test_with_simple_type(self):
+        new_point = map_geometries(
+            lambda g: geojson.MultiPoint([g["coordinates"]]),
+            geojson.Point((-115.81, 37.24)),
+        )
+        self.assertEqual(new_point, geojson.MultiPoint([(-115.81, 37.24)]))
+
+    def test_with_feature_collection(self):
+        new_point = map_geometries(
+            lambda g: geojson.MultiPoint([g["coordinates"]]),
+            geojson.FeatureCollection([geojson.Point((-115.81, 37.24))]),
+        )
+        self.assertEqual(
+            new_point,
+            geojson.FeatureCollection(
+                [geojson.MultiPoint([geojson.Point((-115.81, 37.24))])]
+            ),
+        )
+
+    def test_raise_value_error(self):
+        invalid_object = geojson.Feature(type="InvalidType")
+        with self.assertRaises(ValueError):
+            map_geometries(lambda g: g, invalid_object)


=====================================
tox.ini
=====================================
@@ -1,10 +1,14 @@
-# Tox (http://tox.testrun.org/) is a tool for running tests
-# in multiple virtualenvs. This configuration file will run the
-# test suite on all supported python versions. To use it, "pip install tox"
-# and then run "tox" from this directory.
-
 [tox]
-envlist = py{36,37,38,39,310}, pypy3
+requires =
+    tox>=4.2
+env_list =
+    py{py3, 312, 311, 310, 39, 38, 37}
 
 [testenv]
-commands = {envpython} setup.py test
+deps =
+    pytest
+    pytest-cov
+pass_env =
+    FORCE_COLOR
+commands =
+    {envpython} -m pytest --cov geojson --cov tests --cov-report xml {posargs}



View it on GitLab: https://salsa.debian.org/debian-gis-team/python-geojson/-/compare/a49c40f6c88570b6bf3c7e52b8e43b4940dd8c5d...7dfdb3d1b51ba6bc43ec02e2c3edb0231da98556

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/python-geojson/-/compare/a49c40f6c88570b6bf3c7e52b8e43b4940dd8c5d...7dfdb3d1b51ba6bc43ec02e2c3edb0231da98556
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20231106/7753a827/attachment-0001.htm>


More information about the Pkg-grass-devel mailing list