manager: warn if we can't determine the source file of a function
- ID
22f5874- date
2026-11-06 22:40:02+00:00- author
Alex Chan <alexc@tailscale.com>- parent
954bbfb- message
manager: warn if we can't determine the source file of a function- changed files
2 files, 7 additions, 1 deletion
Changed files
src/funkycache/manager.py (10189 → 10346)
diff --git a/src/funkycache/manager.py b/src/funkycache/manager.py
index c4570fc..acf015c 100644
--- a/src/funkycache/manager.py
+++ b/src/funkycache/manager.py
@@ -276,6 +276,11 @@ def _dep_paths(func: F, files: list[Path]) -> set[Path]:
# 1. Include the source file of the function.
if func_file := inspect.getsourcefile(func):
dep_paths.append(Path(func_file))
+ else:
+ warnings.warn(
+ f"unable to determine source file for {func}; "
+ "caches may not be invalidated correctly"
+ )
# 2. Include any explicitly declared files.
if files:
tests/test_manager.py (13569 → 13658)
diff --git a/tests/test_manager.py b/tests/test_manager.py
index 5492263..9b73f20 100644
--- a/tests/test_manager.py
+++ b/tests/test_manager.py
@@ -257,7 +257,8 @@ class FunkyCacheTestSuite(ABC):
assert inspect.getsourcefile(double) is None
- cache.register(double)
+ with pytest.warns(UserWarning, match="unable to determine source file for"):
+ cache.register(double)
def test_function_cannot_depend_on_symlink(
self, cache: FunkyCache, tmp_path: Path