-
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
if (msg == constants.UCM_NEEDPASSWORD or | ||
msg == constants.UCM_NEEDPASSWORDW): | ||
if msg in [constants.UCM_NEEDPASSWORD, constants.UCM_NEEDPASSWORDW]: |
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 _ReadIntoMemory._callback
refactored with the following changes:
- Replace multiple comparisons of same variable with
in
operator (merge-comparisons
)
rarinfo = self._read_header(handle) | ||
while rarinfo: | ||
while rarinfo := self._read_header(handle): | ||
self.filelist.append(rarinfo) | ||
self.NameToInfo[rarinfo.filename] = rarinfo | ||
self._process_current(handle, constants.RAR_SKIP) | ||
rarinfo = self._read_header(handle) |
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 RarFile._load_metadata
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
raise BadRarFile("Bad RAR archive data: %s" % str(e)) | ||
raise BadRarFile(f"Bad RAR archive data: {str(e)}") |
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 RarFile.open
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
names = [] | ||
for member in self.filelist: | ||
names.append(member.filename) | ||
return names | ||
return [member.filename for member in self.filelist] |
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 RarFile.namelist
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
)
raise BadRarFile("Bad RAR archive data: %s" % str(e)) | ||
raise BadRarFile(f"Bad RAR archive data: {str(e)}") |
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 RarFile._extract_members
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
err = rf.testrar() | ||
if err: | ||
if err := rf.testrar(): |
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:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
lib_path = lib_path or find_library("unrar.dll") | ||
if lib_path: | ||
if lib_path := lib_path or find_library("unrar.dll"): |
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 44-67
refactored with the following changes:
- Use named expression to simplify assignment and conditional [×2] (
use-named-expression
) - Replace call to format with f-string (
use-fstring-for-formatting
)
res.append('%s=%s' % (field[0], field_value)) | ||
return self.__class__.__name__ + '(' + ','.join(res) + ')' | ||
res.append(f'{field[0]}={field_value}') | ||
return f'{self.__class__.__name__}(' + ','.join(res) + ')' |
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 _Structure.__repr__
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
)
rar = RarFile(rar_filename) | ||
return rar | ||
return RarFile(rar_filename) |
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 TestRarFile._open_rarfile
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
rar = RarFile(rar_filename, pwd='password') | ||
return rar | ||
return RarFile(rar_filename, pwd='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.
Function TestPasswordRarFile._open_rarfile
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
Sourcery Code Quality Report❌ Merging this PR will decrease code quality in the affected files by 0.19%.
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!