Skip to content

Commit 2451152

Browse files
committed
✨ add add unpublished modules to caching
1 parent dedf749 commit 2451152

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

nb_cli/handlers/store.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,20 @@ async def dump_unpublished_modules(module_class: type[T], newer: list[T]) -> Non
7474
)
7575

7676

77-
async def load_unpublished_modules(module_class: type[T]) -> list[T]:
78-
module_name: str = module_class.__module_name__
77+
if TYPE_CHECKING:
7978

80-
if (path_historical := CACHE_DIR / f"{module_name}_unpublished.json").is_file():
81-
async with await anyio.open_file(path_historical) as fhistorical:
82-
return type_validate_json(list[module_class], await fhistorical.read())
83-
return []
79+
async def load_unpublished_modules(module_class: type[T]) -> list[T]: ...
80+
81+
else:
82+
83+
@cache(ttl=None)
84+
async def load_unpublished_modules(module_class: type[T]) -> list[T]:
85+
module_name: str = module_class.__module_name__
86+
87+
if (path_historical := CACHE_DIR / f"{module_name}_unpublished.json").is_file():
88+
async with await anyio.open_file(path_historical) as fhistorical:
89+
return type_validate_json(list[module_class], await fhistorical.read())
90+
return []
8491

8592

8693
if TYPE_CHECKING:

0 commit comments

Comments
 (0)