-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
More f-string conversion using pyupgrade 2.25.0 #3724
Conversation
Ran this: $ pyupgrade --py37-plus Bio/*.py Bio/*/*.py Bio/*/*/*.py BioSQL/*.py $ black Bio/ BioSQL/ Then reverted any changes adding a .format method, spotted with: $ git diff | grep "^+" | grep -E "(\.format|\+\+\+)"
Used pyupgrade then reverted most of the more complicated examples where it wanted to use a .format call, but turned a few others into f-strings by hand.
I think on balance I prefer the behaviour of Expect a followup PR using |
Exciting, a failure:
Was: lines.append(
"Query:%8s %s %s" % (self.query_start, self.query, self.query_end)
) PR used: lines.append(f"Query:{self.query_start:>8} {self.query} {self.query_end}") If the value is >>> "%8s" % None
' None' However, while >>> f"{None:>8}"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported format string passed to NoneType.__format__ |
ed3d8da
to
87142ea
Compare
Codecov Report
@@ Coverage Diff @@
## master #3724 +/- ##
==========================================
- Coverage 83.77% 82.08% -1.70%
==========================================
Files 314 294 -20
Lines 52512 49392 -3120
==========================================
- Hits 43994 40543 -3451
- Misses 8518 8849 +331
Continue to review full report at Codecov.
|
The input value can be None.
87142ea
to
6b52163
Compare
Cross reference https://bugs.python.org/issue45165 for the use of f-string alignment with None. |
I hereby agree to dual licence this and any previous contributions under both
the Biopython License Agreement AND the BSD 3-Clause License.
I have read the
CONTRIBUTING.rst
file, have runpre-commit
locally,and understand that AppVeyor and TravisCI will be used to confirm the Biopython unit
tests and style checks pass with these changes.
I have added my name to the alphabetical contributors listings in the files
NEWS.rst
andCONTRIB.rst
as part of this pull request, am listedalready, or do not wish to be listed. (This acknowledgement is optional.)
Progress on #2510, follows on from #3723. With these changes about a quarter of the main code base string formatting will be f-strings:
(pyupgrade would convert about 100 more of the percent uses, but mostly to format strings - there about 30 more f-strings it would create which I missed in this manual selection)