-
Notifications
You must be signed in to change notification settings - Fork 1
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
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.
Due to GitHub API limits, only the first 60 comments can be shown.
return re.search("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1) | ||
return re.search("__version__ = ['\"]([^'\"]+)['\"]", init_py)[1] |
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 get_version
refactored with the following changes:
- Replace m.group(x) with m[x] for re.Match objects (
use-getitem-for-re-match-groups
)
|
||
from prompt_toolkit.formatted_text import HTML | ||
from prompt_toolkit.shortcuts import checkboxlist_dialog, message_dialog | ||
from prompt_toolkit.styles import Style | ||
|
||
results = checkboxlist_dialog( | ||
if results := checkboxlist_dialog( |
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.
Lines 9-30
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
output = "\n\nIn: {}\nOut: {}".format( | ||
input_field.text, eval(input_field.text) | ||
) # Don't do 'eval' in real code! | ||
output = f"\n\nIn: {input_field.text}\nOut: {eval(input_field.text)}" |
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.accept
refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting
)
This removes the following comments ( why? ):
# Don't do 'eval' in real code!
("class:status", _pager_py_path + " - "), | ||
("class:status", f"{_pager_py_path} - "), | ||
( | ||
"class:status.position", | ||
"{}:{}".format( | ||
text_area.document.cursor_position_row + 1, | ||
text_area.document.cursor_position_col + 1, | ||
), | ||
f"{text_area.document.cursor_position_row + 1}:{text_area.document.cursor_position_col + 1}", |
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 get_statusbar_text
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
) - Replace call to format with f-string (
use-fstring-for-formatting
)
return " {}:{} ".format( | ||
text_field.document.cursor_position_row + 1, | ||
text_field.document.cursor_position_col + 1, | ||
) | ||
return f" {text_field.document.cursor_position_row + 1}:{text_field.document.cursor_position_col + 1} " |
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 get_statusbar_right_text
refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting
)
title="Progress bar example with custom formatter.", | ||
formatters=custom_formatters, | ||
style=style, | ||
) as pb: | ||
title="Progress bar example with custom formatter.", | ||
formatters=custom_formatters, | ||
style=style, | ||
) as pb: | ||
|
||
for i in pb(range(20), label="Downloading..."): | ||
for _ in pb(range(20), label="Downloading..."): |
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 unused for index with underscore (
for-index-underscore
)
for i in pb(range(1600), label="Installing"): | ||
for _ in pb(range(1600), label="Installing"): |
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 unused for index with underscore (
for-index-underscore
)
if true_color: | ||
color_depth = ColorDepth.DEPTH_24_BIT | ||
else: | ||
color_depth = ColorDepth.DEPTH_8_BIT | ||
|
||
color_depth = ColorDepth.DEPTH_24_BIT if true_color else ColorDepth.DEPTH_8_BIT | ||
with ProgressBar(formatters=custom_formatters, color_depth=color_depth) as pb: | ||
for i in pb(range(20), label="Downloading..."): | ||
for _ in pb(range(20), label="Downloading..."): |
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 if statement with if expression (
assign-if-exp
) - Replace unused for index with underscore (
for-index-underscore
)
for i in pb(range(1600), label="Installing"): | ||
for _ in pb(range(1600), label="Installing"): |
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 unused for index with underscore (
for-index-underscore
)
for i in pb(range(1600), label="Installing"): | ||
for _ in pb(range(1600), label="Installing"): |
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 unused for index with underscore (
for-index-underscore
)
for i in pb(range(100)): | ||
for _ in pb(range(100)): |
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.task_1
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
)
for i in pb(range(150)): | ||
for _ in pb(range(150)): |
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.task_2
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
)
for i in pb(data()): | ||
for _ in pb(data()): |
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 unused for index with underscore (
for-index-underscore
)
@@ -6,11 +6,12 @@ | |||
This should display the prompt with all the formatting like usual, but not | |||
allow any editing. | |||
""" | |||
|
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.
Lines 16-16
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
print("You said: %s" % text) | ||
print(f"You said: {text}") |
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 (
replace-interpolation-with-fstring
)
print("You said: %s" % answer) | ||
print(f"You said: {answer}") |
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.
Lines 7-7
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
|
||
import getpass | ||
|
||
from prompt_toolkit import prompt | ||
|
||
if __name__ == "__main__": | ||
answer = prompt("What is your name: ", default="%s" % getpass.getuser()) | ||
print("You said: %s" % answer) | ||
answer = prompt("What is your name: ", default=f"{getpass.getuser()}") | ||
print(f"You said: {answer}") |
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.
Lines 11-12
refactored with the following changes:
- Replace interpolated string formatting with f-string [×2] (
replace-interpolation-with-fstring
)
|
||
from prompt_toolkit import prompt | ||
|
||
if __name__ == "__main__": | ||
answer = prompt("Give me some input: ") | ||
print("You said: %s" % answer) | ||
print(f"You said: {answer}") |
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.
Lines 9-9
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
else: | ||
text = ("- %i - " % (line_number + 1)).rjust(width) | ||
return HTML("<strong>%s</strong>") % text | ||
text = ("- %i - " % (line_number + 1)).rjust(width) | ||
return HTML("<strong>%s</strong>") % text |
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 prompt_continuation
refactored with the following changes:
- Remove unnecessary else after guard condition (
remove-unnecessary-else
)
print("You said: %s" % answer) | ||
print(f"You said: {answer}") |
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.
Lines 29-29
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
print("You said: %s" % password) | ||
print(f"You said: {password}") |
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.
Lines 6-6
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
print("You said: %s" % text) | ||
print(f"You said: {text}") |
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 (
replace-interpolation-with-fstring
)
print("You said: %s" % text) | ||
print(f"You said: {text}") | ||
|
||
# While typing | ||
text = prompt( | ||
"Enter e-mail address: ", validator=validator, validate_while_typing=True | ||
) | ||
print("You said: %s" % text) | ||
print(f"You said: {text}") |
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
)
print("You said: %s" % result) | ||
print(f"You said: {result}") |
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 (
replace-interpolation-with-fstring
)
print("You said: %s" % answer) | ||
print(f"You said: {answer}") |
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.
Lines 10-10
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
print("You said: %s" % text) | ||
print(f"You said: {text}") |
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 (
replace-interpolation-with-fstring
)
print("You said: %s" % text) | ||
print(f"You said: {text}") |
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 (
replace-interpolation-with-fstring
)
print("You said: %s" % text) | ||
print(f"You said: {text}") |
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 (
replace-interpolation-with-fstring
)
style="fg:" + color, | ||
selected_style="fg:white bg:" + color, | ||
style=f"fg:{color}", | ||
selected_style=f"fg:white bg:{color}", |
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 ColorCompleter.get_completions
refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
print("You said: %s" % text) | ||
print(f"You said: {text}") |
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 (
replace-interpolation-with-fstring
)
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.21%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Help us improve this quality report! |
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!