Skip to content

Commit bdccc04

Browse files
committed
hypothesis: accept other strategies in check_all_laws.
1 parent cfc58fc commit bdccc04

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

returns/contrib/hypothesis/laws.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ class _Settings:
2929
settings_kwargs: dict[str, Any]
3030
use_init: bool
3131
container_strategy: StrategyFactory | None
32-
other_strategies: dict[type[object], StrategyFactory] = dataclasses.field(
33-
default_factory=dict
34-
)
32+
other_strategies: dict[type[object], StrategyFactory]
3533

3634
def __or__(self, other: Self) -> Self:
3735
return _Settings(
@@ -73,8 +71,9 @@ def _default_settings(container_type: type[Lawful]) -> _Settings:
7371
def check_all_laws(
7472
container_type: type[Lawful[Example_co]],
7573
*,
74+
container_strategy: StrategyFactory[Example_co],
7675
settings_kwargs: dict[str, Any] | None = None,
77-
container_strategy: StrategyFactory[Example_co] | None = None,
76+
other_strategies: dict[type[object], StrategyFactory] | None = None,
7877
) -> None: ...
7978

8079

@@ -93,6 +92,7 @@ def check_all_laws(
9392
settings_kwargs: dict[str, Any] | None = None,
9493
use_init: bool = False,
9594
container_strategy: StrategyFactory[Example_co] | None = None,
95+
other_strategies: dict[type[object], StrategyFactory] | None = None,
9696
) -> None:
9797
"""
9898
Function to check all defined mathematical laws in a specified container.
@@ -124,6 +124,7 @@ def check_all_laws(
124124
settings_kwargs or {},
125125
use_init,
126126
container_strategy,
127+
other_strategies=other_strategies or {},
127128
)
128129

129130
for interface, laws in container_type.laws().items():

tests/test_contrib/test_hypothesis/test_type_resolution.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ def test_types_to_strategies_default() -> None: # noqa: WPS210
187187
settings_kwargs={},
188188
use_init=False,
189189
container_strategy=None,
190+
other_strategies={},
190191
),
191192
)
192193

0 commit comments

Comments
 (0)