Open
Conversation
Comment on lines
-47
to
+58
| size = '%.2f T' % terabytes | ||
| return '%.2f T' % terabytes | ||
| elif bytes >= 1073741824: | ||
| gigabytes = bytes / 1073741824 | ||
| size = '%.2f G' % gigabytes | ||
| return '%.2f G' % gigabytes | ||
| elif bytes >= 1048576: | ||
| megabytes = bytes / 1048576 | ||
| size = '%.2f M' % megabytes | ||
| return '%.2f M' % megabytes | ||
| elif bytes >= 1024: | ||
| kilobytes = bytes / 1024 | ||
| size = '%.2f K' % kilobytes | ||
| return '%.2f K' % kilobytes | ||
| else: | ||
| size = '%d B' % int(bytes) | ||
| return size | ||
| return '%d B' % int(bytes) |
Author
There was a problem hiding this comment.
Function size_str refactored with the following changes:
- Lift return into if (
lift-return-into-if)
Comment on lines
-77
to
-81
| data = infile.read(CACHE_SIZE) | ||
| while data: | ||
| while data := infile.read(CACHE_SIZE): | ||
| sock.sendall(data) | ||
| data = infile.read(CACHE_SIZE) | ||
|
|
Author
There was a problem hiding this comment.
Function http_server refactored with the following changes:
- Remove unreachable except block (
remove-redundant-except-handler) - Use named expression to simplify assignment and conditional (
use-named-expression)
Comment on lines
-146
to
+138
| uri = first_line.split()[1] | ||
| return uri | ||
| return first_line.split()[1] |
Author
There was a problem hiding this comment.
Function parse_request refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
Comment on lines
-155
to
+153
| resp_list = [] | ||
| resp_list.append('HTTP/1.1 %s' % code) | ||
| resp_list.append('Content-Type: %s; char=utf-8' % mimetype) | ||
| resp_list.append('Content-Length: %s' % str(bytelen)) | ||
| resp_list.append('\r\n') | ||
| resp = '\r\n'.join(resp_list) | ||
| return resp | ||
| resp_list = [ | ||
| f'HTTP/1.1 {code}', | ||
| f'Content-Type: {mimetype}; char=utf-8', | ||
| f'Content-Length: {str(bytelen)}', | ||
| '\r\n', | ||
| ] | ||
|
|
||
| return '\r\n'.join(resp_list) |
Author
There was a problem hiding this comment.
Function build_header refactored with the following changes:
- Merge append into list declaration (
merge-list-append) - Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring) - Inline variable that is immediately returned (
inline-immediately-returned-variable)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Branch
masterrefactored 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
masterbranch, then run:Help us improve this pull request!