Skip to content

Commit 9f236be

Browse files
replace ciso8601 with pyiso8601 (#448)
* replace ciso8601 with pyiso8601 * update changelog * test types package in ci
1 parent 4369424 commit 9f236be

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

Diff for: .github/workflows/cicd.yaml

+7-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,13 @@ jobs:
8585
cd stac_fastapi/api && pipenv run pytest -svvv
8686
env:
8787
ENVIRONMENT: testing
88-
88+
89+
- name: Run test suite
90+
run: |
91+
cd stac_fastapi/types && pipenv run pytest -svvv
92+
env:
93+
ENVIRONMENT: testing
94+
8995
- name: Run test suite
9096
run: |
9197
cd stac_fastapi/sqlalchemy && pipenv run pytest -svvv

Diff for: CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
### Removed
1010

1111
### Fixed
12+
* `ciso8601` fails to build in some environments, instead use `pyiso8601` to parse datetimes.
1213

1314
## [2.4.0]
1415

Diff for: stac_fastapi/types/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"pydantic[dotenv]",
1212
"stac_pydantic==2.0.*",
1313
"pystac==1.*",
14-
"ciso8601~=2.2.0",
14+
"iso8601~=1.0.2",
1515
]
1616

1717
extra_reqs = {

Diff for: stac_fastapi/types/stac_fastapi/types/rfc3339.py

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
"""rfc3339."""
2-
2+
import re
33
from datetime import datetime, timezone
44
from typing import Optional, Tuple
55

6-
import ciso8601
6+
import iso8601
77
from pystac.utils import datetime_to_str
88

9+
RFC33339_PATTERN = r"^(\d\d\d\d)\-(\d\d)\-(\d\d)(T|t)(\d\d):(\d\d):(\d\d)([.]\d+)?(Z|([-+])(\d\d):(\d\d))$"
10+
911

1012
def rfc3339_str_to_datetime(s: str) -> datetime:
1113
"""Convert a string conforming to RFC 3339 to a :class:`datetime.datetime`.
1214
13-
Uses :meth:`ciso8601.parse_rfc3339` under the hood.
15+
Uses :meth:`iso8601.parse_date` under the hood.
1416
1517
Args:
1618
s (str) : The string to convert to :class:`datetime.datetime`.
@@ -21,7 +23,16 @@ def rfc3339_str_to_datetime(s: str) -> datetime:
2123
Raises:
2224
ValueError: If the string is not a valid RFC 3339 string.
2325
"""
24-
return ciso8601.parse_rfc3339(s)
26+
# Uppercase the string
27+
s = s.upper()
28+
29+
# Match against RFC3339 regex.
30+
result = re.match(RFC33339_PATTERN, s)
31+
if not result:
32+
raise ValueError("Invalid RFC3339 datetime.")
33+
34+
# Parse with pyiso8601
35+
return iso8601.parse_date(s)
2536

2637

2738
def str_to_interval(

0 commit comments

Comments
 (0)