Skip to content

Sourcery refactored master branch#1

Open
sourcery-ai[bot] wants to merge 1 commit into
masterfrom
sourcery/master
Open

Sourcery refactored master branch#1
sourcery-ai[bot] wants to merge 1 commit into
masterfrom
sourcery/master

Conversation

@sourcery-ai
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot commented Dec 1, 2021

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:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai Bot requested a review from MattFisher December 1, 2021 02:14
Comment thread .update/do.py
for x in tree['contents']:
for y in flatten_tree(x):
yield y
yield from flatten_tree(x)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function flatten_tree refactored with the following changes:

  • Replace yield inside for loop with yield from (yield-from)

Comment thread .update/do.py
Comment on lines -42 to +44
if 'contents' in tree:
x = tree['contents'][0]
return first_leaf(x)
else:
if 'contents' not in tree:
return tree
x = tree['contents'][0]
return first_leaf(x)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function first_leaf refactored with the following changes:

Comment thread .update/do.py
Comment on lines -49 to +47
if page is None:
uri = f'/books/{book}'
else:
uri = f'/books/{book}/pages/{page}'
return uri
return f'/books/{book}' if page is None else f'/books/{book}/pages/{page}'
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function rex_uri refactored with the following changes:

Comment thread .update/do.py
Comment on lines -57 to +55
if page is None:
uri_regex = f"/contents/({book['id']}|{book['short_id']})(@[.\d]+)?(/[-%\w\d]+)?$"
else:
uri_regex = f"/contents/({book['id']}|{book['short_id']})(@[.\d]+)?:({page['id']}|{page['short_id']})(@[.\d]+)?(/[-%\w\d]+)?$"
return uri_regex
return (
f"/contents/({book['id']}|{book['short_id']})(@[.\d]+)?(/[-%\w\d]+)?$"
if page is None
else f"/contents/({book['id']}|{book['short_id']})(@[.\d]+)?:({page['id']}|{page['short_id']})(@[.\d]+)?(/[-%\w\d]+)?$"
)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function cnx_uri_regex refactored with the following changes:

class CalledProcessError(Exception):
pass
if not res == 0:
if res != 0:
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _check_call_py24 refactored with the following changes:

  • Simplify logical expression using De Morgan identities (de-morgan)

Comment on lines -186 to +188
try:
subprocess.check_call(cmd, stdout=devnull, stderr=devnull)
except:
return False
subprocess.check_call(cmd, stdout=devnull, stderr=devnull)
except:
return False
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function has_powershell refactored with the following changes:

Comment on lines -204 to +205
try:
subprocess.check_call(cmd, stdout=devnull, stderr=devnull)
except:
return False
subprocess.check_call(cmd, stdout=devnull, stderr=devnull)
except:
return False
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function has_curl refactored with the following changes:

return False
subprocess.check_call(cmd, stdout=devnull, stderr=devnull)
except:
return False
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function has_wget refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants