Skip to content

Commit 665a984

Browse files
Merge pull request #171 from developmentseed/feature/python-version-support
update python version support and update pyproj version requirement
2 parents 0ab27a7 + 2cbf0b4 commit 665a984

File tree

8 files changed

+40
-36
lines changed

8 files changed

+40
-36
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,26 @@ 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'
20-
- '3.9'
21-
- '3.10'
22-
- '3.11'
23-
- '3.12'
19+
- '3.8'
20+
- '3.9'
21+
- '3.10'
22+
- '3.11'
23+
- '3.12'
24+
- '3.13'
25+
# - '3.14.0-alpha.2' wait for pyproj and rasterio wheels to support 3.14
2426

2527
steps:
26-
- uses: actions/checkout@v3
28+
- uses: actions/checkout@v4
2729
- name: Set up Python ${{ matrix.python-version }}
28-
uses: actions/setup-python@v4
30+
uses: actions/setup-python@v5
2931
with:
3032
python-version: ${{ matrix.python-version }}
3133

@@ -60,7 +62,7 @@ jobs:
6062
- name: Set up Python
6163
uses: actions/setup-python@v5
6264
with:
63-
python-version: '3.12'
65+
python-version: '3.13'
6466

6567
- name: Install dependencies
6668
run: |
@@ -92,9 +94,9 @@ jobs:
9294
runs-on: ubuntu-latest
9395
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
9496
steps:
95-
- uses: actions/checkout@v3
97+
- uses: actions/checkout@v4
9698
- name: Set up Python
97-
uses: actions/setup-python@v4
99+
uses: actions/setup-python@v5
98100
with:
99101
python-version: ${{ env.LATEST_PY_VERSION }}
100102

.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

CHANGES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11

2+
## Unreleased
3+
4+
* add python 3.13 support
5+
* update pyproj dependency version to `>=3.1,<4.0`
6+
27
## 6.1.0 (2024-10-17)
38

49
* add `_tile_matrices_idx: Dict[str, int]` private attribute to improve `matrices` lookup

morecantile/defaults.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def register(
5555
"""Register TileMatrixSet(s)."""
5656
for identifier in custom_tms.keys():
5757
if identifier in self.tms and not overwrite:
58-
raise Exception(f"{identifier} is already a registered TMS.")
58+
raise InvalidIdentifier(f"{identifier} is already a registered TMS.")
5959

6060
return TileMatrixSets({**self.tms, **custom_tms})
6161

morecantile/models.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@ def __init__(self, **data):
510510
"Could not create coordinate Transformer from input CRS to the given geographic CRS"
511511
"some methods might not be available.",
512512
UserWarning,
513+
stacklevel=1,
513514
)
514515
self._to_geographic = None
515516
self._from_geographic = None
@@ -537,10 +538,8 @@ def is_quadtree(self) -> bool:
537538
def is_variable(self) -> bool:
538539
"""Check if TMS has variable width matrix."""
539540
return any(
540-
[
541-
True if matrix.variableMatrixWidths is not None else False
542-
for matrix in self.tileMatrices
543-
]
541+
True if matrix.variableMatrixWidths is not None else False
542+
for matrix in self.tileMatrices
544543
)
545544

546545
def __iter__(self):
@@ -800,6 +799,7 @@ def matrix(self, zoom: int) -> TileMatrix:
800799
warnings.warn(
801800
f"TileMatrix not found for level: {zoom} - Creating values from TMS Scale.",
802801
UserWarning,
802+
stacklevel=1,
803803
)
804804

805805
# TODO: what if we want to construct a matrix for a level up ?
@@ -894,6 +894,7 @@ def lnglat(self, x: float, y: float, truncate=False) -> Coords:
894894
warnings.warn(
895895
f"Point ({x}, {y}) is outside TMS bounds {list(self.xy_bbox)}.",
896896
PointOutsideTMSBounds,
897+
stacklevel=1,
897898
)
898899

899900
lng, lat = self._to_geographic.transform(x, y)
@@ -913,6 +914,7 @@ def xy(self, lng: float, lat: float, truncate=False) -> Coords:
913914
warnings.warn(
914915
f"Point ({lng}, {lat}) is outside TMS bounds {list(self.bbox)}.",
915916
PointOutsideTMSBounds,
917+
stacklevel=1,
916918
)
917919

918920
x, y = self._from_geographic.transform(lng, lat)
@@ -1372,6 +1374,7 @@ def feature(
13721374
"CRS is no longer part of the GeoJSON specification."
13731375
"Other projection than EPSG:4326 might not be supported.",
13741376
UserWarning,
1377+
stacklevel=1,
13751378
)
13761379
feat.update(
13771380
{

morecantile/utils.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,10 @@ def is_power_of_two(number: int) -> bool:
118118
def check_quadkey_support(tms: List) -> bool:
119119
"""Check if a Tile Matrix Set supports quadkeys"""
120120
return all(
121-
[
122-
(t.matrixWidth == t.matrixHeight)
123-
and is_power_of_two(t.matrixWidth)
124-
and ((t.matrixWidth * 2) == tms[i + 1].matrixWidth)
125-
for i, t in enumerate(tms[:-1])
126-
]
121+
(t.matrixWidth == t.matrixHeight)
122+
and is_power_of_two(t.matrixWidth)
123+
and ((t.matrixWidth * 2) == tms[i + 1].matrixWidth)
124+
for i, t in enumerate(tms[:-1])
127125
)
128126

129127

pyproject.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ classifiers = [
1717
"Programming Language :: Python :: 3.10",
1818
"Programming Language :: Python :: 3.11",
1919
"Programming Language :: Python :: 3.12",
20+
"Programming Language :: Python :: 3.13",
2021
"Topic :: Scientific/Engineering :: GIS",
2122
]
2223
dynamic = ["version"]
2324
dependencies = [
2425
"attrs",
25-
"pyproj~=3.1",
26+
"pyproj>=3.1,<4.0",
2627
"pydantic~=2.0",
2728
]
2829

@@ -95,7 +96,7 @@ default_section = "THIRDPARTY"
9596
[tool.mypy]
9697
no_strict_optional = true
9798

98-
[tool.ruff]
99+
[tool.ruff.lint]
99100
select = [
100101
"D1", # pydocstyle errors
101102
"E", # pycodestyle errors
@@ -110,7 +111,7 @@ ignore = [
110111
"B905", # ignore zip() without an explicit strict= parameter, only support with python >3.10
111112
]
112113

113-
[tool.ruff.per-file-ignores]
114+
[tool.ruff.lint.per-file-ignores]
114115
"tests/*.py" = ["D1"]
115116

116117

tests/test_morecantile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def test_register():
4343
assert "MyCustomGrid3031" in defaults.list()
4444

4545
# Check it will raise an exception if TMS is already registered
46-
with pytest.raises(Exception):
46+
with pytest.raises(InvalidIdentifier):
4747
defaults = defaults.register({"MyCustomGrid3031": tms})
4848

4949
# Do not raise is overwrite=True

0 commit comments

Comments
 (0)