-
Notifications
You must be signed in to change notification settings - Fork 3
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 #3
base: master
Are you sure you want to change the base?
Conversation
|
||
|
||
] | ||
|
||
|
||
render = web.template.render(pth+'templ/',cache=True) | ||
render = web.template.render(f'{pth}templ/', cache=True) |
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 47-52
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
web.header('Access-Control-Allow-Origin', '*') | ||
web.header('Access-Control-Allow-Origin', '*') | ||
i=web.input() | ||
l=insta.login(i.login,i.passw) | ||
if l: | ||
if l := insta.login(i.login, i.passw): |
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 login.POST
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
d={} | ||
d['likes']=likes | ||
d['all']=len(likes) | ||
d['names']=names | ||
d['texts']=texts | ||
d['lids']=lids | ||
d['ulikes']=ulikes | ||
d['dates']=dates | ||
|
||
d = { | ||
'likes': likes, | ||
'all': len(likes), | ||
'names': names, | ||
'texts': texts, | ||
'lids': lids, | ||
'ulikes': ulikes, | ||
'dates': dates, | ||
} |
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_json.GET
refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign
)
return open(pth+'data/'+token+'/'+str(numb)+'.png','rb').read() | ||
return open(f'{pth}data/{token}/{str(numb)}.png', 'rb').read() |
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 images.GET
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
return str(second_diff) + " seconds ago" | ||
return f"{str(second_diff)} seconds ago" | ||
if second_diff < 120: | ||
return "a minute ago" | ||
if second_diff < 3600: | ||
return str(second_diff / 60) + " minutes ago" | ||
return f"{str(second_diff / 60)} minutes ago" | ||
if second_diff < 7200: | ||
return "an hour ago" | ||
if second_diff < 86400: | ||
return str(second_diff / 3600) + " hours ago" | ||
return f"{str(second_diff / 3600)} hours ago" | ||
if day_diff == 1: | ||
return "Yesterday" | ||
if day_diff < 7: | ||
return str(day_diff) + " days ago" | ||
return f"{str(day_diff)} days ago" | ||
if day_diff < 31: | ||
return str(day_diff / 7) + " weeks ago" | ||
return f"{str(day_diff / 7)} weeks ago" | ||
if day_diff < 365: | ||
return str(day_diff / 30) + " months ago" | ||
return str(day_diff / 365) + " years ago" | ||
return f"{str(day_diff / 30)} months ago" | ||
return f"{str(day_diff / 365)} years ago" |
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 pretty_date
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
d={} | ||
d['likes']=likes | ||
d['all']=len(likes) | ||
d['names']=names | ||
d['texts']=texts | ||
d['lids']=lids | ||
d['ulikes']=ulikes | ||
d['dates']=dates | ||
d = { | ||
'likes': likes, | ||
'all': len(likes), | ||
'names': names, | ||
'texts': texts, | ||
'lids': lids, | ||
'ulikes': ulikes, | ||
'dates': dates, | ||
} |
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_json
refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign
)
return open(pth+'data/'+token+'/'+str(numb)+'.png','rb').read() | ||
return open(f'{pth}data/{token}/{str(numb)}.png', 'rb').read() |
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 data
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
return str(second_diff) + " seconds ago" | ||
return f"{str(second_diff)} seconds ago" | ||
if second_diff < 120: | ||
return "a minute ago" | ||
if second_diff < 3600: | ||
return str(second_diff / 60) + " minutes ago" | ||
return f"{str(second_diff / 60)} minutes ago" | ||
if second_diff < 7200: | ||
return "an hour ago" | ||
if second_diff < 86400: | ||
return str(second_diff / 3600) + " hours ago" | ||
return f"{str(second_diff / 3600)} hours ago" | ||
if day_diff == 1: | ||
return "Yesterday" | ||
if day_diff < 7: | ||
return str(day_diff) + " days ago" | ||
return f"{str(day_diff)} days ago" | ||
if day_diff < 31: | ||
return str(day_diff / 7) + " weeks ago" | ||
return f"{str(day_diff / 7)} weeks ago" | ||
if day_diff < 365: | ||
return str(day_diff / 30) + " months ago" | ||
return str(day_diff / 365) + " years ago" | ||
return f"{str(day_diff / 30)} months ago" | ||
return f"{str(day_diff / 365)} years ago" |
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 pretty_date
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
'Accept-Language': 'ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4', | ||
'Connection': 'keep-alive', | ||
'Content-Length': '0', | ||
'Host': 'www.instagram.com', | ||
'Origin': 'https://www.instagram.com', | ||
'Referer': 'https://www.instagram.com/', | ||
'User-Agent': ("Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 " | ||
"(KHTML, like Gecko) Chrome/48.0.2564.103 Safari/537.36"), | ||
'X-Instagram-AJAX': '1', | ||
'X-Requested-With': 'XMLHttpRequest'}) | ||
'Accept-Language': 'ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4', | ||
'Connection': 'keep-alive', | ||
'Content-Length': '0', | ||
'Host': 'www.instagram.com', | ||
'Origin': 'https://www.instagram.com', | ||
'Referer': 'https://www.instagram.com/', | ||
'User-Agent': ("Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 " | ||
"(KHTML, like Gecko) Chrome/48.0.2564.103 Safari/537.36"), | ||
'X-Instagram-AJAX': '1', | ||
'X-Requested-With': 'XMLHttpRequest'}) |
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 login
refactored with the following changes:
- Convert for loop into dictionary comprehension (
dict-comprehension
)
'Accept-Language': 'ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4', | ||
'Connection': 'keep-alive', | ||
'Content-Length': '0', | ||
'Host': 'www.instagram.com', | ||
'Origin': 'https://www.instagram.com', | ||
'Referer': 'https://www.instagram.com/', | ||
'User-Agent': ("Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 " | ||
"(KHTML, like Gecko) Chrome/48.0.2564.103 Safari/537.36"), | ||
'X-Instagram-AJAX': '1', | ||
'X-Requested-With': 'XMLHttpRequest'}) | ||
'Accept-Language': 'ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4', | ||
'Connection': 'keep-alive', | ||
'Content-Length': '0', | ||
'Host': 'www.instagram.com', | ||
'Origin': 'https://www.instagram.com', | ||
'Referer': 'https://www.instagram.com/', | ||
'User-Agent': ("Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 " | ||
"(KHTML, like Gecko) Chrome/48.0.2564.103 Safari/537.36"), | ||
'X-Instagram-AJAX': '1', | ||
'X-Requested-With': 'XMLHttpRequest'}) | ||
s.headers.update({'content-type':'application/x-www-form-urlencoded'}) | ||
s.headers.update({'path':'/web/likes/'+str(lid)+'/like/'}) | ||
s.headers.update({'path': f'/web/likes/{str(lid)}/like/'}) | ||
s.headers.update({'x-csrftoken':c['csrftoken']}) | ||
re=s.post('https://www.instagram.com/web/likes/%s/like/'%(lid)) | ||
re = s.post(f'https://www.instagram.com/web/likes/{lid}/like/') |
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 like
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
) - Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.05%.
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!