-
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 #1
base: master
Are you sure you want to change the base?
Conversation
self.log.debug(f"serving finished") | ||
self.log.debug('serving finished') |
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 Client.download
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
text = "T" | ||
if not favicon_path.exists(): | ||
W, H = (360, 360) | ||
color = tuple((random.randint(0, 255) for _ in range(3))) | ||
im = Image.new("RGB", (W, H), color) | ||
draw = ImageDraw.Draw(im) | ||
font = ImageFont.truetype("arial.ttf", 50) | ||
text = "T" |
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 FaviconIconView.faviconicon
refactored with the following changes:
- Move assignments closer to their usage (
move-assign
)
kwargs.update({"search": search_query}) | ||
|
||
kwargs["search"] = search_query |
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 IndexView.index
refactored with the following changes:
- Add single value to dictionary directly rather than using update() (
simplify-dictionary-update
)
if message.reply_markup: | ||
if isinstance(message.reply_markup, types.ReplyInlineMarkup): | ||
reply_btns = [ | ||
[ | ||
{"url": button.url, "text": button.text} | ||
for button in button_row.buttons | ||
if isinstance(button, types.KeyboardButtonUrl) | ||
] | ||
for button_row in message.reply_markup.rows | ||
if message.reply_markup and isinstance( | ||
message.reply_markup, types.ReplyInlineMarkup | ||
): | ||
reply_btns = [ | ||
[ | ||
{"url": button.url, "text": button.text} | ||
for button in button_row.buttons | ||
if isinstance(button, types.KeyboardButtonUrl) | ||
] | ||
for button_row in message.reply_markup.rows | ||
] |
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 InfoView.info
refactored with the following changes:
- Merge nested if conditions (
merge-nested-ifs
) - Replace if statement with if expression (
assign-if-exp
)
pos = -1 if req.query.get("big", None) else int(len(photo.sizes) / 2) | ||
pos = -1 if req.query.get("big", None) else len(photo.sizes) // 2 |
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 LogoView.logo
refactored with the following changes:
- Simplify division expressions. (
simplify-division
)
if request.app["is_authenticated"] and str(request.rel_url.path) not in [ | ||
if not request.app["is_authenticated"] or str(request.rel_url.path) in [ | ||
"/login", | ||
"/logout", | ||
]: | ||
url = request.app.router["login_page"].url_for() | ||
if str(request.rel_url) != "/": | ||
url = url.with_query(redirect_to=str(request.rel_url)) | ||
return await handler(request) | ||
url = request.app.router["login_page"].url_for() | ||
if str(request.rel_url) != "/": | ||
url = url.with_query(redirect_to=str(request.rel_url)) | ||
|
||
basic_auth_check_resp = _do_basic_auth_check(request) | ||
basic_auth_check_resp = _do_basic_auth_check(request) | ||
|
||
if basic_auth_check_resp is True: | ||
return await handler(request) | ||
if basic_auth_check_resp is True: | ||
return await handler(request) | ||
|
||
cookies_auth_check_resp = await _do_cookies_auth_check(request) | ||
cookies_auth_check_resp = await _do_cookies_auth_check(request) | ||
|
||
if cookies_auth_check_resp is not None: | ||
return await handler(request) | ||
if cookies_auth_check_resp is not None: | ||
return await handler(request) | ||
|
||
if isinstance(basic_auth_check_resp, Response): | ||
return basic_auth_check_resp | ||
if isinstance(basic_auth_check_resp, Response): | ||
return basic_auth_check_resp | ||
|
||
return HTTPFound(url) | ||
|
||
return await handler(request) | ||
return HTTPFound(url) |
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 middleware_factory.factory
refactored with the following changes:
- Add guard clause (
last-if-guard
)
color = tuple([random.randint(0, 255) for i in range(3)]) | ||
color = tuple(random.randint(0, 255) for _ in range(3)) | ||
im = Image.new("RGB", (100, 100), color) | ||
temp = io.BytesIO() | ||
im.save(temp, "PNG") | ||
body = temp.getvalue() | ||
else: | ||
thumb_pos = int(len(thumbnails) / 2) | ||
thumb_pos = len(thumbnails) // 2 |
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 ThumbnailView.thumbnail_get
refactored with the following changes:
- Replace unneeded comprehension with generator (
comprehension-to-generator
) - Replace unused for index with underscore (
for-index-underscore
) - Simplify division expressions. (
simplify-division
)
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 2.11%.
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!