Skip to content
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

Use inspect.signature() for argument conversion and define_function_signature() #3387

Merged
merged 3 commits into from Jun 29, 2022

Conversation

Zac-HD
Copy link
Member

@Zac-HD Zac-HD commented Jun 28, 2022

This is a good chunk of the remaining work on #2706.

I'd suggest reviewing commit-by-commit, and TBH leaning pretty heavily on all the tests passing.

@Zac-HD Zac-HD force-pushed the use-signature-everywhere branch 2 times, most recently from 3ff4504 to 08181fb Compare June 28, 2022 10:38
Comment on lines -81 to +75
assert out == ((), {"a": 1, "b": 2})
assert out == ((), {"a": 1})
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a deliberate change for consistency: the previous behaviour of convert_positional_arguments() applied default arguments only for keyword-only params, which could lead to some weird reprs for strategies. Fortunately it can't affect @given(), because there it's an explicit error to have default values!

Comment on lines -62 to -66
def test_populates_defaults():
def bar(x=[], y=1):
pass

assert convert_keyword_arguments(bar, (), {}) == (([], 1), {})
Copy link
Member Author

Choose a reason for hiding this comment

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

A surprisingly complementary case to the above: previously this would populate defaults for pos-or-keyword arguments, but not for keyword-only. As above, we resolved the inconsistency in favor of passing fewer arguments.

@Zac-HD Zac-HD force-pushed the use-signature-everywhere branch 5 times, most recently from 9a37739 to a223db8 Compare June 29, 2022 06:53
@Zac-HD Zac-HD requested a review from honno June 29, 2022 08:03
Copy link
Member

@honno honno left a comment

Choose a reason for hiding this comment

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

LGTM. I love working with inspect.Signature!

@Zac-HD Zac-HD merged commit 9905333 into HypothesisWorks:master Jun 29, 2022
@Zac-HD Zac-HD deleted the use-signature-everywhere branch June 29, 2022 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants