Skip to content

Commit 24f9f0a

Browse files
committed
a few more imminent typings for hypofuzz
1 parent 4644a42 commit 24f9f0a

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

hypothesis-python/src/hypothesis/control.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from collections import defaultdict
1515
from collections.abc import Sequence
1616
from contextlib import contextmanager
17-
from typing import Any, NoReturn, Optional, Union
17+
from typing import Any, Callable, NoReturn, Optional, Union
1818
from weakref import WeakKeyDictionary
1919

2020
from hypothesis import Verbosity, settings
@@ -127,10 +127,15 @@ def deprecate_random_in_strategy(fmt, *args):
127127

128128

129129
class BuildContext:
130-
def __init__(self, data, *, is_final=False, close_on_capture=True):
131-
assert isinstance(data, ConjectureData)
130+
def __init__(
131+
self,
132+
data: ConjectureData,
133+
*,
134+
is_final: bool = False,
135+
close_on_capture: bool = True,
136+
) -> None:
132137
self.data = data
133-
self.tasks = []
138+
self.tasks: list[Callable[[], Any]] = []
134139
self.is_final = is_final
135140
self.close_on_capture = close_on_capture
136141
self.close_on_del = False

hypothesis-python/src/hypothesis/internal/escalation.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,24 @@
1616
from functools import partial
1717
from inspect import getframeinfo
1818
from pathlib import Path
19-
from typing import NamedTuple, Optional
19+
from types import ModuleType
20+
from typing import Callable, NamedTuple, Optional
2021

2122
import hypothesis
2223
from hypothesis.errors import _Trimmable
2324
from hypothesis.internal.compat import BaseExceptionGroup
2425
from hypothesis.utils.dynamicvariables import DynamicVariable
2526

2627

27-
def belongs_to(package):
28-
if not hasattr(package, "__file__"): # pragma: no cover
28+
def belongs_to(package: ModuleType) -> Callable[[str], bool]:
29+
if getattr(package, "__file__", None) is None: # pragma: no cover
2930
return lambda filepath: False
3031

32+
assert package.__file__ is not None
3133
root = Path(package.__file__).resolve().parent
32-
cache = {str: {}, bytes: {}}
34+
cache: dict[type, dict[str, bool]] = {str: {}, bytes: {}}
3335

34-
def accept(filepath):
36+
def accept(filepath: str) -> bool:
3537
ftype = type(filepath)
3638
try:
3739
return cache[ftype][filepath]

0 commit comments

Comments
 (0)