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

Formatted strings #1178

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Formatted strings #1178

wants to merge 4 commits into from

Conversation

dieser-niko
Copy link
Member

closes #1159

There are some capitalisations in there as well.
Also, I had to change the playlist in examples/follow_playlist.py to a user playlist due to the recent API changes.

@dieser-niko dieser-niko linked an issue Dec 3, 2024 that may be closed by this pull request
@dieser-niko
Copy link
Member Author

@haviv1idan you can also check out the PR. I've included some of your changes, but not all. For some, I have added a comment to your PR (#1165)

@kampelmuehler
Copy link

Why mix .format() and f-strings?

Copy link

@haviv1idan haviv1idan left a comment

Choose a reason for hiding this comment

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

@dieser-niko Very nice job.
Just a few suggestions to keep consistency in code

@@ -145,7 +145,7 @@ class SpotifyClientCredentials that can be used to authenticate requests like so
playlists = sp.user_playlists('spotify')
while playlists:
for i, playlist in enumerate(playlists['items']):
print("%4d %s %s" % (i + 1 + playlists['offset'], playlist['uri'], playlist['name']))
print("{:4d} {} {}".format(i + 1 + playlists['offset'], playlist['uri'], playlist['name']))

Choose a reason for hiding this comment

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

@dieser-niko I think we need to be consistent in our code.
Most of files are using f-string instead of format.
You can replace this code to this:

print(f"{i + 1 + playlists['offset']:4d} {playlist['uri']} {playlist['name']}")

Comment on lines +266 to +267
logger.debug('Sending {} to {} with Params: {} Headers: {} and Body: {!r} '.format(
method, url, args.get("params"), headers, args.get('data')))

Choose a reason for hiding this comment

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

The same here. replace format with f-string

Comment on lines +293 to +294
'HTTP Error for {} to {} with Params: {} returned {} due to {}'.format(
method, url, args.get("params"), response.status_code, msg

Choose a reason for hiding this comment

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

The same here. replace format with f-string

Comment on lines +221 to +222
"Sending POST request to {} with Headers: {} and Body: {!r}".format(
self.OAUTH_TOKEN_URL, headers, payload)

Choose a reason for hiding this comment

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

The same here. replace format with f-string

Comment on lines +513 to +514
"Sending POST request to {} with Headers: {} and Body: {!r}".format(
self.OAUTH_TOKEN_URL, headers, payload)

Choose a reason for hiding this comment

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

The same here. replace format with f-string

Comment on lines +543 to +544
"Sending POST request to {} with Headers: {} and Body: {!r}".format(
self.OAUTH_TOKEN_URL, headers, payload)

Choose a reason for hiding this comment

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

The same here. replace format with f-string

Comment on lines +869 to +870
"Sending POST request to {} with Headers: {} and Body: {!r}".format(
self.OAUTH_TOKEN_URL, headers, payload)

Choose a reason for hiding this comment

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

The same here. replace format with f-string

Comment on lines +900 to +901
"Sending POST request to {} with Headers: {} and Body: {!r}".format(
self.OAUTH_TOKEN_URL, headers, payload)

Choose a reason for hiding this comment

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

The same here. replace format with f-string

@dieser-niko
Copy link
Member Author

Yeah honestly I don't know what went through my mind. I guess I preferred to use .format() because it would be easier to read, but I agree, consistency would actually be better.

Currently I don't have the time to fix, expect activity in the next month.

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.

changing %s to f-string
3 participants