From 468dedb23f39512de1f4b61fec899fca007fe16d Mon Sep 17 00:00:00 2001 From: "Arav K." Date: Fri, 28 Jun 2024 20:05:28 +0200 Subject: [PATCH] Use 'repr' and 'str' in place of '!r' and '!s' See: diff --git c/beets/autotag/mb.py i/beets/autotag/mb.py index e16643d7..f152b567 100644 --- c/beets/autotag/mb.py +++ i/beets/autotag/mb.py @@ -66,7 +66,9 @@ class MusicBrainzAPIError(util.HumanReadableException): super().__init__(reason, verb, tb) def get_message(self): - return f"{self._reasonstr()} in {self.verb} with query {self.query!r}" + return ( + f"{self._reasonstr()} in {self.verb} with query {repr(self.query)}" + ) log = logging.getLogger("beets") diff --git c/beets/dbcore/db.py i/beets/dbcore/db.py index 55ba6f11..5aa75aa5 100755 --- c/beets/dbcore/db.py +++ i/beets/dbcore/db.py @@ -397,7 +397,7 @@ class Model(ABC): def __repr__(self) -> str: name = type(self).__name__ - fields = ", ".join(f"{k}={v!r}" for k, v in dict(self).items()) + fields = ", ".join(f"{k}={repr(v)}" for k, v in dict(self).items()) return f"{name}({fields})" def clear_dirty(self): @@ -558,12 +558,12 @@ class Model(ABC): def __getattr__(self, key): if key.startswith("_"): - raise AttributeError(f"model has no attribute {key!r}") + raise AttributeError(f"model has no attribute {repr(key)}") else: try: return self[key] except KeyError: - raise AttributeError(f"no such field {key!r}") + raise AttributeError(f"no such field {repr(key)}") def __setattr__(self, key, value): if key.startswith("_"): diff --git c/beets/dbcore/query.py i/beets/dbcore/query.py index 357b5685..6e94ddd5 100644 --- c/beets/dbcore/query.py +++ i/beets/dbcore/query.py @@ -171,7 +171,7 @@ class FieldQuery(Query, Generic[P]): def __repr__(self) -> str: return ( - f"{self.__class__.__name__}({self.field_name!r}, {self.pattern!r}, " + f"{self.__class__.__name__}({repr(self.field_name)}, {repr(self.pattern)}, " f"fast={self.fast})" ) @@ -210,7 +210,9 @@ class NoneQuery(FieldQuery[None]): return obj.get(self.field_name) is None def __repr__(self) -> str: - return f"{self.__class__.__name__}({self.field_name!r}, {self.fast})" + return ( + f"{self.__class__.__name__}({repr(self.field_name)}, {self.fast})" + ) class StringFieldQuery(FieldQuery[P]): @@ -503,7 +505,7 @@ class CollectionQuery(Query): return clause, subvals def __repr__(self) -> str: - return f"{self.__class__.__name__}({self.subqueries!r})" + return f"{self.__class__.__name__}({repr(self.subqueries)})" def __eq__(self, other) -> bool: return super().__eq__(other) and self.subqueries == other.subqueries @@ -548,7 +550,7 @@ class AnyFieldQuery(CollectionQuery): def __repr__(self) -> str: return ( - f"{self.__class__.__name__}({self.pattern!r}, {self.fields!r}, " + f"{self.__class__.__name__}({repr(self.pattern)}, {repr(self.fields)}, " f"{self.query_class.__name__})" ) @@ -619,7 +621,7 @@ class NotQuery(Query): return not self.subquery.match(obj) def __repr__(self) -> str: - return f"{self.__class__.__name__}({self.subquery!r})" + return f"{self.__class__.__name__}({repr(self.subquery)})" def __eq__(self, other) -> bool: return super().__eq__(other) and self.subquery == other.subquery @@ -975,7 +977,7 @@ class MultipleSort(Sort): return items def __repr__(self): - return f"{self.__class__.__name__}({self.sorts!r})" + return f"{self.__class__.__name__}({repr(self.sorts)})" def __hash__(self): return hash(tuple(self.sorts)) @@ -1015,7 +1017,7 @@ class FieldSort(Sort): def __repr__(self) -> str: return ( f"{self.__class__.__name__}" - f"({self.field!r}, ascending={self.ascending!r})" + f"({repr(self.field)}, ascending={repr(self.ascending)})" ) def __hash__(self) -> int: diff --git c/beets/library.py i/beets/library.py index 77d24ecd..a9adc13d 100644 --- c/beets/library.py +++ i/beets/library.py @@ -156,7 +156,7 @@ class PathQuery(dbcore.FieldQuery[bytes]): def __repr__(self) -> str: return ( - f"{self.__class__.__name__}({self.field!r}, {self.pattern!r}, " + f"{self.__class__.__name__}({repr(self.field)}, {repr(self.pattern)}, " f"fast={self.fast}, case_sensitive={self.case_sensitive})" ) @@ -735,7 +735,7 @@ class Item(LibModel): # can even deadlock due to the database lock. name = type(self).__name__ keys = self.keys(with_album=False) - fields = (f"{k}={self[k]!r}" for k in keys) + fields = (f"{k}={repr(self[k])}" for k in keys) return f"{name}({', '.join(fields)})" def keys(self, computed=False, with_album=True): @@ -1578,7 +1578,7 @@ def parse_query_string(s, model_cls): The string is split into components using shell-like syntax. """ - message = f"Query is not unicode: {s!r}" + message = f"Query is not unicode: {repr(s)}" assert isinstance(s, str), message try: parts = shlex.split(s) diff --git c/beets/test/_common.py i/beets/test/_common.py index c12838e2..0bc1baf8 100644 --- c/beets/test/_common.py +++ i/beets/test/_common.py @@ -152,7 +152,7 @@ class Assertions: """A mixin with additional unit test assertions.""" def assertExists(self, path): # noqa - assert os.path.exists(syspath(path)), f"file does not exist: {path!r}" + assert os.path.exists(syspath(path)), f"file does not exist: {repr(path)}" def assertNotExists(self, path): # noqa assert not os.path.exists(syspath(path)), f"file exists: {repr(path)}" @@ -186,7 +186,7 @@ class InputException(Exception): def __str__(self): msg = "Attempt to read with no input provided." if self.output is not None: - msg += f" Output: {self.output!r}" + msg += f" Output: {repr(self.output)}" return msg diff --git c/beets/ui/commands.py i/beets/ui/commands.py index 3042ca77..a717c94c 100755 --- c/beets/ui/commands.py +++ i/beets/ui/commands.py @@ -213,7 +213,7 @@ def get_singleton_disambig_fields(info: hooks.TrackInfo) -> Sequence[str]: out = [] chosen_fields = config["match"]["singleton_disambig_fields"].as_str_seq() calculated_values = { - "index": f"Index {info.index!s}", + "index": f"Index {str(info.index)}", "track_alt": f"Track {info.track_alt}", "album": ( f"[{info.album}]" diff --git c/beets/util/__init__.py i/beets/util/__init__.py index aa94b6d2..a0f13fa1 100644 --- c/beets/util/__init__.py +++ i/beets/util/__init__.py @@ -104,7 +104,7 @@ class HumanReadableException(Exception): elif hasattr(self.reason, "strerror"): # i.e., EnvironmentError return self.reason.strerror else: - return f'"{self.reason!s}"' + return f'"{str(self.reason)}"' def get_message(self): """Create the human-readable description of the error, sans diff --git c/beets/util/functemplate.py i/beets/util/functemplate.py index 35f60b7d..f149d370 100644 --- c/beets/util/functemplate.py +++ i/beets/util/functemplate.py @@ -166,7 +166,7 @@ class Call: self.original = original def __repr__(self): - return f"Call({self.ident!r}, {self.args!r}, {self.original!r})" + return f"Call({repr(self.ident)}, {repr(self.args)}, {repr(self.original)})" def evaluate(self, env): """Evaluate the function call in the environment, returning a diff --git c/beetsplug/bpd/__init__.py i/beetsplug/bpd/__init__.py index d6c75380..3336702c 100644 --- c/beetsplug/bpd/__init__.py +++ i/beetsplug/bpd/__init__.py @@ -1142,7 +1142,7 @@ class Server(BaseServer): pass for tagtype, field in self.tagtype_map.items(): - info_lines.append(f"{tagtype}: {getattr(item, field)!s}") + info_lines.append(f"{tagtype}: {str(getattr(item, field))}") return info_lines @@ -1301,7 +1301,7 @@ class Server(BaseServer): yield ( f"bitrate: {item.bitrate / 1000}", - f"audio: {item.samplerate!s}:{item.bitdepth!s}:{item.channels!s}", + f"audio: {str(item.samplerate)}:{str(item.bitdepth)}:{str(item.channels)}", ) (pos, total) = self.player.time() diff --git c/beetsplug/edit.py i/beetsplug/edit.py index 61f2020a..20430255 100644 --- c/beetsplug/edit.py +++ i/beetsplug/edit.py @@ -47,7 +47,9 @@ def edit(filename, log): try: subprocess.call(cmd) except OSError as exc: - raise ui.UserError(f"could not run editor command {cmd[0]!r}: {exc}") + raise ui.UserError( + f"could not run editor command {repr(cmd[0])}: {exc}" + ) def dump(arg): diff --git c/beetsplug/replaygain.py i/beetsplug/replaygain.py index 78cce1e6..1c8aaaa9 100644 --- c/beetsplug/replaygain.py +++ i/beetsplug/replaygain.py @@ -534,7 +534,7 @@ class FfmpegBackend(Backend): if output[i].startswith(search): return i raise ReplayGainError( - f"ffmpeg output: missing {search!r} after line {start_line}" + f"ffmpeg output: missing {repr(search)} after line {start_line}" ) def _parse_float(self, line: bytes) -> float: @@ -547,7 +547,7 @@ class FfmpegBackend(Backend): parts = line.split(b":", 1) if len(parts) < 2: raise ReplayGainError( - f"ffmpeg output: expected key value pair, found {line!r}" + f"ffmpeg output: expected key value pair, found {repr(line)}" ) value = parts[1].lstrip() # strip unit @@ -557,7 +557,7 @@ class FfmpegBackend(Backend): return float(value) except ValueError: raise ReplayGainError( - f"ffmpeg output: expected float value, found {value!r}" + f"ffmpeg output: expected float value, found {repr(value)}" ) @@ -886,7 +886,7 @@ class GStreamerBackend(Backend): f = self._src.get_property("location") # A GStreamer error, either an unsupported format or a bug. self._error = ReplayGainError( - f"Error {err!r} - {debug!r} on file {f!r}" + f"Error {repr(err)} - {repr(debug)} on file {repr(f)}" ) def _on_tag(self, bus, message): diff --git c/beetsplug/thumbnails.py i/beetsplug/thumbnails.py index acca413d..0cde56c7 100644 --- c/beetsplug/thumbnails.py +++ i/beetsplug/thumbnails.py @@ -292,4 +292,6 @@ class GioURI(URIGetter): try: return uri.decode(util._fsencoding()) except UnicodeDecodeError: - raise RuntimeError(f"Could not decode filename from GIO: {uri!r}") + raise RuntimeError( + f"Could not decode filename from GIO: {repr(uri)}" + ) diff --git c/test/plugins/test_lyrics.py i/test/plugins/test_lyrics.py index 7cb081fc..484d4889 100644 --- c/test/plugins/test_lyrics.py +++ i/test/plugins/test_lyrics.py @@ -223,9 +223,9 @@ class LyricsAssertions: if not keywords <= words: details = ( - f"{keywords!r} is not a subset of {words!r}." - f" Words only in expected set {keywords - words!r}," - f" Words only in result set {words - keywords!r}." + f"{repr(keywords)} is not a subset of {repr(words)}." + f" Words only in expected set {repr(keywords - words)}," + f" Words only in result set {repr(words - keywords)}." ) self.fail(f"{details} : {msg}") diff --git c/test/plugins/test_player.py i/test/plugins/test_player.py index bf466e1b..e23b6396 100644 --- c/test/plugins/test_player.py +++ i/test/plugins/test_player.py @@ -132,7 +132,7 @@ class MPCResponse: cmd, rest = rest[2:].split("}") return False, (int(code), int(pos), cmd, rest[1:]) else: - raise RuntimeError(f"Unexpected status: {status!r}") + raise RuntimeError(f"Unexpected status: {repr(status)}") def _parse_body(self, body): """Messages are generally in the format "header: content". @@ -145,7 +145,7 @@ class MPCResponse: if not line: continue if ":" not in line: - raise RuntimeError(f"Unexpected line: {line!r}") + raise RuntimeError(f"Unexpected line: {repr(line)}") header, content = line.split(":", 1) content = content.lstrip() if header in repeated_headers: @@ -191,7 +191,7 @@ class MPCClient: responses.append(MPCResponse(response)) response = b"" elif not line: - raise RuntimeError(f"Unexpected response: {line!r}") + raise RuntimeError(f"Unexpected response: {repr(line)}") def serialise_command(self, command, *args): cmd = [command.encode("utf-8")] diff --git c/test/plugins/test_thumbnails.py i/test/plugins/test_thumbnails.py index 07775995..1931061b 100644 --- c/test/plugins/test_thumbnails.py +++ i/test/plugins/test_thumbnails.py @@ -71,7 +71,7 @@ class ThumbnailsTest(BeetsTestCase): return False if path == syspath(LARGE_DIR): return True - raise ValueError(f"unexpected path {path!r}") + raise ValueError(f"unexpected path {repr(path)}") mock_os.path.exists = exists plugin = ThumbnailsPlugin() --- beets/autotag/mb.py | 4 +++- beets/dbcore/db.py | 6 +++--- beets/dbcore/query.py | 16 +++++++++------- beets/library.py | 6 +++--- beets/test/_common.py | 4 ++-- beets/ui/commands.py | 2 +- beets/util/__init__.py | 2 +- beets/util/functemplate.py | 2 +- beetsplug/bpd/__init__.py | 4 ++-- beetsplug/edit.py | 4 +++- beetsplug/replaygain.py | 8 ++++---- beetsplug/thumbnails.py | 4 +++- test/plugins/test_lyrics.py | 6 +++--- test/plugins/test_player.py | 6 +++--- test/plugins/test_thumbnails.py | 2 +- 15 files changed, 42 insertions(+), 34 deletions(-) diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py index e16643d7d2..f152b56755 100644 --- a/beets/autotag/mb.py +++ b/beets/autotag/mb.py @@ -66,7 +66,9 @@ def __init__(self, reason, verb, query, tb=None): super().__init__(reason, verb, tb) def get_message(self): - return f"{self._reasonstr()} in {self.verb} with query {self.query!r}" + return ( + f"{self._reasonstr()} in {self.verb} with query {repr(self.query)}" + ) log = logging.getLogger("beets") diff --git a/beets/dbcore/db.py b/beets/dbcore/db.py index 55ba6f1105..5aa75aa593 100755 --- a/beets/dbcore/db.py +++ b/beets/dbcore/db.py @@ -397,7 +397,7 @@ def _awaken( def __repr__(self) -> str: name = type(self).__name__ - fields = ", ".join(f"{k}={v!r}" for k, v in dict(self).items()) + fields = ", ".join(f"{k}={repr(v)}" for k, v in dict(self).items()) return f"{name}({fields})" def clear_dirty(self): @@ -558,12 +558,12 @@ def __iter__(self) -> Iterator[str]: def __getattr__(self, key): if key.startswith("_"): - raise AttributeError(f"model has no attribute {key!r}") + raise AttributeError(f"model has no attribute {repr(key)}") else: try: return self[key] except KeyError: - raise AttributeError(f"no such field {key!r}") + raise AttributeError(f"no such field {repr(key)}") def __setattr__(self, key, value): if key.startswith("_"): diff --git a/beets/dbcore/query.py b/beets/dbcore/query.py index 357b568575..6e94ddd51b 100644 --- a/beets/dbcore/query.py +++ b/beets/dbcore/query.py @@ -171,7 +171,7 @@ def match(self, obj: Model) -> bool: def __repr__(self) -> str: return ( - f"{self.__class__.__name__}({self.field_name!r}, {self.pattern!r}, " + f"{self.__class__.__name__}({repr(self.field_name)}, {repr(self.pattern)}, " f"fast={self.fast})" ) @@ -210,7 +210,9 @@ def match(self, obj: Model) -> bool: return obj.get(self.field_name) is None def __repr__(self) -> str: - return f"{self.__class__.__name__}({self.field_name!r}, {self.fast})" + return ( + f"{self.__class__.__name__}({repr(self.field_name)}, {self.fast})" + ) class StringFieldQuery(FieldQuery[P]): @@ -503,7 +505,7 @@ def clause_with_joiner( return clause, subvals def __repr__(self) -> str: - return f"{self.__class__.__name__}({self.subqueries!r})" + return f"{self.__class__.__name__}({repr(self.subqueries)})" def __eq__(self, other) -> bool: return super().__eq__(other) and self.subqueries == other.subqueries @@ -548,7 +550,7 @@ def match(self, obj: Model) -> bool: def __repr__(self) -> str: return ( - f"{self.__class__.__name__}({self.pattern!r}, {self.fields!r}, " + f"{self.__class__.__name__}({repr(self.pattern)}, {repr(self.fields)}, " f"{self.query_class.__name__})" ) @@ -619,7 +621,7 @@ def match(self, obj: Model) -> bool: return not self.subquery.match(obj) def __repr__(self) -> str: - return f"{self.__class__.__name__}({self.subquery!r})" + return f"{self.__class__.__name__}({repr(self.subquery)})" def __eq__(self, other) -> bool: return super().__eq__(other) and self.subquery == other.subquery @@ -975,7 +977,7 @@ def sort(self, items): return items def __repr__(self): - return f"{self.__class__.__name__}({self.sorts!r})" + return f"{self.__class__.__name__}({repr(self.sorts)})" def __hash__(self): return hash(tuple(self.sorts)) @@ -1015,7 +1017,7 @@ def key(obj: Model) -> Any: def __repr__(self) -> str: return ( f"{self.__class__.__name__}" - f"({self.field!r}, ascending={self.ascending!r})" + f"({repr(self.field)}, ascending={repr(self.ascending)})" ) def __hash__(self) -> int: diff --git a/beets/library.py b/beets/library.py index 5911c87b60..4893911e3d 100644 --- a/beets/library.py +++ b/beets/library.py @@ -156,7 +156,7 @@ def col_clause(self): def __repr__(self) -> str: return ( - f"{self.__class__.__name__}({self.field!r}, {self.pattern!r}, " + f"{self.__class__.__name__}({repr(self.field)}, {repr(self.pattern)}, " f"fast={self.fast}, case_sensitive={self.case_sensitive})" ) @@ -735,7 +735,7 @@ def __repr__(self): # can even deadlock due to the database lock. name = type(self).__name__ keys = self.keys(with_album=False) - fields = (f"{k}={self[k]!r}" for k in keys) + fields = (f"{k}={repr(self[k])}" for k in keys) return f"{name}({', '.join(fields)})" def keys(self, computed=False, with_album=True): @@ -1578,7 +1578,7 @@ def parse_query_string(s, model_cls): The string is split into components using shell-like syntax. """ - message = f"Query is not unicode: {s!r}" + message = f"Query is not unicode: {repr(s)}" assert isinstance(s, str), message try: parts = shlex.split(s) diff --git a/beets/test/_common.py b/beets/test/_common.py index f3d3fa7ae2..1d2788c728 100644 --- a/beets/test/_common.py +++ b/beets/test/_common.py @@ -144,7 +144,7 @@ class Assertions: """A mixin with additional unit test assertions.""" def assertExists(self, path): # noqa - assert os.path.exists(syspath(path)), f"file does not exist: {path!r}" + assert os.path.exists(syspath(path)), f"file does not exist: {repr(path)}" def assertNotExists(self, path): # noqa assert not os.path.exists(syspath(path)), f"file exists: {repr(path)}" @@ -178,7 +178,7 @@ def __init__(self, output=None): def __str__(self): msg = "Attempt to read with no input provided." if self.output is not None: - msg += f" Output: {self.output!r}" + msg += f" Output: {repr(self.output)}" return msg diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 3042ca77b3..a717c94cb3 100755 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -213,7 +213,7 @@ def get_singleton_disambig_fields(info: hooks.TrackInfo) -> Sequence[str]: out = [] chosen_fields = config["match"]["singleton_disambig_fields"].as_str_seq() calculated_values = { - "index": f"Index {info.index!s}", + "index": f"Index {str(info.index)}", "track_alt": f"Track {info.track_alt}", "album": ( f"[{info.album}]" diff --git a/beets/util/__init__.py b/beets/util/__init__.py index bf424718b7..188e6f8df3 100644 --- a/beets/util/__init__.py +++ b/beets/util/__init__.py @@ -106,7 +106,7 @@ def _reasonstr(self): elif hasattr(self.reason, "strerror"): # i.e., EnvironmentError return self.reason.strerror else: - return f'"{self.reason!s}"' + return f'"{str(self.reason)}"' def get_message(self): """Create the human-readable description of the error, sans diff --git a/beets/util/functemplate.py b/beets/util/functemplate.py index 35f60b7d40..f149d370c2 100644 --- a/beets/util/functemplate.py +++ b/beets/util/functemplate.py @@ -166,7 +166,7 @@ def __init__(self, ident, args, original): self.original = original def __repr__(self): - return f"Call({self.ident!r}, {self.args!r}, {self.original!r})" + return f"Call({repr(self.ident)}, {repr(self.args)}, {repr(self.original)})" def evaluate(self, env): """Evaluate the function call in the environment, returning a diff --git a/beetsplug/bpd/__init__.py b/beetsplug/bpd/__init__.py index d6c75380a1..3336702c22 100644 --- a/beetsplug/bpd/__init__.py +++ b/beetsplug/bpd/__init__.py @@ -1142,7 +1142,7 @@ def _item_info(self, item): pass for tagtype, field in self.tagtype_map.items(): - info_lines.append(f"{tagtype}: {getattr(item, field)!s}") + info_lines.append(f"{tagtype}: {str(getattr(item, field))}") return info_lines @@ -1301,7 +1301,7 @@ def cmd_status(self, conn): yield ( f"bitrate: {item.bitrate / 1000}", - f"audio: {item.samplerate!s}:{item.bitdepth!s}:{item.channels!s}", + f"audio: {str(item.samplerate)}:{str(item.bitdepth)}:{str(item.channels)}", ) (pos, total) = self.player.time() diff --git a/beetsplug/edit.py b/beetsplug/edit.py index 61f2020ada..204302556a 100644 --- a/beetsplug/edit.py +++ b/beetsplug/edit.py @@ -47,7 +47,9 @@ def edit(filename, log): try: subprocess.call(cmd) except OSError as exc: - raise ui.UserError(f"could not run editor command {cmd[0]!r}: {exc}") + raise ui.UserError( + f"could not run editor command {repr(cmd[0])}: {exc}" + ) def dump(arg): diff --git a/beetsplug/replaygain.py b/beetsplug/replaygain.py index 78cce1e6ea..1c8aaaa9f0 100644 --- a/beetsplug/replaygain.py +++ b/beetsplug/replaygain.py @@ -534,7 +534,7 @@ def _find_line( if output[i].startswith(search): return i raise ReplayGainError( - f"ffmpeg output: missing {search!r} after line {start_line}" + f"ffmpeg output: missing {repr(search)} after line {start_line}" ) def _parse_float(self, line: bytes) -> float: @@ -547,7 +547,7 @@ def _parse_float(self, line: bytes) -> float: parts = line.split(b":", 1) if len(parts) < 2: raise ReplayGainError( - f"ffmpeg output: expected key value pair, found {line!r}" + f"ffmpeg output: expected key value pair, found {repr(line)}" ) value = parts[1].lstrip() # strip unit @@ -557,7 +557,7 @@ def _parse_float(self, line: bytes) -> float: return float(value) except ValueError: raise ReplayGainError( - f"ffmpeg output: expected float value, found {value!r}" + f"ffmpeg output: expected float value, found {repr(value)}" ) @@ -886,7 +886,7 @@ def _on_error(self, bus, message): f = self._src.get_property("location") # A GStreamer error, either an unsupported format or a bug. self._error = ReplayGainError( - f"Error {err!r} - {debug!r} on file {f!r}" + f"Error {repr(err)} - {repr(debug)} on file {repr(f)}" ) def _on_tag(self, bus, message): diff --git a/beetsplug/thumbnails.py b/beetsplug/thumbnails.py index acca413d01..0cde56c7d6 100644 --- a/beetsplug/thumbnails.py +++ b/beetsplug/thumbnails.py @@ -292,4 +292,6 @@ def uri(self, path): try: return uri.decode(util._fsencoding()) except UnicodeDecodeError: - raise RuntimeError(f"Could not decode filename from GIO: {uri!r}") + raise RuntimeError( + f"Could not decode filename from GIO: {repr(uri)}" + ) diff --git a/test/plugins/test_lyrics.py b/test/plugins/test_lyrics.py index 7cb081fc42..484d488912 100644 --- a/test/plugins/test_lyrics.py +++ b/test/plugins/test_lyrics.py @@ -223,9 +223,9 @@ def assertLyricsContentOk(self, title, text, msg=""): # noqa: N802 if not keywords <= words: details = ( - f"{keywords!r} is not a subset of {words!r}." - f" Words only in expected set {keywords - words!r}," - f" Words only in result set {words - keywords!r}." + f"{repr(keywords)} is not a subset of {repr(words)}." + f" Words only in expected set {repr(keywords - words)}," + f" Words only in result set {repr(words - keywords)}." ) self.fail(f"{details} : {msg}") diff --git a/test/plugins/test_player.py b/test/plugins/test_player.py index bf466e1b5b..e23b639649 100644 --- a/test/plugins/test_player.py +++ b/test/plugins/test_player.py @@ -132,7 +132,7 @@ def _parse_status(self, status): cmd, rest = rest[2:].split("}") return False, (int(code), int(pos), cmd, rest[1:]) else: - raise RuntimeError(f"Unexpected status: {status!r}") + raise RuntimeError(f"Unexpected status: {repr(status)}") def _parse_body(self, body): """Messages are generally in the format "header: content". @@ -145,7 +145,7 @@ def _parse_body(self, body): if not line: continue if ":" not in line: - raise RuntimeError(f"Unexpected line: {line!r}") + raise RuntimeError(f"Unexpected line: {repr(line)}") header, content = line.split(":", 1) content = content.lstrip() if header in repeated_headers: @@ -191,7 +191,7 @@ def get_response(self, force_multi=None): responses.append(MPCResponse(response)) response = b"" elif not line: - raise RuntimeError(f"Unexpected response: {line!r}") + raise RuntimeError(f"Unexpected response: {repr(line)}") def serialise_command(self, command, *args): cmd = [command.encode("utf-8")] diff --git a/test/plugins/test_thumbnails.py b/test/plugins/test_thumbnails.py index 07775995c1..1931061b95 100644 --- a/test/plugins/test_thumbnails.py +++ b/test/plugins/test_thumbnails.py @@ -71,7 +71,7 @@ def exists(path): return False if path == syspath(LARGE_DIR): return True - raise ValueError(f"unexpected path {path!r}") + raise ValueError(f"unexpected path {repr(path)}") mock_os.path.exists = exists plugin = ThumbnailsPlugin()