You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hypothesis is a mature project with a stable API - but we do occasionally deprecate and eventually remove things. It would be nice if we shipped tools to automatically refactor affected code, and LibCST looks great for that!
Codemod ideas
Automatically fix deprecated code, to make updating Hypothesis easier:
Discard the @st.composite decorator for functions which could just return a strategy, because they have no dependencies between draws.
other ideas TBD, suggestions welcome
General notes
I'd like to support this via both the LibCST and the Hypothesis CLI, for maximum flexibility and visibility
We should ensure that deprecation messages suggest using the codemod if one is available, and add that to our development guide (along with "please add a codemod, or issue, if deprecating something")
The text was updated successfully, but these errors were encountered:
Zac-HD
changed the title
New feature: codemods to automatically upgrade for newer Hypothesis versions
Codemods to automatically upgrade for newer Hypothesis versions
Dec 19, 2020
In the meantime, I'm optimistic that this will be fairly low-impact - if you're running codemods, that implies you've been using Hypothesis for a while and can probably upgrade library versions before trying the Python version upgrade. Even if some of your test files no longer compile under Python 3.9, using 3.8 to run hypothesis codemod ... will at least handle the others.
Closing this because the remaining ideas don't seem worth the implementation effort; though I'd still be delighted to accept PRs if anyone would like to build more codemods 🙂
Hypothesis is a mature project with a stable API - but we do occasionally deprecate and eventually remove things. It would be nice if we shipped tools to automatically refactor affected code, and LibCST looks great for that!
Codemod ideas
Automatically fix deprecated code, to make updating Hypothesis easier:
min_magnitude=None
tomin_magnitude=0
(in First codemods: fix positional arguments for keyword-only parameters #2712)And of course deprecations aren't the only possible use for a refactoring tool:
assume()
calls on a single argument into.filter()
calls on the relevant strategy@st.composite
decorator for functions which could just return a strategy, because they have no dependencies between draws.General notes
The text was updated successfully, but these errors were encountered: