Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Mar 30, 2023

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 WildGenie March 30, 2023 07:48
return "".join(random.choice("0123456789abcdef") for i in range(length))
return "".join(random.choice("0123456789abcdef") for _ in range(length))
Copy link
Author

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:

Comment on lines -243 to +247
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")
Copy link
Author

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:

Comment on lines -283 to +284
if self.wss:
if not self.wss.closed:
await self.wss.close()
if self.wss and not self.wss.closed:
await self.wss.close()
Copy link
Author

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:

Comment on lines -420 to +423
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)
)
Copy link
Author

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:

Comment on lines -65 to +76
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))

Copy link
Author

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:

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Mar 30, 2023

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 0.88%.

Quality metrics Before After Change
Complexity 12.70 🙂 11.86 🙂 -0.84 👍
Method Length 91.42 🙂 91.17 🙂 -0.25 👍
Working memory 8.81 🙂 8.74 🙂 -0.07 👍
Quality 55.29% 🙂 56.17% 🙂 0.88% 👍
Other metrics Before After Change
Lines 617 615 -2
Changed files Quality Before Quality After Quality Change
src/EdgeGPT.py 54.43% 🙂 55.52% 🙂 1.09% 👍
src/ImageGen.py 57.09% 🙂 57.51% 🙂 0.42% 👍

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
src/EdgeGPT.py main 38 ⛔ 251 ⛔ 13 😞 22.88% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
src/EdgeGPT.py ChatHub.ask_stream 15 🙂 193 😞 12 😞 41.26% 😞 Try splitting into smaller methods. Extract out complex expressions
src/ImageGen.py ImageGen.get_images 14 🙂 265 ⛔ 9 🙂 43.39% 😞 Try splitting into smaller methods
src/EdgeGPT.py Conversation.__init__ 10 🙂 218 ⛔ 12 😞 43.80% 😞 Try splitting into smaller methods. Extract out complex expressions
src/EdgeGPT.py ChatHubRequest.update 4 ⭐ 121 😞 8 🙂 66.55% 🙂 Try splitting into smaller methods

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
0 participants