Skip to content

Commit adfd9ca

Browse files
committed
Replace custom cached_property with stdlib
Since Python 3.8 there's functools.cached_property, which works the same way, but also passes type information through.
1 parent 082f10b commit adfd9ca

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

datacube/drivers/postgis/_fields.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from collections.abc import Callable
1212
from datetime import date, datetime, timezone
1313
from decimal import Decimal
14+
from functools import cached_property
1415
from typing import Any, TypeAlias
1516

1617
from sqlalchemy import and_, cast, func
@@ -26,7 +27,7 @@
2627
from datacube.drivers.postgis._schema import Dataset, search_field_index_map
2728
from datacube.model import Range
2829
from datacube.model.fields import Expression, Field
29-
from datacube.utils import cached_property, get_doc_offset
30+
from datacube.utils import get_doc_offset
3031
from datacube.utils.dates import tz_as_utc
3132

3233
DatasetJoinArgs = tuple[FromClause] | tuple[FromClause, ColumnExpressionArgument]

datacube/index/abstract/_index.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import logging
66
from abc import ABC, abstractmethod
77
from collections.abc import Iterable, Mapping, Sequence
8+
from functools import cached_property
89
from urllib.parse import ParseResult, urlparse
910

1011
from deprecat import deprecat
@@ -13,7 +14,7 @@
1314
from datacube.cfg import ODCEnvironment, ODCOptionHandler
1415
from datacube.migration import ODC2DeprecationWarning
1516
from datacube.model import Field, MetadataType
16-
from datacube.utils import cached_property, report_to_user
17+
from datacube.utils import report_to_user
1718
from datacube.utils.generic import thread_local_cache
1819

1920
from ._datasets import AbstractDatasetResource

datacube/index/abstract/_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
# Copyright (c) 2015-2025 ODC Contributors
44
# SPDX-License-Identifier: Apache-2.0
55
from collections.abc import Iterable, Sequence
6+
from functools import cached_property
67
from typing import NamedTuple
78
from uuid import UUID
89

910
from deprecat import deprecat
1011

1112
from datacube.migration import ODC2DeprecationWarning
1213
from datacube.model import Dataset, Product
13-
from datacube.utils import cached_property
1414
from datacube.utils.documents import JsonDict
1515

1616

datacube/model/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from collections import OrderedDict
1414
from collections.abc import Generator, Iterable, Iterator, Mapping, Sequence
1515
from datetime import datetime
16+
from functools import cached_property
1617
from pathlib import Path
1718
from typing import Any
1819
from urllib.parse import urlparse
@@ -23,7 +24,6 @@
2324

2425
from datacube.utils import (
2526
DocReader,
26-
cached_property,
2727
parse_time,
2828
schema_validated,
2929
uri_to_local_path,

datacube/utils/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
unsqueeze_data_array,
3131
unsqueeze_dataset,
3232
)
33-
from .py import cached_property, ignore_exceptions_if, import_function
33+
from .py import ignore_exceptions_if, import_function
3434
from .serialise import jsonify_document
3535
from .uris import get_part_from_uri, is_url, is_vsipath, mk_part_uri, uri_to_local_path
3636

@@ -41,7 +41,6 @@
4141
"NoDatesSafeLoader",
4242
"SimpleDocNav",
4343
"_readable_offset",
44-
"cached_property",
4544
"check_write_path",
4645
"gen_password",
4746
"get_doc_offset",

0 commit comments

Comments
 (0)