From 9e295e51b040aa074b614412f653f0acda97a19e Mon Sep 17 00:00:00 2001 From: Pulux Date: Sun, 12 Jun 2022 06:15:54 +0200 Subject: [PATCH] python3-cached-property: update to 1.5.2. --- .../patches/p267.patch | 101 ++++++++++++++++++ srcpkgs/python3-cached-property/template | 9 +- 2 files changed, 106 insertions(+), 4 deletions(-) create mode 100644 srcpkgs/python3-cached-property/patches/p267.patch diff --git a/srcpkgs/python3-cached-property/patches/p267.patch b/srcpkgs/python3-cached-property/patches/p267.patch new file mode 100644 index 000000000000..0f4afe2765cc --- /dev/null +++ b/srcpkgs/python3-cached-property/patches/p267.patch @@ -0,0 +1,101 @@ +diff --git a/cached_property.py b/cached_property.py +index 3135871..182d164 100644 +--- a/cached_property.py ++++ b/cached_property.py +@@ -13,6 +13,8 @@ try: + import asyncio + except (ImportError, SyntaxError): + asyncio = None ++if asyncio: ++ from inspect import iscoroutinefunction + + + class cached_property(object): +@@ -30,22 +32,14 @@ class cached_property(object): + if obj is None: + return self + +- if asyncio and asyncio.iscoroutinefunction(self.func): +- return self._wrap_in_coroutine(obj) ++ if asyncio and iscoroutinefunction(self.func): ++ value = asyncio.ensure_future(self.func(obj)) ++ else: ++ value = self.func(obj) + +- value = obj.__dict__[self.func.__name__] = self.func(obj) ++ obj.__dict__[self.func.__name__] = value + return value + +- def _wrap_in_coroutine(self, obj): +- @wraps(obj) +- @asyncio.coroutine +- def wrapper(): +- future = asyncio.ensure_future(self.func(obj)) +- obj.__dict__[self.func.__name__] = future +- return future +- +- return wrapper() +- + + class threaded_cached_property(object): + """ +diff --git a/conftest.py b/conftest.py +index 0563f64..1141424 100644 +--- a/conftest.py ++++ b/conftest.py +@@ -7,13 +7,17 @@ has_asyncio = sys.version_info[0] == 3 and sys.version_info[1] >= 4 + # Whether the async and await keywords work + has_async_await = sys.version_info[0] == 3 and sys.version_info[1] >= 5 + ++# Whether "from asyncio import coroutine" *fails* ++version_info = sys.version_info ++dropped_asyncio_coroutine = version_info[0] == 3 and version_info[1] >= 10 ++ + + print("conftest.py", has_asyncio, has_async_await) + + + collect_ignore = [] + +-if not has_asyncio: ++if not has_asyncio or dropped_asyncio_coroutine: + collect_ignore.append("tests/test_coroutine_cached_property.py") + + if not has_async_await: +diff --git a/tests/test_async_cached_property.py b/tests/test_async_cached_property.py +index 4ba84f3..d4157e1 100644 +--- a/tests/test_async_cached_property.py ++++ b/tests/test_async_cached_property.py +@@ -9,9 +9,8 @@ import cached_property + + def unittest_run_loop(f): + def wrapper(*args, **kwargs): +- coro = asyncio.coroutine(f) +- future = coro(*args, **kwargs) +- loop = asyncio.get_event_loop() ++ future = f(*args, **kwargs) ++ loop = asyncio.new_event_loop() + loop.run_until_complete(future) + + return wrapper +diff --git a/tests/test_cached_property.py b/tests/test_cached_property.py +index 5082416..8ac6e48 100644 +--- a/tests/test_cached_property.py ++++ b/tests/test_cached_property.py +@@ -201,12 +201,12 @@ class TestCachedPropertyWithTTL(TestCachedProperty): + # The cache expires in the future + with freeze_time("9999-01-01"): + check.run_threads(num_threads) +- self.assert_cached(check, 2 * num_threads) +- self.assert_cached(check, 2 * num_threads) ++ self.assert_cached(check, num_threads + 1) ++ # self.assert_cached(check, 2 * num_threads) + + # Things are not reverted when we are back to the present +- self.assert_cached(check, 2 * num_threads) +- self.assert_cached(check, 2 * num_threads) ++ self.assert_cached(check, num_threads + 1) ++ # self.assert_cached(check, 2 * num_threads) + + + class TestThreadedCachedPropertyWithTTL( diff --git a/srcpkgs/python3-cached-property/template b/srcpkgs/python3-cached-property/template index 7d088f3cd023..504488a6daeb 100644 --- a/srcpkgs/python3-cached-property/template +++ b/srcpkgs/python3-cached-property/template @@ -1,17 +1,18 @@ # Template file for 'python3-cached-property' pkgname=python3-cached-property -version=1.5.1 -revision=5 +version=1.5.2 +revision=1 wrksrc="cached-property-${version}" build_style=python3-module hostmakedepends="python3-setuptools" depends="python3" +checkdepends="python3-pytest $depends python3-freezegun python3-pytest-cov python3-coverage" short_desc="Decorator for caching properties in classes (Python3)" -maintainer="Orphaned " +maintainer="Pulux " license="BSD-3-Clause" homepage="https://github.com/pydanny/cached-property" distfiles="${PYPI_SITE}/c/cached-property/cached-property-${version}.tar.gz" -checksum=9217a59f14a5682da7c4b8829deadbfc194ac22e9908ccf7c8820234e80a1504 +checksum=9fa5755838eecbb2d234c3aa390bd80fbd3ac6b6869109bfc1b499f7bd89a130 post_install() { vlicense LICENSE