Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(deps): hypothesis update and text, refs #2262 #2263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
milssky wants to merge 1 commit into dry-python:master
base: master
Choose a base branch
Loading
from milssky:fix/hypothesis-update-and-tests

Conversation

@milssky
Copy link

@milssky milssky commented Sep 24, 2025

I have made things!

@pradeep90 hey! Your code is broken :) Can you validate it?

In hypothesis==6.137.2, this code produced the following output:

>>> from hypothesis import strategies as st
>>> st.functions(
... like=lambda *args, **kwargs: None,
... returns=st.booleans(),
... pure=True,
... )
functions(like=lambda *args, **kwargs: <unknown>, returns=booleans(), pure=True)

Whereas in hypothesis==6.140.2, the output is already:

functions(like=lambda *args, **kwargs: None, returns=booleans(), pure=True)

So this is indeed a direct change in the library itself.

Checklist

  • I have double checked that there are no unrelated changes in this pull request (old patches, accidental config files, etc)
  • I have created at least one test case for the changes I have made
  • I have updated the documentation for the changes I have made
  • I have added my changes to the CHANGELOG.md

Related issues

Refs #2262

🙏 Please, if you or your company finds dry-python valuable, help us sustain the project by sponsoring it transparently on https://github.com/sponsors/dry-python. As a thank you, your profile/company logo will be added to our main README which receives hundreds of unique visitors per day.

Copy link

codecov bot commented Sep 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (82ef3ef) to head (c2edebb).
⚠️ Report is 410 commits behind head on master.

Additional details and impacted files
@@ Coverage Diff @@
## master #2263 +/- ##
==========================================
 Coverage 100.00% 100.00% 
==========================================
 Files 80 81 +1 
 Lines 2485 2581 +96 
 Branches 437 44 -393 
==========================================
+ Hits 2485 2581 +96 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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
edited
Loading

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

@pradeep90 pradeep90 Sep 25, 2025

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.

)

milssky reacted with hooray emoji
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sobolevn sobolevn sobolevn left review comments

+1 more reviewer

@pradeep90 pradeep90 pradeep90 left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /