1
0
mirror of synced 2024-11-22 01:04:23 +01:00

Raise a ValueError for invalid FLAC files to please mypy

This commit is contained in:
jvoisin 2023-11-13 15:03:42 +01:00
parent 7405955ab5
commit 0fcafa2edd
2 changed files with 6 additions and 1 deletions

View File

@ -34,7 +34,10 @@ class AbstractParser(abc.ABC):
@abc.abstractmethod @abc.abstractmethod
def get_meta(self) -> Dict[str, Union[str, Dict]]: def get_meta(self) -> Dict[str, Union[str, Dict]]:
"""Return all the metadata of the current file""" """Return all the metadata of the current file
:raises RuntimeError: Raised if the cleaning process went wrong.
"""
@abc.abstractmethod @abc.abstractmethod
def remove_all(self) -> bool: def remove_all(self) -> bool:

View File

@ -82,6 +82,8 @@ class FLACParser(MutagenParser):
with open(fname, 'wb') as f: with open(fname, 'wb') as f:
f.write(picture.data) f.write(picture.data)
p, _ = parser_factory.get_parser(fname) # type: ignore p, _ = parser_factory.get_parser(fname) # type: ignore
if p is None:
raise ValueError
p.sandbox = self.sandbox p.sandbox = self.sandbox
# Mypy chokes on ternaries :/ # Mypy chokes on ternaries :/
meta[name] = p.get_meta() if p else 'harmful data' # type: ignore meta[name] = p.get_meta() if p else 'harmful data' # type: ignore