Skip to content

Commit ede5a1d

Browse files
Merge pull request #170 from developmentseed/feature/python-version-support
update python version support and switch to ruff-format
2 parents 2cec40a + 658338b commit ede5a1d

File tree

8 files changed

+41
-29
lines changed

8 files changed

+41
-29
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@ on:
88
- '*'
99
pull_request:
1010
env:
11-
LATEST_PY_VERSION: '3.12'
11+
LATEST_PY_VERSION: '3.13'
1212

1313
jobs:
1414
tests:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
1818
python-version:
19-
- '3.8'
2019
- '3.9'
2120
- '3.10'
2221
- '3.11'
2322
- '3.12'
23+
- '3.13'
24+
# - '3.14.0-alpha.2', waiting for shapely to support 3.14
2425

2526
steps:
2627
- uses: actions/checkout@v4
@@ -57,9 +58,9 @@ jobs:
5758
runs-on: ubuntu-latest
5859
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
5960
steps:
60-
- uses: actions/checkout@v3
61+
- uses: actions/checkout@v4
6162
- name: Set up Python
62-
uses: actions/setup-python@v4
63+
uses: actions/setup-python@v5
6364
with:
6465
python-version: ${{ env.LATEST_PY_VERSION }}
6566

@@ -71,11 +72,14 @@ jobs:
7172
7273
- name: Set tag version
7374
id: tag
74-
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
75+
run: |
76+
echo "version=${GITHUB_REF#refs/*/}"
77+
echo "version=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
7578
7679
- name: Set module version
7780
id: module
78-
run: echo ::set-output name=version::$(python -c 'from importlib.metadata import version; print(version("geojson_pydantic"))')
81+
run: |
82+
echo version=$(python -c'import geojson_pydantic; print(geojson_pydantic.__version__)') >> $GITHUB_OUTPUT
7983
8084
- name: Build and publish
8185
if: steps.tag.outputs.tag == steps.module.outputs.version

.pre-commit-config.yaml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,21 @@ repos:
44
hooks:
55
- id: validate-pyproject
66

7-
- repo: https://github.com/psf/black
8-
rev: 22.12.0
9-
hooks:
10-
- id: black
11-
language_version: python
12-
137
- repo: https://github.com/PyCQA/isort
14-
rev: 5.12.0
8+
rev: 5.13.2
159
hooks:
1610
- id: isort
1711
language_version: python
1812

19-
- repo: https://github.com/charliermarsh/ruff-pre-commit
20-
rev: v0.0.238
13+
- repo: https://github.com/astral-sh/ruff-pre-commit
14+
rev: v0.3.5
2115
hooks:
2216
- id: ruff
2317
args: ["--fix"]
18+
- id: ruff-format
2419

2520
- repo: https://github.com/pre-commit/mirrors-mypy
26-
rev: v1.4.1
21+
rev: v1.11.2
2722
hooks:
2823
- id: mypy
2924
language_version: python

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
66

77
Note: Minor version `0.X.0` update might break the API, It's recommended to pin geojson-pydantic to minor version: `geojson-pydantic>=0.6,<0.7`
88

9+
## [unreleased]
10+
11+
## [1.2.0] - 2024-12-19
12+
13+
* drop python 3.8 support
14+
* add python 3.13 support
15+
916
## [1.1.2] - 2024-10-22
1017

1118
* relax `bbox` validation and allow antimeridian crossing bboxes
@@ -369,7 +376,8 @@ Although the type file was added in `0.2.0` it wasn't included in the distribute
369376
### Added
370377
- Initial Release
371378

372-
[unreleased]: https://github.com/developmentseed/geojson-pydantic/compare/1.1.2...HEAD
379+
[unreleased]: https://github.com/developmentseed/geojson-pydantic/compare/1.2.0...HEAD
380+
[1.2.0]: https://github.com/developmentseed/geojson-pydantic/compare/1.1.2...1.2.0
373381
[1.1.2]: https://github.com/developmentseed/geojson-pydantic/compare/1.1.1...1.1.2
374382
[1.1.1]: https://github.com/developmentseed/geojson-pydantic/compare/1.1.0...1.1.1
375383
[1.1.0]: https://github.com/developmentseed/geojson-pydantic/compare/1.0.2...1.1.0

geojson_pydantic/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""pydantic BaseModel for GeoJSON objects."""
2+
23
from __future__ import annotations
34

45
import warnings
@@ -42,6 +43,7 @@ def validate_bbox(cls, bbox: Optional[BBox]) -> Optional[BBox]:
4243
warnings.warn(
4344
f"BBOX crossing the Antimeridian line, Min X ({bbox[0]}) > Max X ({bbox[offset]}).",
4445
UserWarning,
46+
stacklevel=1,
4547
)
4648

4749
# Check Y

geojson_pydantic/geometries.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""pydantic models for GeoJSON Geometry objects."""
2+
23
from __future__ import annotations
34

45
import abc
@@ -285,17 +286,20 @@ def check_geometries(cls, geometries: List) -> List:
285286
"""Add warnings for conditions the spec does not explicitly forbid."""
286287
if len(geometries) == 1:
287288
warnings.warn(
288-
"GeometryCollection should not be used for single geometries."
289+
"GeometryCollection should not be used for single geometries.",
290+
stacklevel=1,
289291
)
290292

291293
if any(geom.type == "GeometryCollection" for geom in geometries):
292294
warnings.warn(
293-
"GeometryCollection should not be used for nested GeometryCollections."
295+
"GeometryCollection should not be used for nested GeometryCollections.",
296+
stacklevel=1,
294297
)
295298

296299
if len({geom.type for geom in geometries}) == 1:
297300
warnings.warn(
298-
"GeometryCollection should not be used for homogeneous collections."
301+
"GeometryCollection should not be used for homogeneous collections.",
302+
stacklevel=1,
299303
)
300304

301305
return geometries

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ classifiers = [
1212
"Intended Audience :: Information Technology",
1313
"Intended Audience :: Science/Research",
1414
"License :: OSI Approved :: MIT License",
15-
"Programming Language :: Python :: 3.8",
1615
"Programming Language :: Python :: 3.9",
1716
"Programming Language :: Python :: 3.10",
1817
"Programming Language :: Python :: 3.11",
1918
"Programming Language :: Python :: 3.12",
19+
"Programming Language :: Python :: 3.13",
2020
"Topic :: Scientific/Engineering :: GIS",
2121
"Typing :: Typed",
2222
]
@@ -81,7 +81,7 @@ warn_unused_ignores = true
8181
no_implicit_optional = true
8282
show_error_codes = true
8383

84-
[tool.ruff]
84+
[tool.ruff.lint]
8585
select = [
8686
"D1", # pydocstyle errors
8787
"E", # pycodestyle errors
@@ -96,7 +96,7 @@ ignore = [
9696
"B905", # ignore zip() without an explicit strict= parameter, only support with python >3.10
9797
]
9898

99-
[tool.ruff.per-file-ignores]
99+
[tool.ruff.lint.per-file-ignores]
100100
"tests/*.py" = ["D1"]
101101

102102
[tool.bumpversion]

tests/test_features.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def test_generic_properties_is_dict():
106106
feature = Feature(**test_feature)
107107
assert hasattr(feature, "__geo_interface__")
108108
assert feature.properties["id"] == test_feature["properties"]["id"]
109-
assert type(feature.properties) == dict
109+
assert isinstance(feature.properties, dict)
110110
assert not hasattr(feature.properties, "id")
111111

112112

@@ -116,7 +116,7 @@ def test_generic_properties_is_dict_collection():
116116
assert (
117117
feature.properties["id"] == test_feature_geometry_collection["properties"]["id"]
118118
)
119-
assert type(feature.properties) == dict
119+
assert isinstance(feature.properties, dict)
120120
assert not hasattr(feature.properties, "id")
121121

122122

@@ -137,7 +137,7 @@ def test_generic_geometry():
137137
feature = Feature[Polygon, Dict](**test_feature)
138138
assert type(feature.geometry) == Polygon
139139
assert feature.properties["id"] == test_feature["properties"]["id"]
140-
assert type(feature.properties) == dict
140+
assert isinstance(feature.properties, dict)
141141
assert not hasattr(feature.properties, "id")
142142

143143
with pytest.raises(ValidationError):
@@ -159,7 +159,7 @@ def test_generic_geometry_collection():
159159
assert (
160160
feature.properties["id"] == test_feature_geometry_collection["properties"]["id"]
161161
)
162-
assert type(feature.properties) == dict
162+
assert isinstance(feature.properties, dict)
163163
assert not hasattr(feature.properties, "id")
164164

165165
with pytest.raises(ValidationError):

tests/test_geometries.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,7 @@ def test_polygon_from_bounds():
596596
def test_wkt_name():
597597
"""Make sure WKT name is derived from geometry Type."""
598598

599-
class PointType(Point):
600-
...
599+
class PointType(Point): ...
601600

602601
assert (
603602
PointType(type="Point", coordinates=(1.01, 2.01)).wkt

0 commit comments

Comments
 (0)