Skip to content

Commit 1cab11e

Browse files
committed
simplify entrypoints
1 parent c62b34a commit 1cab11e

2 files changed

Lines changed: 10 additions & 17 deletions

File tree

hypothesis-python/src/hypothesis/entry_points.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,15 @@
1717

1818
import importlib.metadata
1919
import os
20-
from collections.abc import Generator, Sequence
21-
from importlib.metadata import EntryPoint
22-
23-
24-
def get_entry_points() -> Generator[EntryPoint, None, None]:
25-
try:
26-
eps: Sequence[EntryPoint] = importlib.metadata.entry_points(group="hypothesis")
27-
except TypeError: # pragma: no cover
28-
# Load-time selection requires Python >= 3.10.
29-
# type ignore since interface differs pre-3.10
30-
eps = importlib.metadata.entry_points().get("hypothesis", []) # type: ignore
31-
yield from eps
3220

3321

3422
def run() -> None:
35-
if not os.environ.get("HYPOTHESIS_NO_PLUGINS"):
36-
for entry in get_entry_points(): # pragma: no cover
37-
hook = entry.load()
38-
if callable(hook):
39-
hook()
23+
if os.environ.get("HYPOTHESIS_NO_PLUGINS"):
24+
return
25+
26+
for entry in importlib.metadata.entry_points(
27+
group="hypothesis"
28+
): # pragma: no cover
29+
hook = entry.load()
30+
if callable(hook):
31+
hook()

hypothesis-python/src/hypothesis/internal/conjecture/provider_conformance.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def build_intervals(intervals: list[int]) -> list[tuple[int, int]]:
4444
if len(intervals) % 2:
4545
intervals = intervals[:-1]
4646
intervals.sort()
47+
# help mypy infer tuple[int, ...] -> tuple[int, int]
4748
return list(batched(intervals, 2, strict=True)) # type: ignore
4849

4950

0 commit comments

Comments
 (0)