Check f-strings (#1184)

This commit is contained in:
Stéphane Bruckert 2025-01-24 15:11:58 +00:00 committed by GitHub
parent 1d920ff5df
commit c738376b80
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 13 additions and 11 deletions

View File

@ -49,6 +49,7 @@ Add your changes below.
- featured_playlists - featured_playlists
- category_playlists - category_playlists
- Added FAQ entry for inaccessible playlists - Added FAQ entry for inaccessible playlists
- Workflow to check for f-strings
### Changed ### Changed

View File

@ -29,19 +29,18 @@ $ source env/bin/activate
### Lint ### Lint
pip install .[test]
To automatically fix some of the code style: To automatically fix some of the code style:
pip install autopep8
autopep8 --in-place --aggressive --recursive . autopep8 --in-place --aggressive --recursive .
To verify the code style: To verify the code style:
pip install flake8
flake8 . flake8 .
To make sure if the import lists are stored correctly: To make sure if the import lists are stored correctly:
pip install isort
isort . -c isort . -c
Sort them automatically with: Sort them automatically with:

View File

@ -12,7 +12,9 @@ extra_reqs = {
'pymemcache>=3.5.2' 'pymemcache>=3.5.2'
], ],
'test': [ 'test': [
'autopep8>=2.3.2',
'flake8>=7.1.1', 'flake8>=7.1.1',
'flake8-string-format>=0.3.0',
'isort>=5.13.2' 'isort>=5.13.2'
] ]
} }

View File

@ -1244,10 +1244,8 @@ class Spotify:
if they follow the playlist. Maximum: 5 ids. if they follow the playlist. Maximum: 5 ids.
""" """
endpoint = "playlists/{}/followers/contains?ids={}" endpoint = f"playlists/{playlist_id}/followers/contains?ids={','.join(user_ids)}"
return self._get( return self._get(endpoint)
endpoint.format(playlist_id, ",".join(user_ids))
)
def me(self): def me(self):
""" Get detailed profile information about the current user. """ Get detailed profile information about the current user.

View File

@ -1224,19 +1224,21 @@ class RequestHandler(BaseHTTPRequestHandler):
self._write("<html><body><h1>Invalid request</h1></body></html>") self._write("<html><body><h1>Invalid request</h1></body></html>")
return return
self._write("""<html> self._write(f"""<html>
<script> <script>
window.close() window.close()
</script> </script>
<body> <body>
<h1>Authentication status: {}</h1> <h1>Authentication status: {status}</h1>
This window can be closed. This window can be closed.
<script> <script>
window.close() window.close()
</script> </script>
<button class="closeButton" style="cursor: pointer" onclick="window.close();">Close Window</button> <button class="closeButton" style="cursor: pointer" onclick="window.close();">
Close Window
</button>
</body> </body>
</html>""".format(status)) </html>""")
def _write(self, text): def _write(self, text):
return self.wfile.write(text.encode("utf-8")) return self.wfile.write(text.encode("utf-8"))