Skip to content

Commit 2957d5e

Browse files
committed
hypothesis: merge the context mappings.
1 parent f476ef8 commit 2957d5e

2 files changed

Lines changed: 9 additions & 13 deletions

File tree

returns/contrib/hypothesis/laws.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -194,20 +194,16 @@ def _enter_hypothesis_context(
194194
container_type: type[Lawful],
195195
settings: _Settings,
196196
) -> None:
197-
stack.enter_context(strategies_for_types({TypeVar: type_vars_factory})) # type: ignore[dict-item]
198-
stack.enter_context(
199-
strategies_for_types({Callable: pure_functions_factory}) # type: ignore[dict-item]
200-
)
201-
stack.enter_context(
202-
strategies_for_types({
203-
interface: _strategy_for_container(container_type, settings)
204-
for interface in container_type.laws()
205-
}),
206-
)
207197
stack.enter_context(
208198
strategies_for_types({
209-
container_type: _strategy_for_container(container_type, settings)
210-
}),
199+
TypeVar: type_vars_factory, # type: ignore[dict-item]
200+
Callable: pure_functions_factory, # type: ignore[dict-item]
201+
**{
202+
interface: _strategy_for_container(container_type, settings)
203+
for interface in container_type.laws()
204+
},
205+
container_type: _strategy_for_container(container_type, settings),
206+
})
211207
)
212208

213209

tests/test_contrib/test_hypothesis/test_type_resolution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from returns.contrib.hypothesis.laws import (
2020
_enter_hypothesis_context, # noqa: PLC2701
2121
_Settings, # noqa: PLC2701
22-
)
22+
)
2323
from returns.contrib.hypothesis.type_resolver import (
2424
StrategyFactory,
2525
apply_strategy,

0 commit comments

Comments
 (0)