Skip to content

Commit e2aca2d

Browse files
pre-commit-ci[bot]shaypal5
authored andcommitted
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 418f052 commit e2aca2d

2 files changed

Lines changed: 21 additions & 15 deletions

File tree

src/cachier/core.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from collections import OrderedDict
1414
from concurrent.futures import ThreadPoolExecutor
1515
from datetime import datetime, timedelta
16-
from functools import wraps, partial
16+
from functools import partial, wraps
1717
from typing import Any, Optional, Union
1818
from warnings import warn
1919

@@ -321,15 +321,17 @@ def _precache_value(*args, value_to_cache, **kwds): # noqa: D417
321321
func, _is_method=core.func_is_method, args=args, kwds=kwds
322322
)
323323
return core.precache_value((), kwargs, value_to_cache)
324-
324+
325325
def _caller_with_freshness_threshold(max_age: timedelta):
326326
return wraps(func)(partial(_call, max_age))
327-
327+
328328
func_wrapper.clear_cache = _clear_cache
329329
func_wrapper.clear_being_calculated = _clear_being_calculated
330330
func_wrapper.cache_dpath = _cache_dpath
331331
func_wrapper.precache_value = _precache_value
332-
func_wrapper.caller_with_freshness_threshold = _caller_with_freshness_threshold
332+
func_wrapper.caller_with_freshness_threshold = (
333+
_caller_with_freshness_threshold
334+
)
333335
return func_wrapper
334336

335337
return _cachier_decorator

tests/test_call_with_freshness_threshold.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,25 @@
33

44
import cachier
55

6+
67
def test_call_with_freshness_threshold():
78
@cachier.cachier()
89
def test_func(a, b):
9-
print('Computing...')
10+
print("Computing...")
1011
return a + b
11-
12-
print(f'{test_func(1, 2) = }')
13-
print(f'{test_func(1, 2) = }')
14-
caller_with_freshness_threshold = test_func.caller_with_freshness_threshold(
15-
timedelta(seconds=0.5),
12+
13+
print(f"{test_func(1, 2) = }")
14+
print(f"{test_func(1, 2) = }")
15+
caller_with_freshness_threshold = (
16+
test_func.caller_with_freshness_threshold(
17+
timedelta(seconds=0.5),
18+
)
1619
)
17-
print(f'{caller_with_freshness_threshold(1, 2) = }')
18-
print(f'{time.sleep(1.0) = }')
19-
print(f'{test_func(1, 2) = }')
20-
print(f'{caller_with_freshness_threshold(1, 2) = }')
20+
print(f"{caller_with_freshness_threshold(1, 2) = }")
21+
print(f"{time.sleep(1.0) = }")
22+
print(f"{test_func(1, 2) = }")
23+
print(f"{caller_with_freshness_threshold(1, 2) = }")
24+
2125

22-
if __name__ == '__main__':
26+
if __name__ == "__main__":
2327
test_call_with_freshness_threshold()

0 commit comments

Comments
 (0)