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

Codemods to automatically upgrade for newer Hypothesis versions #2705

Closed
2 of 6 tasks
Zac-HD opened this issue Dec 17, 2020 · 3 comments
Closed
2 of 6 tasks

Codemods to automatically upgrade for newer Hypothesis versions #2705

Zac-HD opened this issue Dec 17, 2020 · 3 comments
Labels
new-feature entirely novel capabilities or strategies

Comments

@Zac-HD
Copy link
Member

Zac-HD commented Dec 17, 2020

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:

And of course deprecations aren't the only possible use for a refactoring tool:

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")
@sobolevn
Copy link
Member

Important note: libcst does not work with python3.10+ and can break on some python3.9 code.
Related Instagram/LibCST#285

@Zac-HD
Copy link
Member Author

Zac-HD commented Apr 20, 2021

I hope that they'll fix that soon!

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.

@Zac-HD
Copy link
Member Author

Zac-HD commented Sep 13, 2021

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 🙂

@Zac-HD Zac-HD closed this as completed Sep 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-feature entirely novel capabilities or strategies
Projects
None yet
Development

No branches or pull requests

2 participants