Skip to content

Commit

Permalink
Use 'repr' and 'str' in place of '!r' and '!s'
Browse files Browse the repository at this point in the history
See: <beetbox#5337 (comment)>

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()
  • Loading branch information
Arav K. committed Sep 8, 2024
1 parent b466388 commit ff5c1dd
Show file tree
Hide file tree
Showing 15 changed files with 42 additions and 34 deletions.
4 changes: 3 additions & 1 deletion beets/autotag/mb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions beets/dbcore/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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("_"):
Expand Down
16 changes: 9 additions & 7 deletions beets/dbcore/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})"
)

Expand Down Expand Up @@ -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]):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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__})"
)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions beets/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})"
)

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions beets/test/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)}"
Expand Down Expand Up @@ -186,7 +186,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


Expand Down
2 changes: 1 addition & 1 deletion beets/ui/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}]"
Expand Down
2 changes: 1 addition & 1 deletion beets/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,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
Expand Down
2 changes: 1 addition & 1 deletion beets/util/functemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions beetsplug/bpd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand Down
4 changes: 3 additions & 1 deletion beetsplug/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions beetsplug/replaygain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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)}"
)


Expand Down Expand Up @@ -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):
Expand Down
4 changes: 3 additions & 1 deletion beetsplug/thumbnails.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)}"
)
6 changes: 3 additions & 3 deletions test/plugins/test_lyrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

Expand Down
6 changes: 3 additions & 3 deletions test/plugins/test_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand All @@ -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:
Expand Down Expand Up @@ -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")]
Expand Down
2 changes: 1 addition & 1 deletion test/plugins/test_thumbnails.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit ff5c1dd

Please sign in to comment.