-
Notifications
You must be signed in to change notification settings - Fork 0
Sourcery refactored master branch #1
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
base: master
Are you sure you want to change the base?
Conversation
elif character in string.punctuation: | ||
pass | ||
else: | ||
elif character not in string.punctuation: |
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 header_link
refactored with the following changes:
- Remove empty elif clause (
remove-pass-elif
)
if default: | ||
# yes by default | ||
question += ' [Y/n] ' | ||
else: | ||
# no by default | ||
question += ' [y/N] ' | ||
|
||
question += ' [Y/n] ' if default else ' [y/N] ' |
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 askyesno
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
This removes the following comments ( why? ):
# yes by default
# no by default
shutil.copy(filename, filename + '.backup') | ||
shutil.copy(filename, f'{filename}.backup') | ||
try: | ||
yield | ||
except Exception: | ||
# It failed, we need to restore from the backup. | ||
shutil.copy(filename + '.backup', filename) | ||
shutil.copy(f'{filename}.backup', filename) | ||
else: | ||
# Everything's fine, we can safely get rid of the backup. | ||
os.remove(filename + '.backup') | ||
os.remove(f'{filename}.backup') |
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 backup
refactored with the following changes:
- Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation
)
elif character in string.punctuation: | ||
pass | ||
else: | ||
elif character not in string.punctuation: |
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 header_link
refactored with the following changes:
- Remove empty elif clause (
remove-pass-elif
)
else: | ||
# A file. | ||
if not os.path.isfile(path): | ||
return "not a file" | ||
elif not os.path.isfile(path): | ||
return "not a file" | ||
|
||
if title is not None and title not in titledict[path]: | ||
return "no title named %s" % title | ||
return f"no title named {title}" |
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 check
refactored with the following changes:
- Merge else clause's nested if statement into elif (
merge-else-if-into-elif
) - Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
This removes the following comments ( why? ):
# A file.
link = fix_filename(before) + '#' + after | ||
link = f'{fix_filename(before)}#{after}' |
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 TutorialRenderer.link
refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
result.append('<p><font color="green">%s</font></p>' | ||
% line.strip('+')) | ||
result.append(f"""<p><font color="green">{line.strip('+')}</font></p>""") | ||
elif line.startswith('-'): | ||
result.append('<p><font color="red">%s</font></p>' | ||
% line.strip('-')) | ||
result.append(f"""<p><font color="red">{line.strip('-')}</font></p>""") | ||
else: | ||
result.append('<p>%s</p>' % line) | ||
result.append(f'<p>{line}</p>') |
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 TutorialRenderer.block_code
refactored with the following changes:
- Replace interpolated string formatting with f-string [×3] (
replace-interpolation-with-fstring
)
result = [] | ||
for part in text.split('\n'): | ||
result.append(textwrap.fill(part)) | ||
result = [textwrap.fill(part) for part in text.split('\n')] |
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 wrap_text
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
)
print(" %s -m pip install pygments" % python) | ||
print(f" {python} -m pip install pygments") |
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 main
refactored with the following changes:
- Replace interpolated string formatting with f-string [×2] (
replace-interpolation-with-fstring
)
content = BEGINNING + content.replace(directory + '/', '').rstrip() | ||
content = BEGINNING + content.replace(f'{directory}/', '').rstrip() |
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 main
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
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!