Replace string interpolation with log arguments and f-strings #254
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is the next in the series of refactorings originally set out in #207 which endeavors to replace duplicated code in Sync2Jira with common subroutines; this is the follow-on to #253.
These changes center on removing the uses of Python2-style string interpolation, replacing them with more appropriate operations.
For inserting values into log messages, the logger will do the interpolation automatically if the values are provided as arguments to the call. This approach has the added advantage that the interpolation is deferred until the message is actually logged, such that, if the intended class of logging is disabled (e.g., calling
log.debug()
when the log level is set to "INFO") the interpolation will be skipped, since the message won't be logged, which is a performance savings. So, this PR removes uses of the interpolation operator (%
) from logging calls instead passing the to-be-interpolated values as arguments to the logger call.For inserting values into other strings, Python3 offers "f-strings" which are generally more expressive and easier to read than the Python2 format arguments used with the interpolation operator. So, this PR makes that substitution where it improves the readability of the code.
For converting values to strings without further augmentation, this PR replaces the interpolation with a call to
str()
.Added code to trim whitespace from the issue owner, iff the owner is not
None
, blank, or in some other way absent or unpleasant. (A similar change for the admin username is coming in a subsequent commit.)And, removed a couple of unneeded list instantiations.