Skip to content

Commit db28d3a

Browse files
committed
more typing
1 parent 7cb0989 commit db28d3a

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

hypothesis-python/src/hypothesis/core.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
TypeVar,
3636
Union,
3737
overload,
38+
Iterable,
3839
)
3940
from unittest import TestCase
4041

@@ -321,7 +322,7 @@ def accept(test):
321322
return accept
322323

323324

324-
def encode_failure(choices):
325+
def encode_failure(choices: Iterable[ChoiceT]) -> bytes:
325326
blob = choices_to_bytes(choices)
326327
compressed = zlib.compress(blob)
327328
if len(compressed) < len(blob):
@@ -687,7 +688,7 @@ def skip_exceptions_to_reraise():
687688
return tuple(sorted(exceptions, key=str))
688689

689690

690-
def failure_exceptions_to_catch():
691+
def failure_exceptions_to_catch() -> tuple[type[BaseException], ...]:
691692
"""Return a tuple of exceptions meaning 'this test has failed', to catch.
692693
693694
This is intended to cover most common test runners; if you would

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

+6-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from functools import partial
1717
from inspect import getframeinfo
1818
from pathlib import Path
19-
from types import ModuleType
19+
from types import ModuleType, TracebackType
2020
from typing import Callable, NamedTuple, Optional
2121

2222
import hypothesis
@@ -57,7 +57,9 @@ def accept(filepath: str) -> bool:
5757
is_hypothesis_file = belongs_to(hypothesis)
5858

5959

60-
def get_trimmed_traceback(exception=None):
60+
def get_trimmed_traceback(
61+
exception: Optional[BaseException] = None,
62+
) -> Optional[TracebackType]:
6163
"""Return the current traceback, minus any frames added by Hypothesis."""
6264
if exception is None:
6365
_, exception, tb = sys.exc_info()
@@ -67,9 +69,10 @@ def get_trimmed_traceback(exception=None):
6769
# was raised inside Hypothesis. Additionally, the environment variable
6870
# HYPOTHESIS_NO_TRACEBACK_TRIM is respected if nonempty, because verbose
6971
# mode is prohibitively slow when debugging strategy recursion errors.
72+
assert hypothesis.settings.default is not None
7073
if (
7174
tb is None
72-
or os.environ.get("HYPOTHESIS_NO_TRACEBACK_TRIM", None)
75+
or os.environ.get("HYPOTHESIS_NO_TRACEBACK_TRIM")
7376
or hypothesis.settings.default.verbosity >= hypothesis.Verbosity.debug
7477
or (
7578
is_hypothesis_file(traceback.extract_tb(tb)[-1][0])

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def _clean_source(src: str) -> bytes:
8282
return "\n".join(x.rstrip() for x in src.splitlines() if x.rstrip()).encode()
8383

8484

85-
def function_digest(function):
85+
def function_digest(function: Any) -> bytes:
8686
"""Returns a string that is stable across multiple invocations across
8787
multiple processes and is prone to changing significantly in response to
8888
minor changes to the function.

0 commit comments

Comments
 (0)