-
Notifications
You must be signed in to change notification settings - Fork 3
Sourcery refactored master branch #5
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
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.
Looks good. Worth considering though. View full project report here.
| def sort_matrix(M): | ||
| result = sorted(M, key=lambda matrix_row: sum(matrix_row)) | ||
| return result | ||
| return sorted(M, key=lambda matrix_row: sum(matrix_row)) |
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.
| return sorted(M, key=lambda matrix_row: sum(matrix_row)) | |
| return sorted(M, key=sum) |
Avoid unnecessarily wrapping sum in a lambda. More details.
| print(f.read()) | ||
| f.close() | ||
|
|
||
| with open('exercises.txt', 'a') as f: |
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.
| with open('exercises.txt', 'a') as f: | |
| with open('exercises.txt', 'a', encoding='utf_8') as f: |
UnicodeEncodeError can occur if the text being written to the file contain characters not compatible with the OS's default text encoding because encoding is not set. More info.
| print(read_data) | ||
| print(f.closed) | ||
| f.close() | ||
| with open('exercises.txt') as f: |
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.
UnicodeDecodeError can occur if the content of the file has characters incompatible with the OS's default encoding. Python uses the OS's default text encoding on the content because encoding is not set. More details.
| print(f.readline()) | ||
| f.close() | ||
|
|
||
| with open('exercises.txt') as f: |
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.
Similarly, Set the encoding.
| f1 = open('exercises.txt', 'a') | ||
| f1.write(f.read()) | ||
| f.close() | ||
| with open('list-to-file.txt') as f: |
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.
Similarly, Set the encoding.
| f1.write(f.read()) | ||
| f.close() | ||
| with open('list-to-file.txt') as f: | ||
| f1 = open('exercises.txt', 'a') |
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.
| f1 = open('exercises.txt', 'a') | |
| f1 = open('exercises.txt', 'a', encoding='utf_8') |
Same as above: Set the encoding.
| for letter in string.ascii_uppercase: | ||
| with open(letter + ".txt", "w") as f: | ||
| f.writelines(letter) | ||
| with open(f"{letter}.txt", "w") as f: |
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.
| with open(f"{letter}.txt", "w") as f: | |
| with open(f"{letter}.txt", "w", encoding="utf_8") as f: |
Same as above: Set the encoding.
| f = open(filename, 'r') | ||
| text = f.read() | ||
| f.close() | ||
| with open(filename, 'r') as f: |
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.
UnicodeDecodeError can occur if the content of the file has characters incompatible with the OS's default encoding. Python uses the OS's default text encoding on the content because encoding is not set. More details.
| print("{:<5}{:<15}: {:<90}: {}, {}\n ".format(str(i)+')',hacks_final_date, hacks_name.title(), hacks_city, hacks_country)) | ||
|
|
||
| print( | ||
| "{:<5}{:<15}: {:<90}: {}, {}\n ".format( |
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.
f-string is easier to read, write, and less computationally expensive than legacy string formatting. Read more.
Co-authored-by: code-review-doctor[bot] <72320148+code-review-doctor[bot]@users.noreply.github.com>
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.18%.
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
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!