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

Catch hypothesis.errors.InvalidArgument due to multiple @given decorators #13038

Open
petermattia opened this issue Aug 21, 2024 · 2 comments
Open
Labels
needs-decision Awaiting a decision from a maintainer rule Implementing or modifying a lint rule

Comments

@petermattia
Copy link
Contributor

petermattia commented Aug 21, 2024

List of keywords you searched for before creating this issue. Write them down here so that others can find this issue more easily and help provide feedback.

  • "hypothesis"

It would be cool if ruff could automatically detect this hypothesis issue. Much faster to detect statically than during testing.

Catch FAILED src/tests/test_logic.py::test_check_value_is_greater_than_zero - hypothesis.errors.InvalidArgument: You have applied @given to the test test_check_value_is_greater_than_zero more than once, which wraps the test several times and is extremely slow. A similar effect can be gained by combining the arguments of the two calls to given. For example, instead of @given(booleans()) @given(integers()), you could write @given(booleans(), integers())
@petermattia petermattia changed the title Catch FAILED scan_processing/scan_info/tests/test_slicing_logic.py::test_check_value_is_greater_than_zero - hypothesis.errors.InvalidArgument: You have applied @given to the test test_check_value_is_greater_than_zero more than once, which wraps the test several times and is extremely slow. A similar effect can be gained by combining the arguments of the two calls to given. For example, instead of @given(booleans()) @given(integers()), you could write @given(booleans(), integers()) Catch hypothesis.errors.InvalidArgument Aug 21, 2024
@petermattia petermattia changed the title Catch hypothesis.errors.InvalidArgument Catch hypothesis.errors.InvalidArgument due to multiple @given decorators Aug 21, 2024
@dhruvmanila
Copy link
Member

I'm not familiar with hypothesis but I wonder if a codemod is available for this using https://hypothesis.readthedocs.io/en/latest/extras.html#hypothesis-codemods.

@dhruvmanila dhruvmanila added rule Implementing or modifying a lint rule needs-decision Awaiting a decision from a maintainer labels Aug 23, 2024
@dhruvmanila
Copy link
Member

Note: #7272 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-decision Awaiting a decision from a maintainer rule Implementing or modifying a lint rule
Projects
None yet
Development

No branches or pull requests

2 participants