From c490ac5810b70f3cf5fd8649669838e8fdb19f4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0ar=C5=ABnas=20Nejus?= Date: Wed, 7 May 2025 03:06:44 +0100 Subject: [PATCH] Fix formatting --- beets/test/_common.py | 12 ++++++------ beets/ui/__init__.py | 2 +- beets/ui/commands.py | 4 +--- beets/util/__init__.py | 6 +++--- beetsplug/absubmit.py | 4 ++-- beetsplug/acousticbrainz.py | 2 +- beetsplug/bareasc.py | 2 +- beetsplug/bpm.py | 4 ++-- beetsplug/duplicates.py | 8 ++++---- beetsplug/embedart.py | 2 +- beetsplug/fetchart.py | 2 +- beetsplug/importadded.py | 7 +++---- beetsplug/inline.py | 4 ++-- beetsplug/lastimport.py | 2 +- beetsplug/listenbrainz.py | 2 +- beetsplug/lyrics.py | 14 +++++++------- beetsplug/smartplaylist.py | 2 +- beetsplug/spotify.py | 3 +-- beetsplug/subsonicplaylist.py | 2 +- beetsplug/the.py | 2 +- beetsplug/thumbnails.py | 2 +- beetsplug/zero.py | 2 +- extra/release.py | 2 +- test/plugins/test_convert.py | 18 +++++++++--------- test/plugins/test_embedart.py | 12 ++++++------ test/plugins/test_embyupdate.py | 2 +- test/plugins/test_mbsubmit.py | 2 +- test/plugins/test_play.py | 2 +- test/test_plugins.py | 2 +- test/test_template.py | 6 +++--- test/test_ui.py | 2 +- 31 files changed, 67 insertions(+), 71 deletions(-) diff --git a/beets/test/_common.py b/beets/test/_common.py index 757d461bd..86319c011 100644 --- a/beets/test/_common.py +++ b/beets/test/_common.py @@ -121,15 +121,15 @@ class Assertions: def assertIsFile(self, path): self.assertExists(path) - assert os.path.isfile( - syspath(path) - ), "path exists, but is not a regular file: {!r}".format(path) + assert os.path.isfile(syspath(path)), ( + "path exists, but is not a regular file: {!r}".format(path) + ) def assertIsDir(self, path): self.assertExists(path) - assert os.path.isdir( - syspath(path) - ), "path exists, but is not a directory: {!r}".format(path) + assert os.path.isdir(syspath(path)), ( + "path exists, but is not a directory: {!r}".format(path) + ) def assert_equal_path(self, a, b): """Check that two paths are equal.""" diff --git a/beets/ui/__init__.py b/beets/ui/__init__.py index 386410a09..8cc5de309 100644 --- a/beets/ui/__init__.py +++ b/beets/ui/__init__.py @@ -1768,7 +1768,7 @@ def _open_library(config): ) ) log.debug( - "library database: {0}\n" "library directory: {1}", + "library database: {0}\nlibrary directory: {1}", util.displayable_path(lib.path), util.displayable_path(lib.directory), ) diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 1822c3e7c..12ea4c94d 100755 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -1599,9 +1599,7 @@ def list_func(lib, opts, args): list_cmd = ui.Subcommand("list", help="query the library", aliases=("ls",)) -list_cmd.parser.usage += ( - "\n" "Example: %prog -f '$album: $title' artist:beatles" -) +list_cmd.parser.usage += "\nExample: %prog -f '$album: $title' artist:beatles" list_cmd.parser.add_all_common_options() list_cmd.func = list_func default_commands.append(list_cmd) diff --git a/beets/util/__init__.py b/beets/util/__init__.py index ff0a5d273..6d0ce0f88 100644 --- a/beets/util/__init__.py +++ b/beets/util/__init__.py @@ -559,7 +559,7 @@ def link(path: bytes, dest: bytes, replace: bool = False): except NotImplementedError: # raised on python >= 3.2 and Windows versions before Vista raise FilesystemError( - "OS does not support symbolic links." "link", + "OS does not support symbolic links.link", (path, dest), traceback.format_exc(), ) @@ -581,14 +581,14 @@ def hardlink(path: bytes, dest: bytes, replace: bool = False): os.link(syspath(path), syspath(dest)) except NotImplementedError: raise FilesystemError( - "OS does not support hard links." "link", + "OS does not support hard links.link", (path, dest), traceback.format_exc(), ) except OSError as exc: if exc.errno == errno.EXDEV: raise FilesystemError( - "Cannot hard link across devices." "link", + "Cannot hard link across devices.link", (path, dest), traceback.format_exc(), ) diff --git a/beetsplug/absubmit.py b/beetsplug/absubmit.py index bbbc14edf..3c48f8897 100644 --- a/beetsplug/absubmit.py +++ b/beetsplug/absubmit.py @@ -157,7 +157,7 @@ only files which would be processed", # If file has no MBID, skip it. if not mbid: self._log.info( - "Not analysing {}, missing " "musicbrainz track id.", item + "Not analysing {}, missing musicbrainz track id.", item ) return None @@ -220,6 +220,6 @@ only files which would be processed", ) else: self._log.debug( - "Successfully submitted AcousticBrainz analysis " "for {}.", + "Successfully submitted AcousticBrainz analysis for {}.", item, ) diff --git a/beetsplug/acousticbrainz.py b/beetsplug/acousticbrainz.py index 899288260..714751ac9 100644 --- a/beetsplug/acousticbrainz.py +++ b/beetsplug/acousticbrainz.py @@ -286,7 +286,7 @@ class AcousticPlugin(plugins.BeetsPlugin): yield v, subdata[k] else: self._log.warning( - "Acousticbrainz did not provide info " "about {}", k + "Acousticbrainz did not provide info about {}", k ) self._log.debug( "Data {} could not be mapped to scheme {} " diff --git a/beetsplug/bareasc.py b/beetsplug/bareasc.py index 0a867dfe1..3a52c41dd 100644 --- a/beetsplug/bareasc.py +++ b/beetsplug/bareasc.py @@ -75,7 +75,7 @@ class BareascPlugin(BeetsPlugin): "bareasc", help="unidecode version of beet list command" ) cmd.parser.usage += ( - "\n" "Example: %prog -f '$album: $title' artist:beatles" + "\nExample: %prog -f '$album: $title' artist:beatles" ) cmd.parser.add_all_common_options() cmd.func = self.unidecode_list diff --git a/beetsplug/bpm.py b/beetsplug/bpm.py index 10edfbfd7..946769cdc 100644 --- a/beetsplug/bpm.py +++ b/beetsplug/bpm.py @@ -57,7 +57,7 @@ class BPMPlugin(BeetsPlugin): def commands(self): cmd = ui.Subcommand( "bpm", - help="determine bpm of a song by pressing " "a key to the rhythm", + help="determine bpm of a song by pressing a key to the rhythm", ) cmd.func = self.command return [cmd] @@ -79,7 +79,7 @@ class BPMPlugin(BeetsPlugin): return self._log.info( - "Press Enter {0} times to the rhythm or Ctrl-D " "to exit", + "Press Enter {0} times to the rhythm or Ctrl-D to exit", self.config["max_strokes"].get(int), ) new_bpm = bpm(self.config["max_strokes"].get(int)) diff --git a/beetsplug/duplicates.py b/beetsplug/duplicates.py index 1e30a60a5..fadb29845 100644 --- a/beetsplug/duplicates.py +++ b/beetsplug/duplicates.py @@ -236,7 +236,7 @@ class DuplicatesPlugin(BeetsPlugin): checksum = getattr(item, key, False) if not checksum: self._log.debug( - "key {0} on item {1} not cached:" "computing checksum", + "key {0} on item {1} not cached:computing checksum", key, displayable_path(item.path), ) @@ -255,7 +255,7 @@ class DuplicatesPlugin(BeetsPlugin): ) else: self._log.debug( - "key {0} on item {1} cached:" "not computing checksum", + "key {0} on item {1} cached:not computing checksum", key, displayable_path(item.path), ) @@ -275,13 +275,13 @@ class DuplicatesPlugin(BeetsPlugin): values = [v for v in values if v not in (None, "")] if strict and len(values) < len(keys): self._log.debug( - "some keys {0} on item {1} are null or empty:" " skipping", + "some keys {0} on item {1} are null or empty: skipping", keys, displayable_path(obj.path), ) elif not strict and not len(values): self._log.debug( - "all keys {0} on item {1} are null or empty:" " skipping", + "all keys {0} on item {1} are null or empty: skipping", keys, displayable_path(obj.path), ) diff --git a/beetsplug/embedart.py b/beetsplug/embedart.py index 740863bf1..2a4e06a93 100644 --- a/beetsplug/embedart.py +++ b/beetsplug/embedart.py @@ -66,7 +66,7 @@ class EmbedCoverArtPlugin(BeetsPlugin): if self.config["maxwidth"].get(int) and not ArtResizer.shared.local: self.config["maxwidth"] = 0 self._log.warning( - "ImageMagick or PIL not found; " "'maxwidth' option ignored" + "ImageMagick or PIL not found; 'maxwidth' option ignored" ) if ( self.config["compare_threshold"].get(int) diff --git a/beetsplug/fetchart.py b/beetsplug/fetchart.py index 0da884278..cf2200abc 100644 --- a/beetsplug/fetchart.py +++ b/beetsplug/fetchart.py @@ -686,7 +686,7 @@ class FanartTV(RemoteArtSource): # can this actually occur? else: self._log.debug( - "fanart.tv: unexpected mb_releasegroupid in " "response!" + "fanart.tv: unexpected mb_releasegroupid in response!" ) matches.sort(key=lambda x: int(x["likes"]), reverse=True) diff --git a/beetsplug/importadded.py b/beetsplug/importadded.py index 61a14fba9..2564f26b2 100644 --- a/beetsplug/importadded.py +++ b/beetsplug/importadded.py @@ -58,8 +58,7 @@ class ImportAddedPlugin(BeetsPlugin): or session.config["reflink"] ): self._log.debug( - "In place import detected, recording mtimes from " - "source paths" + "In place import detected, recording mtimes from source paths" ) items = ( [task.item] @@ -95,7 +94,7 @@ class ImportAddedPlugin(BeetsPlugin): mtime = os.stat(util.syspath(source)).st_mtime self.item_mtime[destination] = mtime self._log.debug( - "Recorded mtime {0} for item '{1}' imported from " "'{2}'", + "Recorded mtime {0} for item '{1}' imported from '{2}'", mtime, util.displayable_path(destination), util.displayable_path(source), @@ -130,7 +129,7 @@ class ImportAddedPlugin(BeetsPlugin): def update_item_times(self, lib, item): if self.reimported_item(item): self._log.debug( - "Item '{0}' is reimported, skipping import of " "added date.", + "Item '{0}' is reimported, skipping import of added date.", util.displayable_path(item.path), ) return diff --git a/beetsplug/inline.py b/beetsplug/inline.py index 4092c46d0..c4258fc83 100644 --- a/beetsplug/inline.py +++ b/beetsplug/inline.py @@ -28,7 +28,7 @@ class InlineError(Exception): def __init__(self, code, exc): super().__init__( - ("error in inline path field code:\n" "%s\n%s: %s") + ("error in inline path field code:\n%s\n%s: %s") % (code, type(exc).__name__, str(exc)) ) @@ -87,7 +87,7 @@ class InlinePlugin(BeetsPlugin): func = _compile_func(python_code) except SyntaxError: self._log.error( - "syntax error in inline field definition:\n" "{0}", + "syntax error in inline field definition:\n{0}", traceback.format_exc(), ) return diff --git a/beetsplug/lastimport.py b/beetsplug/lastimport.py index f59205b99..28cf958a5 100644 --- a/beetsplug/lastimport.py +++ b/beetsplug/lastimport.py @@ -267,7 +267,7 @@ def process_tracks(lib, tracks, log): count = int(song.get("play_count", 0)) new_count = int(tracks[num].get("playcount", 1)) log.debug( - "match: {0} - {1} ({2}) " "updating: play_count {3} => {4}", + "match: {0} - {1} ({2}) updating: play_count {3} => {4}", song.artist, song.title, song.album, diff --git a/beetsplug/listenbrainz.py b/beetsplug/listenbrainz.py index 37a7920b9..c579645db 100644 --- a/beetsplug/listenbrainz.py +++ b/beetsplug/listenbrainz.py @@ -180,7 +180,7 @@ class ListenBrainzPlugin(BeetsPlugin): ) for playlist in listenbrainz_playlists: self._log.debug( - f'Playlist: {playlist["type"]} - {playlist["date"]}' + f"Playlist: {playlist['type']} - {playlist['date']}" ) return listenbrainz_playlists diff --git a/beetsplug/lyrics.py b/beetsplug/lyrics.py index cb48e2424..3e979221c 100644 --- a/beetsplug/lyrics.py +++ b/beetsplug/lyrics.py @@ -557,7 +557,7 @@ class Genius(SearchBackend): @cached_property def headers(self) -> dict[str, str]: - return {"Authorization": f'Bearer {self.config["genius_api_key"]}'} + return {"Authorization": f"Bearer {self.config['genius_api_key']}"} def search(self, artist: str, title: str) -> Iterable[SearchResult]: search_data: GeniusAPI.Search = self.fetch_json( @@ -913,17 +913,17 @@ class RestFiles: def write_artist(self, artist: str, items: Iterable[Item]) -> None: parts = [ - f'{artist}\n{"=" * len(artist)}', + f"{artist}\n{'=' * len(artist)}", ".. contents::\n :local:", ] for album, items in groupby(items, key=lambda i: i.album): - parts.append(f'{album}\n{"-" * len(album)}') + parts.append(f"{album}\n{'-' * len(album)}") parts.extend( part for i in items if (title := f":index:`{i.title.strip()}`") for part in ( - f'{title}\n{"~" * len(title)}', + f"{title}\n{'~' * len(title)}", textwrap.indent(i.lyrics, "| "), ) ) @@ -941,9 +941,9 @@ class RestFiles: d = self.directory text = f""" ReST files generated. to build, use one of: - sphinx-build -b html {d} {d/"html"} - sphinx-build -b epub {d} {d/"epub"} - sphinx-build -b latex {d} {d/"latex"} && make -C {d/"latex"} all-pdf + sphinx-build -b html {d} {d / "html"} + sphinx-build -b epub {d} {d / "epub"} + sphinx-build -b latex {d} {d / "latex"} && make -C {d / "latex"} all-pdf """ ui.print_(textwrap.dedent(text)) diff --git a/beetsplug/smartplaylist.py b/beetsplug/smartplaylist.py index d758c0255..5ea3c6bff 100644 --- a/beetsplug/smartplaylist.py +++ b/beetsplug/smartplaylist.py @@ -327,7 +327,7 @@ class SmartPlaylistPlugin(BeetsPlugin): if extm3u: attr = [(k, entry.item[k]) for k in keys] al = [ - f" {key}=\"{quote(str(value), safe='/:')}\"" + f' {key}="{quote(str(value), safe="/:")}"' for key, value in attr ] attrs = "".join(al) diff --git a/beetsplug/spotify.py b/beetsplug/spotify.py index 55a77a8a7..3f5b16d11 100644 --- a/beetsplug/spotify.py +++ b/beetsplug/spotify.py @@ -208,8 +208,7 @@ class SpotifyPlugin(MetadataSourcePlugin, BeetsPlugin): "Retry-After", DEFAULT_WAITING_TIME ) self._log.debug( - f"Too many API requests. Retrying after " - f"{seconds} seconds." + f"Too many API requests. Retrying after {seconds} seconds." ) time.sleep(int(seconds) + 1) return self._handle_response( diff --git a/beetsplug/subsonicplaylist.py b/beetsplug/subsonicplaylist.py index 606cdc8bd..9b4a7778c 100644 --- a/beetsplug/subsonicplaylist.py +++ b/beetsplug/subsonicplaylist.py @@ -115,7 +115,7 @@ class SubsonicPlaylistPlugin(BeetsPlugin): )[0] if playlists.attrib.get("code", "200") != "200": alt_error = ( - "error getting playlists," " but no error message found" + "error getting playlists, but no error message found" ) self._log.warn(playlists.attrib.get("message", alt_error)) return diff --git a/beetsplug/the.py b/beetsplug/the.py index 42da708a3..802b0a3db 100644 --- a/beetsplug/the.py +++ b/beetsplug/the.py @@ -54,7 +54,7 @@ class ThePlugin(BeetsPlugin): else: if not (p.startswith("^") or p.endswith("$")): self._log.warning( - 'warning: "{0}" will not ' "match string start/end", + 'warning: "{0}" will not match string start/end', p, ) if self.config["a"]: diff --git a/beetsplug/thumbnails.py b/beetsplug/thumbnails.py index f0755c0f9..e11b75390 100644 --- a/beetsplug/thumbnails.py +++ b/beetsplug/thumbnails.py @@ -161,7 +161,7 @@ class ThumbnailsPlugin(BeetsPlugin): ) else: self._log.debug( - "{1}x{1} thumbnail for {0} exists and is " "recent enough", + "{1}x{1} thumbnail for {0} exists and is recent enough", album, size, ) diff --git a/beetsplug/zero.py b/beetsplug/zero.py index bda4052ab..5d1244dec 100644 --- a/beetsplug/zero.py +++ b/beetsplug/zero.py @@ -93,7 +93,7 @@ class ZeroPlugin(BeetsPlugin): self._log.error("invalid field: {0}", field) elif field in ("id", "path", "album_id"): self._log.warning( - "field '{0}' ignored, zeroing " "it would be dangerous", field + "field '{0}' ignored, zeroing it would be dangerous", field ) else: try: diff --git a/extra/release.py b/extra/release.py index 1891f17f2..16e2e860e 100755 --- a/extra/release.py +++ b/extra/release.py @@ -170,7 +170,7 @@ For packagers: Other changes: {new_header} -{'-' * len(new_header)} +{"-" * len(new_header)} """, text, ) diff --git a/test/plugins/test_convert.py b/test/plugins/test_convert.py index a2b4eaf67..6dd28337a 100644 --- a/test/plugins/test_convert.py +++ b/test/plugins/test_convert.py @@ -67,9 +67,9 @@ class ConvertMixin: self.assertIsFile(path) with open(path, "rb") as f: f.seek(-len(display_tag), os.SEEK_END) - assert ( - f.read() == tag - ), f"{displayable_path(path)} is not tagged with {display_tag}" + assert f.read() == tag, ( + f"{displayable_path(path)} is not tagged with {display_tag}" + ) def assertNoFileTag(self, path, tag): """Assert that the path is a file and the files content does not @@ -80,9 +80,9 @@ class ConvertMixin: self.assertIsFile(path) with open(path, "rb") as f: f.seek(-len(tag), os.SEEK_END) - assert ( - f.read() != tag - ), f"{displayable_path(path)} is unexpectedly tagged with {display_tag}" + assert f.read() != tag, ( + f"{displayable_path(path)} is unexpectedly tagged with {display_tag}" + ) class ConvertTestCase(ConvertMixin, PluginTestCase): @@ -124,9 +124,9 @@ class ImportConvertTest(AsIsImporterMixin, ImportHelper, ConvertTestCase): self.run_asis_importer() for path in self.importer.paths: for root, dirnames, filenames in os.walk(path): - assert ( - len(fnmatch.filter(filenames, "*.mp3")) == 0 - ), f"Non-empty import directory {util.displayable_path(path)}" + assert len(fnmatch.filter(filenames, "*.mp3")) == 0, ( + f"Non-empty import directory {util.displayable_path(path)}" + ) def get_count_of_import_files(self): import_file_count = 0 diff --git a/test/plugins/test_embedart.py b/test/plugins/test_embedart.py index 2d2d68153..cb4d1a421 100644 --- a/test/plugins/test_embedart.py +++ b/test/plugins/test_embedart.py @@ -153,9 +153,9 @@ class EmbedartCliTest(PluginMixin, FetchImageHelper, BeetsTestCase): self.run_command("embedart", "-y", "-f", self.abbey_differentpath) mediafile = MediaFile(syspath(item.path)) - assert ( - mediafile.images[0].data == self.image_data - ), f"Image written is not {displayable_path(self.abbey_artpath)}" + assert mediafile.images[0].data == self.image_data, ( + f"Image written is not {displayable_path(self.abbey_artpath)}" + ) @require_artresizer_compare def test_accept_similar_art(self): @@ -167,9 +167,9 @@ class EmbedartCliTest(PluginMixin, FetchImageHelper, BeetsTestCase): self.run_command("embedart", "-y", "-f", self.abbey_similarpath) mediafile = MediaFile(syspath(item.path)) - assert ( - mediafile.images[0].data == self.image_data - ), f"Image written is not {displayable_path(self.abbey_similarpath)}" + assert mediafile.images[0].data == self.image_data, ( + f"Image written is not {displayable_path(self.abbey_similarpath)}" + ) def test_non_ascii_album_path(self): resource_path = os.path.join(_common.RSRC, b"image.mp3") diff --git a/test/plugins/test_embyupdate.py b/test/plugins/test_embyupdate.py index 8def5dca5..9c7104371 100644 --- a/test/plugins/test_embyupdate.py +++ b/test/plugins/test_embyupdate.py @@ -143,7 +143,7 @@ class EmbyUpdateTest(PluginTestCase): responses.add( responses.POST, - ("http://localhost:8096" "/Users/AuthenticateByName"), + ("http://localhost:8096/Users/AuthenticateByName"), body=body, status=200, content_type="application/json", diff --git a/test/plugins/test_mbsubmit.py b/test/plugins/test_mbsubmit.py index f92d85973..04b1b736e 100644 --- a/test/plugins/test_mbsubmit.py +++ b/test/plugins/test_mbsubmit.py @@ -64,6 +64,6 @@ class MBSubmitPluginTest(PluginMixin, TerminalImportMixin, ImportTestCase): # Manually build the string for comparing the output. tracklist = ( - "Open files with Picard? " "02. Tag Track 2 - Tag Artist (0:01)" + "Open files with Picard? 02. Tag Track 2 - Tag Artist (0:01)" ) assert tracklist in output.getvalue() diff --git a/test/plugins/test_play.py b/test/plugins/test_play.py index 712739633..571af95dd 100644 --- a/test/plugins/test_play.py +++ b/test/plugins/test_play.py @@ -97,7 +97,7 @@ class PlayPluginTest(CleanupModulesMixin, PluginTestCase): with open(open_mock.call_args[0][0][0], "rb") as f: playlist = f.read().decode("utf-8") assert ( - f'{os.path.dirname(self.item.path.decode("utf-8"))}\n' == playlist + f"{os.path.dirname(self.item.path.decode('utf-8'))}\n" == playlist ) def test_raw(self, open_mock): diff --git a/test/test_plugins.py b/test/test_plugins.py index efa26d084..d273de698 100644 --- a/test/test_plugins.py +++ b/test/test_plugins.py @@ -174,7 +174,7 @@ class EventsTest(PluginImportTestCase): logs = [line for line in logs if not line.startswith("Sending event:")] assert logs == [ - f'Album: {displayable_path(os.path.join(self.import_dir, b"album"))}', + f"Album: {displayable_path(os.path.join(self.import_dir, b'album'))}", f" {displayable_path(self.import_media[0].path)}", f" {displayable_path(self.import_media[1].path)}", ] diff --git a/test/test_template.py b/test/test_template.py index 236bee5aa..031aab289 100644 --- a/test/test_template.py +++ b/test/test_template.py @@ -61,9 +61,9 @@ class ParseTest(unittest.TestCase): """ assert isinstance(obj, functemplate.Call), f"not a Call: {obj}" assert obj.ident == ident, f"wrong identifier: {obj.ident} vs. {ident}" - assert ( - len(obj.args) == numargs - ), f"wrong argument count in {obj.ident}: {len(obj.args)} vs. {numargs}" + assert len(obj.args) == numargs, ( + f"wrong argument count in {obj.ident}: {len(obj.args)} vs. {numargs}" + ) def test_plain_text(self): assert list(_normparse("hello world")) == ["hello world"] diff --git a/test/test_ui.py b/test/test_ui.py index e9588dbc6..afa16e171 100644 --- a/test/test_ui.py +++ b/test/test_ui.py @@ -1441,7 +1441,7 @@ class CompletionTest(TestPluginTestCase): assert tester.returncode == 0 assert out == b"completion tests passed\n", ( "test/test_completion.sh did not execute properly. " - f'Output:{out.decode("utf-8")}' + f"Output:{out.decode('utf-8')}" )