-
Notifications
You must be signed in to change notification settings - Fork 35
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 #206
Conversation
be1896c
to
36992d5
Compare
if "FALSE" in suppress.upper(): | ||
self.suppress_warnings = False | ||
else: | ||
self.suppress_warnings = True | ||
self.suppress_warnings = "FALSE" not in suppress.upper() |
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 APILibrary.suppress_insecure_request_warnings
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
) - Simplify boolean if expression (
boolean-if-exp-identity
)
elif isinstance(number_of_items, int): | ||
pass | ||
else: | ||
elif not isinstance(number_of_items, int): |
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 APILibrary.validate_response_contains_correct_number_of_items
refactored with the following changes:
- Remove empty elif clause (
remove-pass-elif
)
new_response = {} | ||
for item in dir(response): | ||
if item[0] != '_': | ||
new_response[item] = getattr(response, item) | ||
new_response = { | ||
item: getattr(response, item) | ||
for item in dir(response) | ||
if item[0] != '_' | ||
} | ||
|
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 _convert_resp_to_dict
refactored with the following changes:
- Convert for loop into dictionary comprehension (
dict-comprehension
)
stdout = open(os.devnull, 'w') | ||
self.process = subprocess.Popen([path], stdout=stdout) | ||
stdout.close() | ||
with open(os.devnull, 'w') as stdout: | ||
self.process = subprocess.Popen([path], stdout=stdout) |
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 WinAppDriver.set_up_driver
refactored with the following changes:
- Use
with
when opening file to ensure closure (ensure-file-closed
)
self._wait_until_page_contains_element(each, self.get_appium_timeout()) | ||
if count == 0: | ||
self._wait_until_page_contains_element(each, self.get_appium_timeout()) | ||
self.mouse_over_and_context_click_element(each) | ||
else: | ||
self._wait_until_page_contains_element(each, self.get_appium_timeout()) |
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 DesktopLibrary.select_elements_from_context_menu
refactored with the following changes:
- Hoist repeated code outside conditional statement (
hoist-statement-from-if
)
for x in range(swipe_count): | ||
for _ in range(swipe_count): |
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 MobileLibrary.scroll_up_to_text
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
)
for x in range(number_of_types): | ||
for _ in range(number_of_types): |
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 _ObjectNamespacePlugin.loaded
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
)
response = suds_library.call_soap_method(action, *soap_object) | ||
return response | ||
return suds_library.call_soap_method(action, *soap_object) |
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 SOAPLibrary.call_soap_method_with_list_object
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
for index in range(len(response_dictionary)): | ||
for _ in range(len(response_dictionary)): |
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 _build_dict_from_response
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
)
if encode: | ||
self._myData = base64.b64decode(data) | ||
else: | ||
self._myData = data | ||
self._myData = base64.b64decode(data) if encode else data |
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 WebdriverRemoteMock.push_file
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
Sourcery Code Quality Report❌ Merging this PR will decrease code quality in the affected files by 0.12%.
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! |
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.
Tested this out locally with the sample files and everything seems to be good. Each refactor made sense after reading through it. Coverage still at 100%.
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.
WHAT SORCERY IS THIS :D
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!