Skip to content

Commit b9a13f8

Browse files
committed
MAINT: move cached_property backport to compat module
Signed-off-by: Filipe Laíns <[email protected]>
1 parent 47363b5 commit b9a13f8

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

mesonpy/__init__.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,15 @@
4949
import mesonpy._wheelfile
5050

5151
from mesonpy._compat import (
52-
Collection, Iterator, Literal, Mapping, Path, typing_get_args
52+
Collection, Iterator, Literal, Mapping, Path, cached_property,
53+
typing_get_args
5354
)
5455

5556

5657
if typing.TYPE_CHECKING: # pragma: no cover
5758
import pyproject_metadata # noqa: F401
5859

5960

60-
if sys.version_info >= (3, 8):
61-
from functools import cached_property
62-
else:
63-
cached_property = lambda x: property(functools.lru_cache(maxsize=None)(x)) # noqa: E731
64-
65-
6661
__version__ = '0.11.0'
6762

6863

mesonpy/_compat.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# SPDX-FileCopyrightText: 2021 Quansight, LLC
33
# SPDX-FileCopyrightText: 2021 Filipe Laíns <[email protected]>
44

5+
import functools
56
import os
67
import pathlib
78
import sys
@@ -25,6 +26,12 @@
2526
from typing_extensions import get_args as typing_get_args
2627

2728

29+
if sys.version_info >= (3, 8):
30+
from functools import cached_property
31+
else:
32+
cached_property = lambda x: property(functools.lru_cache(maxsize=None)(x)) # noqa: E731
33+
34+
2835
Path = Union[str, os.PathLike]
2936

3037

@@ -38,6 +45,7 @@ def is_relative_to(path: pathlib.Path, other: Union[pathlib.Path, str]) -> bool:
3845

3946

4047
__all__ = [
48+
'cached_property',
4149
'is_relative_to',
4250
'typing_get_args',
4351
'Collection',

0 commit comments

Comments
 (0)