-
Notifications
You must be signed in to change notification settings - Fork 3
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 Starbot ⭐ refactored lewoudar/scalpel #19
base: master
Are you sure you want to change the base?
Conversation
return tuple([int(i) for i in __version__.split('.')]) | ||
return tuple(int(i) for i in __version__.split('.')) |
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 version_info
refactored with the following changes:
- Replace unneeded comprehension with generator (
comprehension-to-generator
)
error_message = '' | ||
if ur.scheme == 'file': | ||
error_message = f'unable to open file {url}' | ||
|
||
error_message = f'unable to open file {url}' if ur.scheme == 'file' else '' |
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 SeleniumSpider._handle_url
refactored with the following changes:
- Move setting of default value for variable into
else
branch (introduce-default-else
) - Replace if statement with if expression (
assign-if-exp
)
if filename in ['chromedriver', 'geckodriver']: | ||
if filename in {'chromedriver', 'geckodriver'}: |
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 check_driver_presence
refactored with the following changes:
- Use set when checking membership of a collection of literals (
collection-into-set
)
callables = [] | ||
for str_callable in str_callable_list: | ||
callables.append(get_callable_from_string(str_callable)) | ||
|
||
callables = [ | ||
get_callable_from_string(str_callable) | ||
for str_callable in str_callable_list | ||
] |
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 callable_list_converter
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
)
if isinstance(value, Path): | ||
return str(value.absolute()) | ||
return str(value) | ||
return str(value.absolute()) if isinstance(value, Path) else str(value) |
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 str_converter
refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else
) - Replace if statement with if expression (
assign-if-exp
)
assert [content] == [item for item in read_mp(mp_file)] | ||
assert [content] == list(read_mp(mp_file)) |
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 TestWriteMp.test_should_write_bytes_when_giving_content_in_write_mode_without_custom_encoder
refactored with the following changes:
- Replace identity comprehension with call to collection constructor (
identity-comprehension
)
assert [content] == [item for item in read_mp(mp_file, decoder=decode_datetime)] | ||
assert [content] == list(read_mp(mp_file, decoder=decode_datetime)) |
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 TestWriteMp.test_should_write_bytes_when_giving_content_in_write_mode_with_custom_encoder
refactored with the following changes:
- Replace identity comprehension with call to collection constructor (
identity-comprehension
)
assert content == [item for item in read_mp(mp_file)] | ||
assert content == list(read_mp(mp_file)) |
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 TestWriteMp.test_should_write_bytes_when_giving_content_in_append_mode_without_custom_encoder
refactored with the following changes:
- Replace identity comprehension with call to collection constructor (
identity-comprehension
)
assert content == [item for item in read_mp(mp_file, decoder=decode_datetime)] | ||
assert content == list(read_mp(mp_file, decoder=decode_datetime)) |
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 TestWriteMp.test_should_write_bytes_when_giving_content_in_append_mode_with_custom_encoder
refactored with the following changes:
- Replace identity comprehension with call to collection constructor (
identity-comprehension
)
assert [fruit_1, fruit_2] == [item for item in read_mp(f'{backup.resolve()}')] | ||
assert [fruit_1, fruit_2] == list(read_mp(f'{backup.resolve()}')) |
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 TestStaticSpider.test_should_save_content_to_backup_file
refactored with the following changes:
- Replace identity comprehension with call to collection constructor (
identity-comprehension
)
assert [] == [line for line in async_file] | ||
assert [] == list(async_file) |
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 TestAsyncFile.test_iter_method_is_implemented
refactored with the following changes:
- Replace identity comprehension with call to collection constructor (
identity-comprehension
)
for line in f: | ||
result.append(line) | ||
|
||
result.extend(iter(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.
Function TestOpenFile.test_open_file_works_as_expected
refactored with the following changes:
- Replace a for append loop with list extend (
for-append-to-extend
) - Simplify generator expression (
simplify-generator
)
Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨
Here's your pull request refactoring your most popular Python repo.
If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.
Review changes via command line
To manually merge these changes, make sure you're on the
master
branch, then run: