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 main branch #4
Conversation
15ed08b
to
ffcfb60
Compare
ffcfb60
to
be4bda5
Compare
HELP_DICT = dict() | ||
HELP_DICT = {} |
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 17-87
refactored with the following changes:
- Replace dict() with {} (
dict-literal
)
if not len(query)==2: | ||
if len(query) != 2: |
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 flex_cmd
refactored with the following changes:
- Simplify logical expression using De Morgan identities (
de-morgan
)
if spoiler==False: | ||
if not spoiler: |
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 additional_info_btn
refactored with the following changes:
- Simplify comparison to boolean (
simplify-boolean-comparison
)
if result[0]==False: | ||
await cq.answer("No Data Available!!!") | ||
return | ||
if result[0]==False: | ||
await cq.answer("No Data Available!!!") | ||
return |
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 featured_in_btn
refactored with the following changes:
- Hoist conditional out of nested conditional (
hoist-if-from-if
)
if find_gc==None: | ||
if find_gc 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 list_disabled
refactored with the following changes:
- Use x is None rather than x == None (
none-compare
)
if auth is True: | ||
if auth: |
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_anime
refactored with the following changes:
- Merge duplicate blocks in conditional (
merge-duplicate-blocks
) - Simplify comparison to boolean (
simplify-boolean-comparison
) - Simplify sequence comparison (
simplify-len-comparison
)
if auth is True: | ||
if auth: |
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_anilist
refactored with the following changes:
- Merge duplicate blocks in conditional (
merge-duplicate-blocks
) - Simplify comparison to boolean (
simplify-boolean-comparison
) - Simplify sequence comparison (
simplify-len-comparison
)
if auth is True: | ||
if auth: |
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_manga
refactored with the following changes:
- Simplify comparison to boolean (
simplify-boolean-comparison
)
if auth is True: | ||
if auth: |
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_airing
refactored with the following changes:
- Simplify comparison to boolean (
simplify-boolean-comparison
)
k = await return_json_senpai(query=query, vars=vars_, auth=False if "user" in req else True, user=int(user)) | ||
k = await return_json_senpai( | ||
query=query, vars=vars_, auth="user" not in req, user=int(user) | ||
) | ||
|
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_user
refactored with the following changes:
- Simplify boolean if expression (
boolean-if-exp-identity
) - Simplify logical expression using De Morgan identities (
de-morgan
)
out = [] | ||
for i in data: | ||
out.append(f"{i['index']}. `{i['name']}`\n") | ||
out = [f"{i['index']}. `{i['name']}`\n" for i in data] |
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_wo
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
)
ret = {} | ||
keys = list(index.keys()) | ||
for i in range(len(keys)): | ||
if query.lower() in keys[i].lower(): | ||
ret[keys[i]] = index[keys[i]] | ||
return ret | ||
return { | ||
keys[i]: index[keys[i]] | ||
for i in range(len(keys)) | ||
if query.lower() in keys[i].lower() | ||
} |
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 search_filler
refactored with the following changes:
- Convert for loop into dictionary comprehension (
dict-comprehension
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
)
total_ep = [] | ||
mix_ep = None | ||
filler_ep = None | ||
ac_ep = None | ||
for tol in ttl_ep: | ||
total_ep.append(tol.text) | ||
total_ep = [tol.text for tol in ttl_ep] |
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 parse_filler
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
)
if auth == False: | ||
if not auth: | ||
url = "https://graphql.anilist.co" | ||
response = requests.post(url, json={"query": query, "variables": vars}).json() | ||
return requests.post(url, json={"query": query, "variables": vars}).json() |
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 return_json_senpai
refactored with the following changes:
- Simplify comparison to boolean (
simplify-boolean-comparison
) - Lift return into if (
lift-return-into-if
)
th = "st" if x == "1" else "nd" if x == "2" else "rd" if x == "3" else "th" | ||
return th | ||
return "st" if x == "1" else "nd" if x == "2" else "rd" if x == "3" else "th" |
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 pos_no
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
if result[0]!=0 and result[0]!=6: | ||
if result[0] not in [0, 6]: |
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_btns
refactored with the following changes:
- Replace multiple comparisons of same variable with
in
operator (merge-comparisons
) - Simplify comparison to boolean (
simplify-boolean-comparison
) - Merge else clause's nested if statement into elif (
merge-else-if-into-elif
)
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.92%.
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
main
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
main
branch, then run:Help us improve this pull request!