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

Add pyupgrade to our toolchain #6699

Closed
legoktm opened this issue Dec 5, 2022 · 4 comments · Fixed by #6720
Closed

Add pyupgrade to our toolchain #6699

legoktm opened this issue Dec 5, 2022 · 4 comments · Fixed by #6720

Comments

@legoktm
Copy link
Member

legoktm commented Dec 5, 2022

Description

pyupgrade is a tool that automatically rewrites code to use modern syntax. https://github.com/asottile/pyupgrade has a detailed list with examples.

This would be similar to black/isort, in which we'd have a command like make pyupgrade that applies all the changes, and then another like make pyupgrade-check which verifies there are no unapplied changes. Note that black should always run after pyupgrade changes things.

User Stories

  • As a developer, I want to automatically update Python code to modern patterns/syntax so I don't have to do it manually
@phershbe
Copy link

phershbe commented Dec 6, 2022

@legoktm I can work on this if you'd like. I'm relatively new and don't have professional experience yet but I do open source sometimes and I've worked with make and black before, for example. Let me know!

@legoktm
Copy link
Member Author

legoktm commented Dec 7, 2022

Hi @phershbe, thanks for your interest! I want to get input from other team members before we move ahead with this, that will probably take (or not) a week if you don't mind waiting, or I can suggest another task for you to work on now!

@phershbe
Copy link

phershbe commented Dec 7, 2022

@legoktm Yeah, of course, I'm not on any kind of timeline, I'm simply here to help and to practice. Thank you for offering another task ... I'm kind of intimated by a lot of stuff, any other easy tasks off the top of your head? I was looking at #6641.

@legoktm
Copy link
Member Author

legoktm commented Dec 12, 2022

@phershbe: yep, that is (I think!) relatively straightforward (parsing the flask version out of requirements.txt). I'd also suggest #2484 (some code deletion), and #6515 (porting some regex checks to Python/flask).

legoktm added a commit that referenced this issue Jan 10, 2023
Generated with `pyupgrade --py38-plus **.py`, with manual adjustments
for unused imports and then running black+isort.

Mostly covers:
* migration to f-strings
* removal of coding: utf-8 comments
* io.open() -> open()

Fixes #6699.
legoktm added a commit that referenced this issue Jan 10, 2023
Generated with `pyupgrade --py38-plus **.py`, with manual adjustments
for unused imports and then running black+isort.

Mostly covers:
* migration to f-strings
* removal of coding: utf-8 comments
* io.open() -> open()

Fixes #6699.
legoktm added a commit that referenced this issue Jan 10, 2023
Generated with `pyupgrade --py38-plus **.py`, with manual adjustments
for unused imports and then running black+isort.

Mostly covers:
* migration to f-strings
* removal of coding: utf-8 comments
* io.open() -> open()

Fixes #6699.
nathandyer pushed a commit that referenced this issue Mar 13, 2023
Generated with `pyupgrade --py38-plus **.py`, with manual adjustments
for unused imports and then running black+isort.

Mostly covers:
* migration to f-strings
* removal of coding: utf-8 comments
* io.open() -> open()

Fixes #6699.
legoktm added a commit that referenced this issue Jul 6, 2023
In #6720 adding pyupgrade to CI automatically was deemed infeasible, so
we did a one-time pass and left it alone. With ruff it's pretty
straightforward so let's turn it on and auto-fix the newly flagged
issues.

Fixes #6699.
legoktm added a commit that referenced this issue Jul 6, 2023
In #6720 adding pyupgrade to CI automatically was deemed infeasible, so
we did a one-time pass and left it alone. With ruff it's pretty
straightforward so let's turn it on and auto-fix the newly flagged
issues.

Fixes #6699.
legoktm added a commit that referenced this issue Jul 6, 2023
In #6720 adding pyupgrade to CI automatically was deemed infeasible, so
we did a one-time pass and left it alone. With ruff it's pretty
straightforward so let's turn it on and auto-fix the newly flagged
issues.

Fixes #6699.
legoktm added a commit that referenced this issue Jul 26, 2023
In #6720 adding pyupgrade to CI automatically was deemed infeasible, so
we did a one-time pass and left it alone. With ruff it's pretty
straightforward so let's turn it on and auto-fix the newly flagged
issues.

Fixes #6699.
legoktm added a commit that referenced this issue Jul 26, 2023
In #6720 adding pyupgrade to CI automatically was deemed infeasible, so
we did a one-time pass and left it alone. With ruff it's pretty
straightforward so let's turn it on and auto-fix the newly flagged
issues.

Fixes #6699.
legoktm added a commit that referenced this issue Jul 27, 2023
In #6720 adding pyupgrade to CI automatically was deemed infeasible, so
we did a one-time pass and left it alone. With ruff it's pretty
straightforward so let's turn it on and auto-fix the newly flagged
issues.

Fixes #6699.
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 a pull request may close this issue.

2 participants