| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
pre-commit.ci autofix |
Sorry, something went wrong.
| "/{name}{{{bbox} sc\n".format( | ||
| name=font.get_glyph_name(glyph_id), | ||
| bbox=" ".join(map(str, [g.horiAdvance, 0, *g.bbox])), | ||
| ) |
There was a problem hiding this comment.
I think that one can get f-strings here as well (although those will be horrible...) if it is executed again?
Sorry, something went wrong.
|
In general, I'm tempting to skip the f-string conversion and let it evolve "organically" as some of them are quite painful as @ksunden points out (others are obviously a clear improvement). Also, some that are turned into format should probably be f-strings (others not). (Interesting that some unpacking comprehensions are converted into tuples, but not things like if a in ["b", "c"]:.) Edit: to be clear, things that are not f-string conversions, I do not object to. |
Sorry, something went wrong.
|
|
||
| # The decorator ensures this always returns the same handler (and it is only | ||
| # attached once). | ||
| @functools.lru_cache() |
There was a problem hiding this comment.
Some of these should be converted to functions.cache for clarity, in fact.
Sorry, something went wrong.
There was a problem hiding this comment.
I updated some of them where I thought an unbounded cache was alright, but others I figured we can handle later if we want to change to unbounded rather than the default size of 128. When I was looking through the lru_cache locations it looked like we may even have some decorated instance methods with self that may be keeping instances alive, I wonder if that is causing any of the slowly growing memory leaks that have been reported...
Sorry, something went wrong.
There was a problem hiding this comment.
I was specifically referring to cases where the cache just serves to establish a singleton, like here.
Sorry, something went wrong.
|
I went through every .format() call and subjectively evaluated whether f-strings would be nicer or not. So, this is definitely most of the locations that can/should be updated now (even more than the automatic formatter picked up the first go-around). I personally prefer to just get formatting changes updated in one go so you can ignore that commit more easily through blames. |
Sorry, something went wrong.
|
I think it would be a good idea to add a .git-blame-ignore-revs file. See also https://www.stefanjudis.com/today-i-learned/how-to-exclude-commits-from-git-blame/ |
Sorry, something went wrong.
Yes, I agree and we already have one that I updated here :) |
Sorry, something went wrong.
There was a problem hiding this comment.
This is good; I can drop my f-string stash now.
Sorry, something went wrong.
|
Thanks, @QuLogic, good recommendations as usual! |
Sorry, something went wrong.
Command: `pyupgrade --py39-plus` Manual updates to add some f-strings and ignore f-strings in tex formats.
| Back | FazBrowse Home | New Git URL |
PR Summary
Now that we are on Python 3.9+ (#24919), we can update/simplify some of the code.
Automated command line utility for it:
A lot of this is f-string updates, so I added the first commit to the git ignore blame so there is less churn in the blame lookups.
There are also some OSError aliases and getting rid of the unnecessary parentheses in the lru_cache decorator
PR Checklist
Documentation and Tests
Release Notes