Subst cleanups#4869
Open
mwichmann wants to merge 1 commit into
Open
Conversation
* Line breaks added for clarity * Code-style enforced in some places * In SpecialAttrWrapper.escape, an attribute is read once and stored in a local variable. * If all previous parts of an if-else chain have done return (or raise), there's no need for the next to be an "else". This causes one fairly large indentation change in StringSubber.expand(), as about 40 lines shift left one indent (checker observation) * In subst-dict the local variable is renamed from dict to substitutions to avoid "hiding" built-in dict (frequent checker grumble) Signed-off-by: Mats Wichmann <mats@linux.com>
5db12e9 to
c59efbf
Compare
bdbaddog
reviewed
Jun 28, 2026
| return quote_func(self.data) | ||
| else: | ||
| return self.data | ||
| data = self.data |
Contributor
There was a problem hiding this comment.
why data = self.data instead of just using self.data?
same question why self.literal instead of self.is_literal() ?
Collaborator
Author
There was a problem hiding this comment.
"data": to avoid as many as three attribute lookups
Collaborator
Author
There was a problem hiding this comment.
Oh, missed the second Q. is_literal seemed an extra call that wasn't needed:
def is_literal(self) -> bool:
return self.literalBoth would only have a minimal performance improvement, so if you don't want we can just drop the changes.
Contributor
There was a problem hiding this comment.
There's a a couple .. def is_literal from class Literal() which returns True presently..
can those get called by this logic?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No changed behavior, so existing tests and docs are unchanged.
Contributor Checklist:
CHANGES.txtandRELEASE.txt(and read theREADME.rst).