Skip to content

Commit f6d160a

Browse files
Fix in code copyright statement and add docstrings to async_cache.
* check_pre_commit_config_frozen.py
1 parent 6557a3e commit f6d160a

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

check_pre_commit_config_frozen.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,32 @@
6363

6464

6565
class async_cache:
66+
"""
67+
A wrapper for caching coroutines.
68+
69+
Parameters
70+
----------
71+
cache_dict : dict
72+
the dictionary to use for caching.
73+
Provide this to use the same cache for multiple wrappers.
74+
75+
Examples
76+
--------
77+
>>> @async_cache()
78+
... async def calc():
79+
... return 8
80+
81+
"""
82+
6683
def __init__(self, cache_dict=None):
84+
"""Init."""
6785
self._dict = cache_dict or {}
6886

6987
def __call__(
7088
self, func: Callable[..., Coroutine[None, None, T]]
7189
) -> Callable[..., Coroutine[None, None, T]]:
90+
"""Wrap a function and return it."""
91+
7292
@wraps(func)
7393
async def get(*args, **kwargs):
7494
key = (args, tuple(map(tuple, kwargs.items())))
@@ -84,12 +104,11 @@ async def get(*args, **kwargs):
84104

85105
# -- Git ---------------------------------------------------------------------
86106

87-
# The git commands in this section is partially sourced and modified from
107+
# Fragments of the following git logic are sourced from
88108
# https://github.com/pre-commit/pre-commit/blob/main/pre_commit/git.py
89-
# https://github.com/pre-commit/pre-commit/blob/main/pre_commit/util.py
90109
#
91110
# Original Copyright (c) 2014 pre-commit dev team: Anthony Sottile, Ken Struys
92-
111+
# MIT License
93112

94113
# prevents errors on windows
95114
NO_FS_MONITOR = ("-c", "core.useBuiltinFSMonitor=false")

0 commit comments

Comments
 (0)