-
Notifications
You must be signed in to change notification settings - Fork 16
Sourcery Starbot ⭐ refactored xmonader/pygundb #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
base: development
Are you sure you want to change the base?
Conversation
ch = { | ||
return { | ||
SOUL: newuid(), | ||
'put': { | ||
soul: new_node(soul, **kwargs) | ||
} | ||
} | ||
return ch | ||
} |
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 format_put_request
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
ch = { | ||
return { | ||
SOUL: newuid(), | ||
'get': { | ||
SOUL: soul | ||
} | ||
} | ||
return ch | ||
} |
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 format_get_request
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
elif backend_db == "pickle": | ||
backend = Pickle() |
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 GunClient._init_backend
refactored with the following changes:
- Remove redundant conditional (
remove-redundant-if
)
elif backend_db == "pickle": | ||
backend = Pickle() |
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 GUNRequestHandler._init_backend
refactored with the following changes:
- Remove redundant conditional (
remove-redundant-if
)
# node with meta | ||
node = {METADATA: {SOUL: name, STATE: {k: get_current_state() for k in kwargs}}, **kwargs} | ||
return node | ||
return { | ||
METADATA: { | ||
SOUL: name, | ||
STATE: {k: get_current_state() for k in kwargs}, | ||
}, | ||
**kwargs, | ||
} |
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 new_node
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
This removes the following comments ( why? ):
# node with meta
else: | ||
if ( | ||
is_reference(val) and dfs(graph[val["#"]]) or not is_reference and dfs(val) | ||
): # The reference is found in this child | ||
return True | ||
if ( | ||
is_reference(val) and dfs(graph[val["#"]]) or not is_reference and dfs(val) | ||
): # The reference is found in this child | ||
return True |
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 search.dfs
refactored with the following changes:
- Remove unnecessary else after guard condition (
remove-unnecessary-else
)
if os.path.exists(path): | ||
self.db = dbm.open(path) | ||
else: | ||
self.db = dbm.open(path, "c") | ||
self.db = dbm.open(path) if os.path.exists(path) else dbm.open(path, "c") |
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 UDB.__init__
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
if not item in res: | ||
if item not in 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 uniquify
refactored with the following changes:
- Simplify logical expression using De Morgan identities (
de-morgan
)
res = {} | ||
for k, v in obj.items(): | ||
if k.startswith("list_"): | ||
res[k] = listify(fix_lists(v)) | ||
else: | ||
res[k] = fix_lists(v) | ||
return res | ||
return { | ||
k: listify(fix_lists(v)) if k.startswith("list_") else fix_lists(v) | ||
for k, v in obj.items() | ||
} |
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 fix_lists
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
) - Convert for loop into dictionary comprehension (
dict-comprehension
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
)
if isinstance(v, dict): | ||
res[k] = defaultify(v) | ||
else: | ||
res[k] = v | ||
res[k] = defaultify(v) if isinstance(v, dict) else v |
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 defaultify
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
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
development
branch, then run: