Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/test_contrib/test_hypothesis/test_type_resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def test_types_to_strategies_default() -> None: # noqa: WPS210
]
assert (
_strategy_string(result[callable_type], Callable[[int, str], bool])
== 'functions(like=lambda *args, **kwargs: <unknown>,'
== 'functions(like=lambda *args, **kwargs: None,'
Copy link
Member

@sobolevn sobolevn Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The question is: does this function actually return None? Or is it a repr bug?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weirder and weirder

>>> from hypothesis.internal.lambda_sources import lambda_description
>>> lambda_description(lambda *args, **kwargs: None)
'lambda *args, **kwargs: None'
>>> lambda_description(lambda *args: None)
'lambda *args: <unknown>'
>>> lambda_description(lambda: None)
'lambda: <unknown>'

I keep looking

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the repr of lambdas was changed in HypothesisWorks/hypothesis#4500. Afaics, they used to always use <unknown>, but now they refine the lambda body string where possible. I think this should be a harmless change for us.

(Found this via the changelog for 6.137.3

https://github.com/HypothesisWorks/hypothesis/blob/275d4964d1df8f3bcac5eef96c36407d15824b56/hypothesis-python/docs/changelog.rst?plain=1#L233-L245

This patch makes the stringification of lambdas, and as a result
certain automatic filter rewriting operations, more robust. This fixes
issue https://github.com/HypothesisWorks/hypothesis/issues/4498, where a lambda was mistakenly identified as the identity
operator due to "inspect.getsource()" only returning the first line of
the lambda definition.

As a result, the "repr" of strategies filtered or mapped by lambda
functions may change slightly.

)

' returns=booleans(), pure=True)'
)
assert (
Expand Down