typing: type beets.library.exceptions

This commit is contained in:
Šarūnas Nejus
2026-07-06 04:37:36 +01:00
parent 2cf20aa60c
commit fcee48fb0a

View File

@@ -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__()}"