-
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
channels = None | ||
if args.channels: | ||
channels = re.split('\s*,\s*', args.channels) | ||
playlists = None | ||
if args.playlists: | ||
playlists = re.split('\s*,\s*', args.playlists) | ||
|
||
channels = re.split('\s*,\s*', args.channels) if args.channels else None | ||
playlists = re.split('\s*,\s*', args.playlists) if args.playlists else 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 add_channel_section
refactored with the following changes:
- Move setting of default value for variable into
else
branch [×2] (introduce-default-else
) - Replace if statement with if expression [×2] (
assign-if-exp
)
storage = Storage("%s-oauth2.json" % sys.argv[0]) | ||
storage = Storage(f"{sys.argv[0]}-oauth2.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 get_authenticated_service
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
storage = Storage("%s-oauth2.json" % sys.argv[0]) | ||
storage = Storage(f"{sys.argv[0]}-oauth2.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 get_authenticated_service
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
storage = Storage("%s-oauth2.json" % sys.argv[0]) | ||
storage = Storage(f"{sys.argv[0]}-oauth2.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 get_authenticated_service
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
storage = Storage("%s-oauth2.json" % sys.argv[0]) | ||
storage = Storage(f"{sys.argv[0]}-oauth2.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 get_authenticated_service
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
storage = Storage("%s-oauth2.json" % sys.argv[0]) | ||
storage = Storage(f"{sys.argv[0]}-oauth2.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 get_authenticated_service
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
storage = Storage("%s-oauth2.json" % sys.argv[0]) | ||
storage = Storage(f"{sys.argv[0]}-oauth2.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 get_authenticated_service
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
tags = None | ||
if options.keywords: | ||
tags = options.keywords.split(',') | ||
|
||
tags = options.keywords.split(',') if options.keywords else 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 initialize_upload
refactored with the following changes:
- Move setting of default value for variable into
else
branch (introduce-default-else
) - Replace if statement with if expression (
assign-if-exp
)
api_service = build(API_SERVICE_NAME, API_VERSION, credentials=credentials) | ||
return api_service | ||
return build(API_SERVICE_NAME, API_VERSION, credentials=credentials) |
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_authenticated_service
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
if DEVELOPER_KEY == "REPLACE_ME": | ||
self.response.write("""You must set up a project and get an API key | ||
if DEVELOPER_KEY == "REPLACE_ME": | ||
self.response.write("""You must set up a project and get an API key | ||
to run this project. Please visit | ||
<landing page> to do so.""") | ||
else: | ||
youtube = build( | ||
YOUTUBE_API_SERVICE_NAME, | ||
YOUTUBE_API_VERSION, | ||
developerKey=DEVELOPER_KEY) | ||
search_response = youtube.search().list( | ||
q="Hello", | ||
part="id,snippet", | ||
maxResults=5 | ||
).execute() | ||
videos = [] | ||
channels = [] | ||
playlists = [] | ||
for search_result in search_response.get("items", []): | ||
else: | ||
youtube = build( | ||
YOUTUBE_API_SERVICE_NAME, | ||
YOUTUBE_API_VERSION, | ||
developerKey=DEVELOPER_KEY) | ||
search_response = youtube.search().list( | ||
q="Hello", | ||
part="id,snippet", | ||
maxResults=5 | ||
).execute() | ||
|
||
videos = [] | ||
channels = [] | ||
playlists = [] | ||
|
||
for search_result in search_response.get("items", []): | ||
if search_result["id"]["kind"] == "youtube#video": | ||
videos.append("%s (%s)" % (search_result["snippet"]["title"], | ||
search_result["id"]["videoId"])) | ||
videos.append( | ||
f'{search_result["snippet"]["title"]} ({search_result["id"]["videoId"]})' | ||
) | ||
elif search_result["id"]["kind"] == "youtube#channel": | ||
channels.append("%s (%s)" % (search_result["snippet"]["title"], | ||
search_result["id"]["channelId"])) | ||
channels.append( | ||
f'{search_result["snippet"]["title"]} ({search_result["id"]["channelId"]})' | ||
) | ||
elif search_result["id"]["kind"] == "youtube#playlist": | ||
playlists.append("%s (%s)" % (search_result["snippet"]["title"], | ||
search_result["id"]["playlistId"])) | ||
|
||
template_values = { | ||
'videos': videos, | ||
'channels': channels, | ||
'playlists': playlists | ||
} | ||
|
||
self.response.headers['Content-type'] = 'text/plain' | ||
template = JINJA_ENVIRONMENT.get_template('index.html') | ||
self.response.write(template.render(template_values)) | ||
playlists.append( | ||
f'{search_result["snippet"]["title"]} ({search_result["id"]["playlistId"]})' | ||
) | ||
|
||
template_values = { | ||
'videos': videos, | ||
'channels': channels, | ||
'playlists': playlists | ||
} | ||
|
||
self.response.headers['Content-type'] = 'text/plain' | ||
template = JINJA_ENVIRONMENT.get_template('index.html') | ||
self.response.write(template.render(template_values)) |
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 MainHandler.get
refactored with the following changes:
- Replace interpolated string formatting with f-string [×3] (
replace-interpolation-with-fstring
)
Sourcery Code Quality Report❌ Merging this PR will decrease code quality in the affected files by 0.04%.
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! |
|
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 MainHandler.post
refactored with the following changes:
- Replace a for append loop with list extend (
for-append-to-extend
) - Simplify generator expression (
simplify-generator
)
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!