-
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
sys.path.append(os.getcwd()+"/.lib/") | ||
sys.path.append(f"{os.getcwd()}/.lib/") |
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.
Lines 4-12
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
resp_js = session.get('https://www.instagram.com/'+usrname+'/?__a=1').text | ||
resp_js = session.get(f'https://www.instagram.com/{usrname}/?__a=1').text |
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 get_page
refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
if xdict != {}: | ||
print(f"{su} {re}most used %s :" % text) | ||
i = 0 | ||
for key, val in xdict.items(): | ||
if len(mail) == 1: | ||
if key in mail[0]: | ||
continue | ||
print(f" {gr}%s : {wh}%s" % (key, val)) | ||
i += 1 | ||
if i > 4: | ||
break | ||
print() | ||
else: | ||
pass | ||
|
||
if xdict == {}: | ||
return | ||
print(f"{su} {re}most used %s :" % text) | ||
i = 0 | ||
for key, val in xdict.items(): | ||
if len(mail) == 1 and key in mail[0]: | ||
continue | ||
print(f" {gr}%s : {wh}%s" % (key, val)) | ||
i += 1 | ||
if i > 4: | ||
break | ||
print() | ||
|
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 exinfo
refactored with the following changes:
- Add guard clause (
last-if-guard
) - Merge nested if conditions (
merge-nested-ifs
) - Remove redundant pass statement (
remove-redundant-pass
)
|
||
resp_js = get_page(usrname) | ||
js = json.loads(resp_js) | ||
js = js['graphql']['user'] | ||
|
||
if js['is_private'] != False: | ||
is_private = True | ||
|
||
if js['edge_owner_to_timeline_media']['count'] > 12: | ||
pass | ||
else: | ||
|
||
if js['edge_owner_to_timeline_media']['count'] <= 12: |
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 user_info
refactored with the following changes:
- Swap if/else to remove empty if body (
remove-pass-body
)
@@ -112,7 +108,6 @@ def user_info(usrname): | |||
|
|||
def highlight_post_info(i): | |||
|
|||
postinfo = {} |
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 highlight_post_info
refactored with the following changes:
- Merge dictionary assignment with declaration [×2] (
merge-dict-assign
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
) - Move assignment closer to its usage within a block (
move-assign-in-block
) - Hoist repeated code outside conditional statement [×2] (
hoist-statement-from-if
)
|
||
posts = [] | ||
|
||
for x in range(total_uploads): | ||
posts.append(highlight_post_info(x)) | ||
|
||
posts = [highlight_post_info(x) for x in range(total_uploads)] |
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 post_info
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
)
if match == None: | ||
if match is None: |
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 validate_mail
refactored with the following changes:
- Use x is None rather than x == None (
none-compare
)
data = requests.get("http://tinyurl.com/api-create.php?url=" + url) | ||
data = requests.get(f"http://tinyurl.com/api-create.php?url={url}") |
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 urlshortner
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
output = {k: v for k, v in sorted(with_count.items(), reverse=True, key=lambda item: item[1])} | ||
return output | ||
return dict(sorted(with_count.items(), reverse=True, key=lambda item: item[1])) |
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 sort_list
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
) - Replace identity comprehension with call to collection constructor (
identity-comprehension
)
exinfo = {} | ||
email = r.findall(r"[_a-z0-9-\.]+[@@]{1}[a-z0-9]+\.[a-z0-9]+", stri.lower()) | ||
exinfo['email'] = email | ||
|
||
exinfo = {'email': email} |
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 find
refactored with the following changes:
- Move assignment closer to its usage within a block (
move-assign-in-block
) - Merge dictionary assignment with declaration (
merge-dict-assign
)
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 2.49%.
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!