Skip to content

Commit 0965157

Browse files
committed
Merge remote-tracking branch 'upstream/main'
# Conflicts: # CHANGELOG.md # pystac/extensions/mlm.py
2 parents df2ef7f + 918c629 commit 0965157

25 files changed

+2080
-1639
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- windows-latest
3333
- macos-latest
3434
steps:
35-
- uses: actions/checkout@v4
35+
- uses: actions/checkout@v5
3636
- uses: astral-sh/setup-uv@v6
3737
with:
3838
python-version: ${{ matrix.python-version }}
@@ -55,7 +55,7 @@ jobs:
5555
name: coverage
5656
runs-on: ubuntu-latest
5757
steps:
58-
- uses: actions/checkout@v4
58+
- uses: actions/checkout@v5
5959
- uses: astral-sh/setup-uv@v6
6060
- name: Install with dependencies
6161
run: uv sync --all-extras
@@ -84,7 +84,7 @@ jobs:
8484
without-orjson:
8585
runs-on: ubuntu-latest
8686
steps:
87-
- uses: actions/checkout@v4
87+
- uses: actions/checkout@v5
8888
- uses: astral-sh/setup-uv@v6
8989
- name: Sync
9090
run: uv sync
@@ -99,7 +99,7 @@ jobs:
9999
# appropriate for CI on Github actions.
100100
runs-on: ubuntu-latest
101101
steps:
102-
- uses: actions/checkout@v4
102+
- uses: actions/checkout@v5
103103
- uses: actions/setup-python@v5
104104
with:
105105
python-version: "3.10"
@@ -116,7 +116,7 @@ jobs:
116116
docs:
117117
runs-on: ubuntu-latest
118118
steps:
119-
- uses: actions/checkout@v4
119+
- uses: actions/checkout@v5
120120
- uses: astral-sh/setup-uv@v6
121121
- name: Install pandoc
122122
run: sudo apt-get install pandoc

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
id-token: write
1717
if: ${{ github.repository }} == 'stac-utils/pystac'
1818
steps:
19-
- uses: actions/checkout@v4
19+
- uses: actions/checkout@v5
2020
- name: Set up Python 3.x
2121
uses: actions/setup-python@v5
2222
with:

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
### Fixed
1212

13+
- More permissive collection extent deserialization ([#1559](https://github.com/stac-utils/pystac/pull/1559))
14+
- Type of `proj:code` setter ([#1560](https://github.com/stac-utils/pystac/pull/1560))
15+
- Use `urllib3` to fix parsing non-ascii in urls ([#1566](https://github.com/stac-utils/pystac/pull/1566))
16+
- Some return types and other **mypy** nits ([#1569](https://github.com/stac-utils/pystac/pull/1569))
1317
- `extensions.mlm` various fixes [#1556](https://github.com/stac-utils/pystac/pull/1556)
1418
- Fixed ResizeType typos `interpolation-nearest` and `interpolation-linear`
1519
- Fixed displaying the correct property in error message for `ResultStructure.data_type`

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ python -m pip install 'pystac[orjson]'
3535
```
3636

3737
If you would like to use a custom `RetryStacIO` class for automatically retrying
38-
network requests when reading with PySTAC, you'll need
38+
network requests when reading with PySTAC, or if you have non-ASCII characters in
39+
your urls you'll need
3940
[`urllib3`](https://urllib3.readthedocs.io/en/stable/):
4041

4142
```shell

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ dev = [
5555
"types-python-dateutil>=2.9.0.20241003",
5656
"types-requests>=2.32.0.20250328",
5757
"types-urllib3>=1.26.25.14",
58+
"urllib3>=2.3.0",
5859
"virtualenv>=20.26.6",
5960
]
6061
docs = [

pystac/collection.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
import warnings
4-
from collections.abc import Iterable
4+
from collections.abc import Iterable, Sequence
55
from copy import deepcopy
66
from datetime import datetime, timezone
77
from typing import (
@@ -71,7 +71,7 @@ class SpatialExtent:
7171

7272
def __init__(
7373
self,
74-
bboxes: Bboxes | list[float | int],
74+
bboxes: Bboxes | Sequence[float | int],
7575
extra_fields: dict[str, Any] | None = None,
7676
) -> None:
7777
if not isinstance(bboxes, list):
@@ -199,7 +199,7 @@ class TemporalExtent:
199199

200200
def __init__(
201201
self,
202-
intervals: TemporalIntervals | list[datetime | None],
202+
intervals: TemporalIntervals | Sequence[datetime | None],
203203
extra_fields: dict[str, Any] | None = None,
204204
):
205205
if not isinstance(intervals, list):
@@ -652,7 +652,17 @@ def from_dict(
652652
id = d.pop("id")
653653
description = d.pop("description")
654654
license = d.pop("license")
655-
extent = Extent.from_dict(d.pop("extent"))
655+
if extent_dict := d.pop("extent", None):
656+
extent = Extent.from_dict(extent_dict)
657+
else:
658+
warnings.warn(
659+
"Collection is missing extent, setting default spatial and "
660+
"temporal extents"
661+
)
662+
extent = Extent(
663+
spatial=SpatialExtent([-90, -180, 90, 180]),
664+
temporal=TemporalExtent([None, None]),
665+
)
656666
title = d.pop("title", None)
657667
stac_extensions = d.pop("stac_extensions", None)
658668
keywords = d.pop("keywords", None)

pystac/extensions/classification.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def value(self) -> int:
155155
Returns:
156156
int
157157
"""
158-
return get_required(self.properties.get("value"), self, "value")
158+
return cast(int, get_required(self.properties.get("value"), self, "value"))
159159

160160
@value.setter
161161
def value(self, v: int) -> None:
@@ -184,7 +184,7 @@ def name(self) -> str:
184184
Returns:
185185
Optional[str]
186186
"""
187-
return get_required(self.properties.get("name"), self, "name")
187+
return cast(str, get_required(self.properties.get("name"), self, "name"))
188188

189189
@name.setter
190190
def name(self, v: str) -> None:
@@ -200,7 +200,7 @@ def title(self) -> str | None:
200200
return self.properties.get("title")
201201

202202
@title.setter
203-
def title(self, v: str) -> None:
203+
def title(self, v: str | None) -> None:
204204
if v is not None:
205205
self.properties["title"] = v
206206
else:
@@ -392,7 +392,7 @@ def offset(self) -> int:
392392
Returns:
393393
int
394394
"""
395-
return get_required(self.properties.get("offset"), self, "offset")
395+
return cast(int, get_required(self.properties.get("offset"), self, "offset"))
396396

397397
@offset.setter
398398
def offset(self, v: int) -> None:
@@ -405,7 +405,7 @@ def length(self) -> int:
405405
Returns:
406406
int
407407
"""
408-
return get_required(self.properties.get("length"), self, "length")
408+
return cast(int, get_required(self.properties.get("length"), self, "length"))
409409

410410
@length.setter
411411
def length(self, v: int) -> None:

pystac/extensions/datacube.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,11 @@ def dim_type(self) -> DimensionType | str:
8888
<datacube#temporal-dimension-object>`. May be an arbitrary string for
8989
:stac-ext:`Additional Dimension Objects
9090
<datacube#additional-dimension-object>`."""
91-
return get_required(
92-
self.properties.get(DIM_TYPE_PROP), "cube:dimension", DIM_TYPE_PROP
91+
return cast(
92+
str,
93+
get_required(
94+
self.properties.get(DIM_TYPE_PROP), "cube:dimension", DIM_TYPE_PROP
95+
),
9396
)
9497

9598
@dim_type.setter
@@ -198,8 +201,11 @@ class HorizontalSpatialDimension(SpatialDimension):
198201
@property
199202
def axis(self) -> HorizontalSpatialDimensionAxis:
200203
"""Axis of the spatial dimension. Must be one of ``"x"`` or ``"y"``."""
201-
return get_required(
202-
self.properties.get(DIM_AXIS_PROP), "cube:dimension", DIM_AXIS_PROP
204+
return cast(
205+
HorizontalSpatialDimensionAxis,
206+
get_required(
207+
self.properties.get(DIM_AXIS_PROP), "cube:dimension", DIM_AXIS_PROP
208+
),
203209
)
204210

205211
@axis.setter
@@ -211,8 +217,11 @@ class VerticalSpatialDimension(SpatialDimension):
211217
@property
212218
def axis(self) -> VerticalSpatialDimensionAxis:
213219
"""Axis of the spatial dimension. Must be ``"z"``."""
214-
return get_required(
215-
self.properties.get(DIM_AXIS_PROP), "cube:dimension", DIM_AXIS_PROP
220+
return cast(
221+
VerticalSpatialDimensionAxis,
222+
get_required(
223+
self.properties.get(DIM_AXIS_PROP), "cube:dimension", DIM_AXIS_PROP
224+
),
216225
)
217226

218227
@axis.setter
@@ -453,8 +462,11 @@ def dimensions(self, v: list[str]) -> None:
453462
@property
454463
def var_type(self) -> VariableType | str:
455464
"""Type of the variable, either ``data`` or ``auxiliary``"""
456-
return get_required(
457-
self.properties.get(VAR_TYPE_PROP), "cube:variable", VAR_TYPE_PROP
465+
return cast(
466+
str,
467+
get_required(
468+
self.properties.get(VAR_TYPE_PROP), "cube:variable", VAR_TYPE_PROP
469+
),
458470
)
459471

460472
@var_type.setter

pystac/extensions/eo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def name(self) -> str:
134134
Returns:
135135
str
136136
"""
137-
return get_required(self.properties.get("name"), self, "name")
137+
return cast(str, get_required(self.properties.get("name"), self, "name"))
138138

139139
@name.setter
140140
def name(self, v: str) -> None:

pystac/extensions/file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def values(self, v: list[Any]) -> None:
9090
@property
9191
def summary(self) -> str:
9292
"""Gets or sets the short description of the value(s)."""
93-
return get_required(self.properties.get("summary"), self, "summary")
93+
return cast(str, get_required(self.properties.get("summary"), self, "summary"))
9494

9595
@summary.setter
9696
def summary(self, v: str) -> None:

0 commit comments

Comments
 (0)