Skip to content

Commit 9157aa8

Browse files
authored
Require Python 3.11 and bump hdx-python-country and hdx-python-utilities minimums (#127)
* Require Python 3.11 and bump hdx-python-country and hdx-python-utilities minimums - requires-python >=3.11, drop 3.10 classifier, ruff target py311 - hdx-python-country>=4.2.6, hdx-python-utilities>=4.2.5 - Apply ruff UP017 fixes (timezone.utc -> UTC) - Upgrade uv.lock * Update doc
1 parent 91e42b3 commit 9157aa8

9 files changed

Lines changed: 89 additions & 785 deletions

File tree

‎CLAUDE.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Formatted and linted with `ruff` (rules: E, F, I, UP; line-length not enforced).
3333
pre-commit run --all-files
3434
```
3535

36-
- Python ≥ 3.10
36+
- Python ≥ 3.11
3737
- Type hints throughout; use `X | Y` union syntax (PEP 604), not `Optional`/`Union`
3838
- Google-style docstrings with `Args:` and `Returns:` sections
3939
- No inline comments unless the *why* is non-obvious

‎documentation/reference/changelog.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Breaking Changes
2+
From 6.7.7, Python 3.11 or later is required
23

34
From 6.6.5, removed DatasetTitleHelper class and Dataset method remove_dates_from_title
45

‎pyproject.toml‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ classifiers = [
1818
"Programming Language :: Python",
1919
"Programming Language :: Python :: 3",
2020
"Programming Language :: Python :: 3 :: Only",
21-
"Programming Language :: Python :: 3.10",
2221
"Programming Language :: Python :: 3.11",
2322
"Programming Language :: Python :: 3.12",
2423
"Programming Language :: Python :: 3.13",
@@ -33,14 +32,14 @@ classifiers = [
3332
]
3433
readme = "README.md"
3534
dynamic = ["version"]
36-
requires-python = ">=3.10"
35+
requires-python = ">=3.11"
3736

3837
dependencies = [
3938
"ckanapi>=4.11",
4039
"defopt>=7.0.0",
4140
"email_validator",
42-
"hdx-python-country>=4.2.5",
43-
"hdx-python-utilities>=4.2.4",
41+
"hdx-python-country>=4.2.6",
42+
"hdx-python-utilities>=4.2.5",
4443
"makefun",
4544
"requests",
4645
]
@@ -87,7 +86,7 @@ allow-direct-references = true
8786
# ----------------------------------------------------------------------------
8887

8988
[tool.ruff]
90-
target-version = "py310"
89+
target-version = "py311"
9190
src = ["src"]
9291
exclude = ["_version.py"]
9392

‎src/hdx/api/utilities/date_helper.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Helper to the Dataset and Resource classes for handling HDX dates."""
22

33
from collections.abc import Iterable
4-
from datetime import datetime, timezone
4+
from datetime import UTC, datetime
55

66
from hdx.utilities.dateparse import now_utc, parse_date
77

@@ -52,7 +52,7 @@ def get_hdx_date(
5252
microsecond=0,
5353
)
5454
else:
55-
date = date.astimezone(timezone.utc)
55+
date = date.astimezone(UTC)
5656
if include_microseconds:
5757
timespec = "microseconds"
5858
else:
@@ -92,7 +92,7 @@ def get_time_period_info(
9292
hour=23,
9393
minute=59,
9494
second=59,
95-
tzinfo=timezone.utc,
95+
tzinfo=UTC,
9696
)
9797
ongoing = True
9898
else:
@@ -179,8 +179,8 @@ def get_hdx_time_period_from_years(
179179
retval = sorted(int(x) for x in list(startyear))
180180
startyear = retval[0]
181181
endyear = retval[-1]
182-
startdate = datetime(startyear, 1, 1, tzinfo=timezone.utc)
183-
enddate = datetime(endyear, 12, 31, 23, 59, 59, tzinfo=timezone.utc)
182+
startdate = datetime(startyear, 1, 1, tzinfo=UTC)
183+
enddate = datetime(endyear, 12, 31, 23, 59, 59, tzinfo=UTC)
184184
return (
185185
cls.get_hdx_time_period(startdate, enddate, ignore_timeinfo=False),
186186
retval,

‎tests/hdx/api/utilities/test_hdx_state.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import json
44
from copy import deepcopy
5-
from datetime import datetime, timezone
5+
from datetime import UTC, datetime
66
from os import makedirs
77
from os.path import exists
88
from pathlib import Path
@@ -37,11 +37,11 @@ def multidatestatefile(self):
3737

3838
@pytest.fixture(scope="class")
3939
def date1(self):
40-
return datetime(2020, 9, 23, 0, 0, tzinfo=timezone.utc)
40+
return datetime(2020, 9, 23, 0, 0, tzinfo=UTC)
4141

4242
@pytest.fixture(scope="class")
4343
def date2(self):
44-
return datetime(2022, 5, 12, 10, 15, tzinfo=timezone.utc)
44+
return datetime(2022, 5, 12, 10, 15, tzinfo=UTC)
4545

4646
@pytest.fixture(scope="function")
4747
def do_state(self, tempfolder, statefile):

‎tests/hdx/data/test_dataset_noncore.py‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import copy
44
import json
5-
from datetime import datetime, timezone
5+
from datetime import UTC, datetime
66

77
import pytest
88
from hdx.location.country import Country
@@ -348,35 +348,35 @@ def test_get_set_date_of_dataset(self, configuration):
348348
dataset = Dataset({"dataset_date": "[2020-01-07T00:00:00 TO *]"})
349349
result = dataset.get_time_period(today=datetime(2020, 11, 17))
350350
assert result == {
351-
"startdate": datetime(2020, 1, 7, 0, 0, tzinfo=timezone.utc),
352-
"enddate": datetime(2020, 11, 17, 23, 59, 59, tzinfo=timezone.utc),
351+
"startdate": datetime(2020, 1, 7, 0, 0, tzinfo=UTC),
352+
"enddate": datetime(2020, 11, 17, 23, 59, 59, tzinfo=UTC),
353353
"startdate_str": "2020-01-07T00:00:00+00:00",
354354
"enddate_str": "2020-11-17T23:59:59+00:00",
355355
"ongoing": True,
356356
}
357357
dataset.set_time_period("2020-02-09")
358358
result = dataset.get_time_period("%d/%m/%Y")
359359
assert result == {
360-
"startdate": datetime(2020, 2, 9, 0, 0, tzinfo=timezone.utc),
361-
"enddate": datetime(2020, 2, 9, 23, 59, 59, tzinfo=timezone.utc),
360+
"startdate": datetime(2020, 2, 9, 0, 0, tzinfo=UTC),
361+
"enddate": datetime(2020, 2, 9, 23, 59, 59, tzinfo=UTC),
362362
"startdate_str": "09/02/2020",
363363
"enddate_str": "09/02/2020",
364364
"ongoing": False,
365365
}
366366
dataset.set_time_period("2020-02-09", "2020-10-20")
367367
result = dataset.get_time_period("%d/%m/%Y")
368368
assert result == {
369-
"startdate": datetime(2020, 2, 9, 0, 0, tzinfo=timezone.utc),
370-
"enddate": datetime(2020, 10, 20, 23, 59, 59, tzinfo=timezone.utc),
369+
"startdate": datetime(2020, 2, 9, 0, 0, tzinfo=UTC),
370+
"enddate": datetime(2020, 10, 20, 23, 59, 59, tzinfo=UTC),
371371
"startdate_str": "09/02/2020",
372372
"enddate_str": "20/10/2020",
373373
"ongoing": False,
374374
}
375375
dataset.set_time_period("2020-02-09", ongoing=True)
376376
result = dataset.get_time_period("%d/%m/%Y", today=datetime(2020, 3, 9, 0, 0))
377377
assert result == {
378-
"startdate": datetime(2020, 2, 9, 0, 0, tzinfo=timezone.utc),
379-
"enddate": datetime(2020, 3, 9, 23, 59, 59, tzinfo=timezone.utc),
378+
"startdate": datetime(2020, 2, 9, 0, 0, tzinfo=UTC),
379+
"enddate": datetime(2020, 3, 9, 23, 59, 59, tzinfo=UTC),
380380
"startdate_str": "09/02/2020",
381381
"enddate_str": "09/03/2020",
382382
"ongoing": True,

‎tests/hdx/data/test_dataset_resource_generation.py‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Dataset Tests (noncore methods)"""
22

3-
from datetime import datetime, timezone
3+
from datetime import UTC, datetime
44

55
import pytest
66
from hdx.utilities.compare import assert_files_same
@@ -73,8 +73,8 @@ def process_row(headers, row):
7373
]
7474
assert success is True
7575
assert results == {
76-
"startdate": datetime(2001, 1, 1, 0, 0, tzinfo=timezone.utc),
77-
"enddate": datetime(2002, 12, 31, 23, 59, 59, tzinfo=timezone.utc),
76+
"startdate": datetime(2001, 1, 1, 0, 0, tzinfo=UTC),
77+
"enddate": datetime(2002, 12, 31, 23, 59, 59, tzinfo=UTC),
7878
"resource": {
7979
"description": "Conflict data",
8080
"format": "csv",
@@ -289,8 +289,8 @@ def process_row(headers, row):
289289
)
290290
assert success is True
291291
assert results == {
292-
"startdate": datetime(2001, 1, 1, 0, 0, tzinfo=timezone.utc),
293-
"enddate": datetime(2002, 12, 31, 23, 59, 59, tzinfo=timezone.utc),
292+
"startdate": datetime(2001, 1, 1, 0, 0, tzinfo=UTC),
293+
"enddate": datetime(2002, 12, 31, 23, 59, 59, tzinfo=UTC),
294294
"resource": {
295295
"description": "Conflict data",
296296
"format": "csv",
@@ -433,11 +433,9 @@ def process_year(row):
433433
date_function=process_year,
434434
)
435435
assert success is True
436-
assert results["startdate"] == datetime(
437-
2001, 1, 1, 0, 0, tzinfo=timezone.utc
438-
)
436+
assert results["startdate"] == datetime(2001, 1, 1, 0, 0, tzinfo=UTC)
439437
assert results["enddate"] == datetime(
440-
2001, 12, 31, 23, 59, 59, tzinfo=timezone.utc
438+
2001, 12, 31, 23, 59, 59, tzinfo=UTC
441439
)
442440
assert (
443441
dataset["dataset_date"]

‎tests/hdx/data/test_resource.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import json
55
import logging
66
import os
7-
from datetime import datetime, timezone
7+
from datetime import UTC, datetime
88
from os import remove
99
from os.path import basename
1010
from pathlib import Path
@@ -912,17 +912,17 @@ def test_get_set_date_of_resource(self, configuration):
912912
resource = Resource({"daterange_for_data": "[2020-01-07T00:00:00 TO *]"})
913913
result = resource.get_date_of_resource(today=datetime(2020, 11, 17))
914914
assert result == {
915-
"startdate": datetime(2020, 1, 7, 0, 0, tzinfo=timezone.utc),
916-
"enddate": datetime(2020, 11, 17, 23, 59, 59, tzinfo=timezone.utc),
915+
"startdate": datetime(2020, 1, 7, 0, 0, tzinfo=UTC),
916+
"enddate": datetime(2020, 11, 17, 23, 59, 59, tzinfo=UTC),
917917
"startdate_str": "2020-01-07T00:00:00+00:00",
918918
"enddate_str": "2020-11-17T23:59:59+00:00",
919919
"ongoing": True,
920920
}
921921
resource.set_date_of_resource("2020-02-09", "2020-10-20")
922922
result = resource.get_date_of_resource("%d/%m/%Y")
923923
assert result == {
924-
"startdate": datetime(2020, 2, 9, 0, 0, tzinfo=timezone.utc),
925-
"enddate": datetime(2020, 10, 20, 23, 59, 59, tzinfo=timezone.utc),
924+
"startdate": datetime(2020, 2, 9, 0, 0, tzinfo=UTC),
925+
"enddate": datetime(2020, 10, 20, 23, 59, 59, tzinfo=UTC),
926926
"startdate_str": "09/02/2020",
927927
"enddate_str": "20/10/2020",
928928
"ongoing": False,

0 commit comments

Comments
 (0)