Skip to content

Commit

Permalink
you should actually implement the thing you claimed to
Browse files Browse the repository at this point in the history
  • Loading branch information
tybug committed Feb 11, 2025
1 parent 8e76016 commit b1df522
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions hypothesis-python/src/hypothesis/internal/escalation.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,21 @@ def belongs_to(package: ModuleType) -> Callable[[str], bool]:
return lambda filepath: False

assert package.__file__ is not None
FILE_CACHE[package] = {}
FILE_CACHE[package].setdefault({})
cache = FILE_CACHE[package]
root = Path(package.__file__).resolve().parent

def accept(filepath: str) -> bool:
try:
return FILE_CACHE[package][filepath]
return cache[filepath]
except KeyError:
pass
try:
Path(filepath).resolve().relative_to(root)
result = True
except Exception:
result = False
FILE_CACHE[package][filepath] = result
cache[filepath] = result
return result

accept.__name__ = f"is_{package.__name__}_file"
Expand Down

0 comments on commit b1df522

Please sign in to comment.