Replies: 5 comments 4 replies
-
Yeah, the shear volume of non-f-string formatting in the project is why I haven't thrown anything into the CI jobs for it. We have ~10 years of string substitution and Perhaps if it could be tuned to new additions we could add it rather quickly, but I think we need to get through at least the bulk of the existing conversions first. |
Beta Was this translation helpful? Give feedback.
-
After thinking on this some more, I'm of the opinion we're just going to have to make a concerted effort in the next release cycle or two to do these conversions in large batches. I don't see a way to piecemeal this out and have any substantial movement in any reasonable amount of time if we want to formally make a check on f-strings going forward. |
Beta Was this translation helpful? Give feedback.
-
I've opened #3505 to kick this off. We used String substitution...we're gonna be here for a while. |
Beta Was this translation helpful? Give feedback.
-
I took a first pass at this and am hopeful the testing can vet out any issues that may have been left. I also went at it from a global perspective, which may not have been what we wanted. I believe in some cases, such as logging, the use of "%" based formatting is still suggested over f-strings. However, most logging appears to have not been following the Pylint suggestion for logging format interpolation (W1202), instead of:
using:
So the strings were being interpolated whether or not the messages were being emitted. Therefore moving them to f-strings should be an "apples to apples" conversion, meaning I believe that f-strings will also be interpolated regardless of the log message being emitted so there should be a similar performance observed between the main and the branch. However, this is one case to potentially consider not using f-strings and implementing logging format interpolation. I am not sure how beneficial this would be in the end, so my first pass simply changes everything to f-strings anyway, and if we want to try it out I suggest we handle this in a separate branch/PR after finishing an f-string conversion and passing all tests and checks. I opened a draft PR for discussion. My first commit implements the f-strings, and the second commit attempts to restore flake8 E501 compliance. Since I believe E501 should be the only thing the f-strings swap broke I did not address other flake8 complaints. The draft PR is #3536, since I only addressed E501 I suspect we will still see flake8 failures, my test against upstream main seemed to show there were 296 flake 8 issues already existing before I started (unless maybe I used the wrong version of flake8?)
|
Beta Was this translation helpful? Give feedback.
-
We done this now via pylint, so should be all good now |
Beta Was this translation helpful? Give feedback.
-
One of the common things that we are asking people to do is now use f-strings for all the new PRs. So, thought we should find something that can actually detect this for us, and our CI to detect this and alert straight away
Now,
pylint
can detect these for us, so that we don't forget :)Now, trying this on our project gives us a significant amount of lint issues. https://dpaste.com/2F7AFCCDY. I just ran a
pylint sos
in the current stateMy thought here is, that we disable most of these at first, convert all the f-strigs, and at least check for these. Then, maybe, we could start adding the extra tests and improve the ilnting.
Thoughts?
Beta Was this translation helpful? Give feedback.
All reactions