Skip to content

Commit b3abc64

Browse files
mcrotkclaude
andcommitted
Add docstrings to CacheControls' remaining members and a few internals
cache_key, cache_lock and cache_condition (shown in editors through cache_controls), the passthrough view's maxsize and currsize, InstallsCopyMethods.__set_name__, and a comment on why PassthroughKey saves its hash. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 0762cd2 commit b3abc64

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

‎src/mcrotk_cache_utils/_copying/copy_handling.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class InstallsCopyMethods:
6363
"""Mixin for ``cached_method``'s descriptor: copy handling for the class, set up when the class is created."""
6464

6565
def __set_name__(self, owner: type, name: str) -> None:
66+
"""Check ``on_copy`` against the class's own copy methods, and install ours unless it's ``"manual"``."""
6667
super().__set_name__(owner, name) # pyright: ignore[reportAttributeAccessIssue] (cachetools' descriptor)
6768
on_copy, explicit = getattr(self, ON_COPY)
6869
theirs = user_copy_methods(owner)

‎src/mcrotk_cache_utils/_decorators/cache_controls.py‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,20 @@ def cache(self) -> Any:
2424
...
2525

2626
@property
27-
def cache_key(self) -> Callable[..., Any]: ...
27+
def cache_key(self) -> Callable[..., Any]:
28+
"""The function that makes the cache keys from a call's arguments."""
29+
...
30+
2831
@property
29-
def cache_lock(self) -> Any: ...
32+
def cache_lock(self) -> Any:
33+
"""The lock, if one was given."""
34+
...
35+
3036
@property
31-
def cache_condition(self) -> Any: ...
37+
def cache_condition(self) -> Any:
38+
"""The condition, if one was given."""
39+
...
40+
3241
def cache_clear(self) -> None:
3342
"""Empty the cache (and reset the ``info`` counters)."""
3443
...

‎src/mcrotk_cache_utils/_keys/passthrough.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ def __new__(cls, parts: Iterable[Any], passthrough: dict[int, tuple[Any, Callabl
2323
return key
2424

2525
def __hash__(self) -> int:
26+
# Saved after the first time: a call hashes its key at least twice (make_key's check that
27+
# it's hashable, then the cache lookup), and hashing walks every part of the key.
2628
try:
2729
return self._hash
2830
except AttributeError:
@@ -137,10 +139,12 @@ class PassthroughCacheView(PassthroughView, cachetools.Cache[Any, Any]):
137139

138140
@property
139141
def maxsize(self) -> Any:
142+
"""The real cache's ``maxsize``, for ``cache_info``."""
140143
return self._cache.maxsize # pyright: ignore[reportAttributeAccessIssue]
141144

142145
@property
143146
def currsize(self) -> Any:
147+
"""The real cache's ``currsize``, for ``cache_info``."""
144148
return self._cache.currsize # pyright: ignore[reportAttributeAccessIssue]
145149

146150
# A method, not a staticmethod as in Cache, since it delegates to the real cache (Cache

0 commit comments

Comments
 (0)