Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Dec 4, 2023

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:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from tatstratasys December 4, 2023 15:24
Comment on lines -18 to +26
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
Copy link
Author

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}')
Copy link
Author

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:

Copy link
Author

@sourcery-ai sourcery-ai bot left a 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):
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants