-
Notifications
You must be signed in to change notification settings - Fork 0
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 #1
base: master
Are you sure you want to change the base?
Conversation
return "".join(random.choice("0123456789abcdef") for i in range(length)) | ||
return "".join(random.choice("0123456789abcdef") for _ in range(length)) |
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 getRanHex
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
)
if response.status_code != 200: | ||
print(f"Status code: {response.status_code}") | ||
print(response.text) | ||
print(response.url) | ||
raise Exception("Authentication failed") | ||
if response.status_code != 200: | ||
print(f"Status code: {response.status_code}") | ||
print(response.text) | ||
print(response.url) | ||
raise Exception("Authentication failed") |
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 Conversation.__init__
refactored with the following changes:
- Hoist conditional out of nested conditional (
hoist-if-from-if
)
if self.wss: | ||
if not self.wss.closed: | ||
await self.wss.close() | ||
if self.wss and not self.wss.closed: | ||
await self.wss.close() |
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 ChatHub.ask_stream
refactored with the following changes:
- Merge nested if conditions (
merge-nested-ifs
)
if not args.enter_once: | ||
question = await get_input_async(session=session) | ||
else: | ||
question = input() | ||
question = ( | ||
input() | ||
if args.enter_once | ||
else await get_input_async(session=session) | ||
) |
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 main
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
) - Hoist repeated code outside conditional statement (
hoist-statement-from-if
) - Swap if/else branches of if expression to remove negation (
swap-if-expression
)
if response.text == "": | ||
time.sleep(1) | ||
continue | ||
else: | ||
if response.text != "": | ||
break | ||
|
||
time.sleep(1) | ||
continue | ||
# Use regex to search for src="" | ||
image_links = regex.findall(r'src="([^"]+)"', response.text) | ||
# Remove size limit | ||
normal_image_links = [link.split("?w=")[0] for link in image_links] | ||
# Remove duplicates | ||
normal_image_links = list(set(normal_image_links)) | ||
|
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 ImageGen.get_images
refactored with the following changes:
- Swap if/else branches (
swap-if-else-branches
) - 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.88%.
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!