Skip to content

Commit

Permalink
MAINT: move cached_property backport to compat module
Browse files Browse the repository at this point in the history
Signed-off-by: Filipe Laíns <[email protected]>
  • Loading branch information
FFY00 committed Nov 28, 2022
1 parent eb40d61 commit d098706
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 2 additions & 7 deletions mesonpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,15 @@
import mesonpy._wheelfile

from mesonpy._compat import (
Collection, Iterator, Literal, Mapping, Path, typing_get_args
Collection, Iterator, Literal, Mapping, Path, cached_property,
typing_get_args
)


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


if sys.version_info >= (3, 8):
from functools import cached_property
else:
cached_property = lambda x: property(functools.lru_cache(maxsize=None)(x)) # noqa: E731


__version__ = '0.11.0'


Expand Down
8 changes: 8 additions & 0 deletions mesonpy/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-FileCopyrightText: 2021 Quansight, LLC
# SPDX-FileCopyrightText: 2021 Filipe Laíns <[email protected]>

import functools
import os
import pathlib
import sys
Expand All @@ -25,6 +26,12 @@
from typing_extensions import get_args as typing_get_args


if sys.version_info >= (3, 8):
from functools import cached_property
else:
cached_property = lambda x: property(functools.lru_cache(maxsize=None)(x)) # noqa: E731


Path = Union[str, os.PathLike]


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


__all__ = [
'cached_property',
'is_relative_to',
'typing_get_args',
'Collection',
Expand Down

0 comments on commit d098706

Please sign in to comment.