mirror of
https://github.com/beetbox/beets.git
synced 2026-07-16 14:07:40 -04:00
typing: type beets.library.exceptions
This commit is contained in:
@@ -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__()}"
|
||||
|
||||
Reference in New Issue
Block a user