-
Notifications
You must be signed in to change notification settings - Fork 0
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
Sourcery refactored master branch #2
base: master
Are you sure you want to change the base?
Conversation
def DumpBuffer (buf, length, caption="", dest=sys.stdout): | ||
def DumpBuffer(buf, length, caption="", dest=sys.stdout): | ||
def GetPrintableChar(str): | ||
if str.isalpha(): | ||
return str | ||
else: | ||
return '.' | ||
return str if str.isalpha() else '.' | ||
|
||
dest.write('---------> %s <--------- (%d bytes)\n' % (caption, length)) | ||
dest.write(' +0 +4 +8 +c 0 4 8 c\n') | ||
i = 0 | ||
while i < length: | ||
if length - i > 16: | ||
l = 16 | ||
else: | ||
l = length - i | ||
|
||
l = 16 if length - i > 16 else length - i |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function DumpBuffer
refactored with the following changes:
- Replace if statement with if expression [×2] (
assign-if-exp
) - Replace assignment with augmented assignment (
aug-assign
)
wait_for_prompt(inkscape_process, '%s -i %s -e %s' % (icon_file, rect, output_file)) | ||
wait_for_prompt(inkscape_process, f'{icon_file} -i {rect} -e {output_file}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function inkscape_render_rect
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Type: Refactoring
Summary of PR: This PR introduces code simplifications and modernizes string formatting by using f-strings and ternary operators in two Python scripts.
General PR suggestions
- Consider adhering to PEP 8 guidelines regarding spaces around default parameter values to maintain consistency with Python's style recommendations.
- Review the use of variable names that may shadow built-in type names, such as 'str', to avoid potential confusion and improve code clarity.
- Acknowledge the improvements in code readability and conciseness brought by the use of ternary operators and augmented assignment operators.
- Appreciate the transition to f-strings for string formatting, which is a more readable and performant approach in modern Python development.
- Ensure that all refactoring changes maintain the original functionality and intent of the code while enhancing maintainability and readability.
Your trial expires on December 18, 2023. Please email tim@sourcery.ai to continue using Sourcery ✨
@@ -15,22 +15,15 @@ | |||
|
|||
# Hexadecimal dump code from http://www.alexonlinux.com/hex-dump-functions | |||
|
|||
def DumpBuffer (buf, length, caption="", dest=sys.stdout): | |||
def DumpBuffer(buf, length, caption="", dest=sys.stdout): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought (llm): While the function signature has been reformatted to remove the space before the parenthesis, it's worth noting that PEP 8 suggests using spaces around the '=' for default parameter values.
Branch
master
refactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
master
branch, then run:Help us improve this pull request!