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

Pyupgrade + flynt + f-strings #1759

Merged
merged 5 commits into from
Nov 30, 2021
Merged

Pyupgrade + flynt + f-strings #1759

merged 5 commits into from
Nov 30, 2021

Conversation

akx
Copy link
Contributor

@akx akx commented Nov 29, 2021

Pull Request check-list

Please make sure to review and check all of these items:

  • Does $ tox pass with this change (including linting)?
    • Seemed to – some tests were skipped though.
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
    • The changes are mechanical.
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
    • No functional changes.
  • Is there an example added to the examples folder (if applicable)?
    • No functional changes.

Description of change

Since redis-py is Python 3.6+, this PR runs pyupgrade and flynt, followed by some manual edits, to turn all % and (almost all) .format() invocations to f-strings instead.

pyupgrade also does a couple other things such as fixes up super() calls and refactors things to use dict comprehensions, etc.

This is tangentially related to #1734 (so heads-up @WisdomPill 😄). Since black's code style prescribes a max-line-length of 88, I've (temporarily) adjusted the flake8 invocation in CI for that.

@codecov-commenter
Copy link

codecov-commenter commented Nov 29, 2021

Codecov Report

Merging #1759 (e9008bc) into master (12f45ee) will decrease coverage by 0.01%.
The diff coverage is 66.02%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1759      +/-   ##
==========================================
- Coverage   90.89%   90.87%   -0.02%     
==========================================
  Files          59       59              
  Lines       14229    14232       +3     
==========================================
+ Hits        12933    12934       +1     
- Misses       1296     1298       +2     
Impacted Files Coverage Δ
redis/commands/parser.py 88.70% <0.00%> (ø)
redis/commands/search/commands.py 87.88% <0.00%> (ø)
redis/commands/search/querystring.py 0.00% <0.00%> (ø)
tests/test_connection.py 73.07% <0.00%> (ø)
tests/test_pubsub.py 97.68% <0.00%> (ø)
redis/sentinel.py 85.98% <40.00%> (-0.56%) ⬇️
redis/client.py 84.81% <50.00%> (ø)
redis/commands/search/document.py 87.50% <50.00%> (ø)
redis/commands/search/result.py 97.22% <50.00%> (ø)
tests/conftest.py 91.83% <50.00%> (ø)
... and 22 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4db85ef...e9008bc. Read the comment docs.

@chayim
Copy link
Contributor

chayim commented Nov 29, 2021

Wow @akx thanks for introducing me to flynt. What do you think of modifying the commit hooks / tox linters call so that we fail immediately if there are any code chnages? You'd have to add this to dev_requirements.txt but this way we could catch PRs that violate this in the future. WYDT?

@chayim chayim added maintenance Maintenance (CI, Releases, etc) waiting-for-response labels Nov 29, 2021
@akx
Copy link
Contributor Author

akx commented Nov 29, 2021

Sure thing @chayim! Added that configuration in e9008bc.

@WisdomPill
Copy link
Contributor

great PR @akx!
Nice to see this new tool (flynt).

Which PR are we going to merge first? @chayim

@chayim
Copy link
Contributor

chayim commented Nov 29, 2021

@akx didn't pass unfortunately.

@WisdomPill I'd like to merge this, then yours - only since yours is pure autogen on top. I am feel guilty about pushing you again - please don't hate me! I think these are both great contributions and will be very thankful when they land.

@akx
Copy link
Contributor Author

akx commented Nov 29, 2021

@chayim Ah, I forgot that flynt wants the path to look at (whereas flake8 and friends default to the cwd). Fixed...

I also agree that this should probably be merged first, since there were a bunch of hand-rolled fixes in the 3rd commit.

@WisdomPill
Copy link
Contributor

No problem, just let me know when this gets merged so I can rebase on top of it

@chayim
Copy link
Contributor

chayim commented Nov 30, 2021

❤️ to everyone here. This is a beautiful thing.

@WisdomPill by the time you receive this, it'll now be in. Hopefully (as in 30 minutes from now) master will also be versioned as 4.1.0rc2 so that we can close this off. Yours is the next merge in.

@chayim chayim merged commit fbe87ac into redis:master Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Maintenance (CI, Releases, etc)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants