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

Update to Pyro v2 (Sourcery refactored) #7

Merged
merged 1 commit into from
Sep 20, 2022
Merged

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Sep 20, 2022

Pull Request #6 refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.

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 Pyro-v2 branch, then run:

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

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from Ryomen-Sukuna September 20, 2022 10:06
@sourcery-ai
Copy link
Author

sourcery-ai bot commented Sep 20, 2022

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 0.24%.

Quality metrics Before After Change
Complexity 5.49 ⭐ 5.38 ⭐ -0.11 👍
Method Length 90.67 🙂 90.56 🙂 -0.11 👍
Working memory 8.78 🙂 8.87 🙂 0.09 👎
Quality 63.25% 🙂 63.01% 🙂 -0.24% 👎
Other metrics Before After Change
Lines 601 603 2
Changed files Quality Before Quality After Quality Change
gdrive/helpers/downloader.py 75.99% ⭐ 74.32% 🙂 -1.67% 👎
gdrive/helpers/utils.py 83.20% ⭐ 83.20% ⭐ 0.00%
gdrive/helpers/gdrive_utils/gDrive.py 59.57% 🙂 59.73% 🙂 0.16% 👍
gdrive/helpers/sql_helper/gDriveDB.py 89.50% ⭐ 89.53% ⭐ 0.03% 👍
gdrive/helpers/sql_helper/idsDB.py 88.78% ⭐ 88.74% ⭐ -0.04% 👎
gdrive/plugins/copy.py 67.20% 🙂 67.20% 🙂 0.00%
gdrive/plugins/delete.py 58.55% 🙂 59.80% 🙂 1.25% 👍
gdrive/plugins/download.py 46.58% 😞 46.58% 😞 0.00%

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

File Function Complexity Length Working Memory Quality Recommendation
gdrive/plugins/download.py _download 10 🙂 284 ⛔ 10 😞 44.07% 😞 Try splitting into smaller methods. Extract out complex expressions
gdrive/plugins/download.py _telegram_file 5 ⭐ 229 ⛔ 14 😞 44.87% 😞 Try splitting into smaller methods. Extract out complex expressions
gdrive/helpers/gdrive_utils/gDrive.py GoogleDrive.checkFolderLink 10 🙂 176 😞 13 😞 45.47% 😞 Try splitting into smaller methods. Extract out complex expressions
gdrive/helpers/gdrive_utils/gDrive.py GoogleDrive.upload_file 10 🙂 234 ⛔ 10 😞 46.44% 😞 Try splitting into smaller methods. Extract out complex expressions
gdrive/helpers/gdrive_utils/gDrive.py GoogleDrive.delete_file 9 🙂 168 😞 11 😞 50.44% 🙂 Try splitting into smaller methods. Extract out complex expressions

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!

Comment on lines -44 to +64
for path in glob.glob(os.path.join(DOWNLOAD_DIRECTORY, "*")):
if path.endswith(
(
".avi",
".mov",
".flv",
".wmv",
".3gp",
".mpeg",
".webm",
".mp4",
".mkv",
return next(
(
(True, path)
for path in glob.glob(os.path.join(DOWNLOAD_DIRECTORY, "*"))
if path.endswith(
(
".avi",
".mov",
".flv",
".wmv",
".3gp",
".mpeg",
".webm",
".mp4",
".mkv",
)
)
) and path.startswith(ytdl.prepare_filename(meta)):
return True, path
return False, "Something went wrong! No video file exists on server."
and path.startswith(ytdl.prepare_filename(meta))
),
(False, "Something went wrong! No video file exists on server."),
)
Copy link
Author

Choose a reason for hiding this comment

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

Function utube_dl refactored with the following changes:

  • Use the built-in function next instead of a for-loop (use-next)

return str(round(size, 2)) + " " + dict_power_n[number] + "B"
return f"{str(round(size, 2))} {dict_power_n[number]}B"
Copy link
Author

Choose a reason for hiding this comment

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

Function humanbytes refactored with the following changes:

return res.group(5)
return res[5]
Copy link
Author

Choose a reason for hiding this comment

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

Function GoogleDrive.getIdFromUrl refactored with the following changes:

for file in response.get("files", []):
files.append(file)
files.extend(iter(response.get("files", [])))
Copy link
Author

Choose a reason for hiding this comment

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

Function GoogleDrive.getFilesByFolderId refactored with the following changes:

saved_cred = SESSION.query(gDriveCreds).get(chat_id)
if saved_cred:
if saved_cred := SESSION.query(gDriveCreds).get(chat_id):
Copy link
Author

Choose a reason for hiding this comment

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

Function _clear refactored with the following changes:

rem = SESSION.query(ParentID).get(chat_id)
if rem:
if rem := SESSION.query(ParentID).get(chat_id):
Copy link
Author

Choose a reason for hiding this comment

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

Function _clear refactored with the following changes:

Comment on lines -19 to +21
user_id = message.from_user.id
if len(message.command) > 1:
link = message.command[1]
user_id = message.from_user.id
Copy link
Author

Choose a reason for hiding this comment

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

Function _clone refactored with the following changes:

@@ -16,7 +16,6 @@
& CustomFilters.auth_users
)
def _delete(client: Client, message: Message):
user_id = message.from_user.id
Copy link
Author

Choose a reason for hiding this comment

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

Function _delete refactored with the following changes:

Comment on lines -108 to +111
user_id = message.from_user.id
if len(message.command) > 1:
sent_message = message.reply_text("🕵️**Checking Link...**", quote=True)
link = message.command[1]
user_id = message.from_user.id
Copy link
Author

Choose a reason for hiding this comment

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

Function _ytdl refactored with the following changes:

@Ryomen-Sukuna Ryomen-Sukuna merged commit a33c1ae into Pyro-v2 Sep 20, 2022
@Ryomen-Sukuna Ryomen-Sukuna deleted the sourcery/Pyro-v2 branch September 20, 2022 10:11
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.

1 participant