-
Notifications
You must be signed in to change notification settings - Fork 0
Sourcery refactored master branch #1
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
base: master
Are you sure you want to change the base?
Conversation
|
keywords = {} | ||
for keyword in suite.resource.keywords: | ||
keywords[keyword.name] = keyword | ||
keywords = {keyword.name: keyword for keyword in suite.resource.keywords} | ||
suite.resource.keywords._items = list(keywords.values()) | ||
|
||
# Strip duplicate variables | ||
variables = {} | ||
for variable in suite.resource.variables: | ||
variables[variable.name] = variable | ||
variables = {variable.name: variable for variable in suite.resource.variables} |
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_suite
refactored with the following changes:
- Convert for loop into dictionary comprehension (
dict-comprehension
)
matches = [] | ||
|
||
for lib in list(STDLIBS) + list(get_root_modules()): | ||
if needle in lib.lower(): | ||
matches.append(lib) | ||
|
||
return matches | ||
return [ | ||
lib | ||
for lib in list(STDLIBS) + list(get_root_modules()) | ||
if needle in lib.lower() | ||
] |
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 complete_libraries
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
)
header = rpa and "Tasks" or "Test Cases" | ||
header = "Tasks" if rpa else "Test Cases" |
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 execute_python.execute_ipywidget
refactored with the following changes:
- Replace boolean ternary with inline if expression (
ternary-to-if-expression
)
remained = [] | ||
for driver in drivers: | ||
if driver.get("type") != type_: | ||
remained.append(driver) | ||
remained = [driver for driver in drivers if driver.get("type") != type_] |
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 clear_drivers
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
)
aliases = [] | ||
for alias, idx_ in cache._aliases.items(): | ||
if (idx + 1) == idx_: | ||
aliases.append(alias) | ||
aliases = [ | ||
alias | ||
for alias, idx_ in cache._aliases.items() | ||
if (idx + 1) == idx_ | ||
] | ||
|
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 get_webdrivers
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
)
results = [] | ||
matches = [] | ||
unresolved = [] | ||
if needle: | ||
results = driver.find_elements_by_xpath(needle) | ||
results = driver.find_elements_by_xpath(needle) if needle 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 get_selenium_xpath_selector_completions
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
if as_bytes: | ||
fp = MemoryStream() | ||
screenshot.Save(fp, ImageFormat.Png) | ||
return bytes(bytearray(fp.ToArray())) | ||
else: | ||
if not as_bytes: | ||
return screenshot | ||
fp = MemoryStream() | ||
screenshot.Save(fp, ImageFormat.Png) | ||
return bytes(bytearray(fp.ToArray())) |
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 PickSnipTool.take_screenshot
refactored with the following changes:
- Swap if/else branches (
swap-if-else-branches
) - Remove unnecessary else after guard condition (
remove-unnecessary-else
)
if s and not s.startswith("*") and not s.startswith("["): | ||
if s.count("."): | ||
library, name = s.rsplit(".", 1) | ||
return library + "." + name[0].title() + name[1:].lower() | ||
else: | ||
return s[0].title() + s[1:].lower() | ||
else: | ||
if not s or s.startswith("*") or s.startswith("["): | ||
return s | ||
if not s.count("."): | ||
return s[0].title() + s[1:].lower() | ||
library, name = s.rsplit(".", 1) | ||
return library + "." + name[0].title() + name[1:].lower() |
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 readable_keyword
refactored with the following changes:
- Swap if/else branches (
swap-if-else-branches
) - Remove unnecessary else after guard condition (
remove-unnecessary-else
)
context_name = context_parts[1].strip().lower() | ||
if context_name == "settings": | ||
return "__settings__" | ||
elif line.lstrip() == line: | ||
return "__root__" | ||
elif context_name in ["tasks", "test cases"]: | ||
return "__tasks__" | ||
elif context_name == "keywords": | ||
return "__keywords__" | ||
else: | ||
context_name = context_parts[1].strip().lower() | ||
if context_name == "settings": | ||
return "__settings__" | ||
elif line.lstrip() == line: | ||
return "__root__" | ||
elif context_name in ["tasks", "test cases"]: | ||
return "__tasks__" | ||
elif context_name == "keywords": | ||
return "__keywords__" | ||
else: | ||
return "__root__" | ||
return "__root__" |
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 detect_robot_context
refactored with the following changes:
- Remove unnecessary else after guard condition (
remove-unnecessary-else
)
else: | ||
data, metadata = JSON(data=obj, expanded=True)._repr_json_() | ||
return ( | ||
{"application/json": data, "text/html": f"<pre>{to_html(obj)}</pre>"}, | ||
metadata, | ||
) | ||
data, metadata = JSON(data=obj, expanded=True)._repr_json_() | ||
return ( | ||
{"application/json": data, "text/html": f"<pre>{to_html(obj)}</pre>"}, | ||
metadata, | ||
) |
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 to_mime_and_metadata
refactored with the following changes:
- Remove unnecessary else after guard condition (
remove-unnecessary-else
)
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.30%.
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!