diff --git a/beets/library/exceptions.py b/beets/library/exceptions.py index 39725a4e4..df095aeb8 100644 --- a/beets/library/exceptions.py +++ b/beets/library/exceptions.py @@ -8,7 +8,7 @@ class FileOperationError(Exception): error, and an unhandled Mutagen exception. """ - def __init__(self, path, reason): + def __init__(self, path: bytes, reason: Exception) -> None: """Create an exception describing an operation on the file at `path` with the underlying (chained) exception `reason`. """ @@ -16,7 +16,7 @@ class FileOperationError(Exception): self.path = path self.reason = reason - def __str__(self): + def __str__(self) -> str: """Get a string representing the error. Describe both the underlying reason and the file path in question. @@ -27,7 +27,7 @@ class FileOperationError(Exception): class ReadError(FileOperationError): """An error while reading a file (i.e. in `Item.read`).""" - def __str__(self): + def __str__(self) -> str: # Formatting super() directly stringifies the proxy object, so call # __str__ explicitly to forward to FileOperationError.__str__. return f"error reading {super().__str__()}" @@ -36,7 +36,7 @@ class ReadError(FileOperationError): class WriteError(FileOperationError): """An error while writing a file (i.e. in `Item.write`).""" - def __str__(self): + def __str__(self) -> str: # Formatting super() directly stringifies the proxy object, so call # __str__ explicitly to forward to FileOperationError.__str__. return f"error writing {super().__str__()}"