Conversation
| def get_emails(self): | ||
| uids = self.mail.uid('SEARCH', 'ALL')[1][0].split() | ||
| return uids | ||
| return self.mail.uid('SEARCH', 'ALL')[1][0].split() |
There was a problem hiding this comment.
Function EmailHelper.get_emails refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| email_message = email.message_from_string(raw_email_string) | ||
| return email_message | ||
| return email.message_from_string(raw_email_string) |
There was a problem hiding this comment.
Function EmailHelper.get_email_message refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| filename = uid.decode() + ".jpg" | ||
| filename = f"{uid.decode()}.jpg" | ||
| img_path = html_to_img_convertor.save_img( | ||
| html.encode(), output_dir, filename) | ||
| print(img_path) | ||
|
|
||
| filename = uid.decode() + ".pdf" | ||
| filename = f"{uid.decode()}.pdf" |
There was a problem hiding this comment.
Lines 48-53 refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation)
| header_info = header_info + '<b>' + header + '</b>: '\ | ||
| + decoded_string + '<br/>' | ||
| header_info = f'{header_info}<b>{header}</b>: {decoded_string}<br/>' | ||
|
|
||
| return header_info + '<br/>' | ||
| return f'{header_info}<br/>' |
There was a problem hiding this comment.
Function EmailtoHtml.__get_formatted_header_info refactored with the following changes:
- Use f-string instead of string concatenation [×6] (
use-fstring-for-concatenation)
| hdr = "" | ||
| for element in decoded_header: | ||
| if isinstance(element[0], bytes): | ||
| hdr += str(element[0], element[1] or 'ASCII') | ||
| else: | ||
| hdr += element[0] | ||
| return hdr | ||
| return "".join( | ||
| str(element[0], element[1] or 'ASCII') | ||
| if isinstance(element[0], bytes) | ||
| else element[0] | ||
| for element in decoded_header | ||
| ) |
There was a problem hiding this comment.
Function EmailtoHtml.__get_utf8_header refactored with the following changes:
- Use str.join() instead of for loop (
use-join) - Replace if statement with if expression (
assign-if-exp) - Inline variable that is immediately returned (
inline-immediately-returned-variable)
| filename = "%s_%s%s" % (file_name_parts[0], | ||
| '_' + str(counter), | ||
| file_name_parts[1]) | ||
| filename = f"{file_name_parts[0]}__{str(counter)}{file_name_parts[1]}" |
There was a problem hiding this comment.
Function HtmltoImage.__get_unique_version refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring) - Use f-string instead of string concatenation (
use-fstring-for-concatenation) - Simplify unnecessary nesting, casting and constant values in f-strings (
simplify-fstring-formatting)
| if ret_code > 0 and original_error == '': | ||
| if ret_code > 0 and not original_error: |
There was a problem hiding this comment.
Function HtmltoImage.__process_errors refactored with the following changes:
- Replaces an empty collection equality with a boolean operation (
simplify-empty-collection-comparison)
| filename = "%s_%s%s" % (file_name_parts[0], | ||
| '_' + str(counter), | ||
| file_name_parts[1]) | ||
| filename = f"{file_name_parts[0]}__{str(counter)}{file_name_parts[1]}" |
There was a problem hiding this comment.
Function HtmltoPdf.__get_unique_version refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring) - Use f-string instead of string concatenation (
use-fstring-for-concatenation) - Simplify unnecessary nesting, casting and constant values in f-strings (
simplify-fstring-formatting)
| if ret_code > 0 and original_error == '': | ||
| if ret_code > 0 and not original_error: |
There was a problem hiding this comment.
Function HtmltoPdf.__process_errors refactored with the following changes:
- Replaces an empty collection equality with a boolean operation (
simplify-empty-collection-comparison)
| except HTTPError: | ||
| except (HTTPError, URLError, ValueError): | ||
| return False | ||
| except URLError: | ||
| return False | ||
| except ValueError: | ||
| return False | ||
|
|
There was a problem hiding this comment.
Function can_url_fetch refactored with the following changes:
- Merge except handlers with identical code blocks [×2] (
merge-except-handler)
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!