Skip to content

Commit

Permalink
Register strategy for zip
Browse files Browse the repository at this point in the history
and skip a from_type warning on exceptions, which can happen under PyPY.
  • Loading branch information
Zac-HD committed Jan 8, 2024
1 parent 585f0a4 commit e534c52
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
6 changes: 6 additions & 0 deletions hypothesis-python/RELEASE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
RELEASE_TYPE: patch

This patch registers explicit strategies for a handful of builtin types,
motivated by improved introspection in PyPy 7.3.14 triggering existing
internal warnings.
Thanks to Carl Friedrich Bolz-Tereick for helping us work out what changed!
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,7 @@ def from_type_guarded(thing):
kwargs[k] = from_type_guarded(hints[k])
if p.default is not Parameter.empty and kwargs[k] is not ...:
kwargs[k] = just(p.default) | kwargs[k]
if params and not kwargs:
if params and not kwargs and not issubclass(thing, BaseException):
from_type_repr = repr_call(from_type, (thing,), {})
builds_repr = repr_call(builds, (thing,), {})
warnings.warn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,17 +625,18 @@ def _networks(bits):
BaseExceptionGroup: st.builds(
BaseExceptionGroup,
st.text(),
st.lists(st.from_type(BaseException), min_size=1),
st.lists(st.from_type(BaseException), min_size=1, max_size=5),
),
ExceptionGroup: st.builds(
ExceptionGroup,
st.text(),
st.lists(st.from_type(Exception), min_size=1),
st.lists(st.from_type(Exception), min_size=1, max_size=5),
),
enumerate: st.builds(enumerate, st.just(())),
filter: st.builds(filter, st.just(lambda _: None), st.just(())),
map: st.builds(map, st.just(lambda _: None), st.just(())),
reversed: st.builds(reversed, st.just(())),
zip: st.builds(zip), # avoids warnings on PyPy 7.3.14+
property: st.builds(property, st.just(lambda _: None)),
classmethod: st.builds(classmethod, st.just(lambda self: self)),
staticmethod: st.builds(staticmethod, st.just(lambda self: self)),
Expand Down

0 comments on commit e534c52

Please sign in to comment.