diff options
| author | jvoisin | 2023-11-13 15:03:42 +0100 |
|---|---|---|
| committer | jvoisin | 2023-11-13 15:03:42 +0100 |
| commit | 0fcafa2eddd34f15f34ad0a40f662cf3d5bcef0e (patch) | |
| tree | da8fc5b1469f53fc6f5c3049b13f20cbcc2abe09 /libmat2 | |
| parent | 7405955ab5995b06c929148f0439670c9be7cb2d (diff) | |
Raise a ValueError for invalid FLAC files to please mypy
Diffstat (limited to 'libmat2')
| -rw-r--r-- | libmat2/abstract.py | 5 | ||||
| -rw-r--r-- | libmat2/audio.py | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/libmat2/abstract.py b/libmat2/abstract.py index c531fbd..adf384a 100644 --- a/libmat2/abstract.py +++ b/libmat2/abstract.py | |||
| @@ -34,7 +34,10 @@ class AbstractParser(abc.ABC): | |||
| 34 | 34 | ||
| 35 | @abc.abstractmethod | 35 | @abc.abstractmethod |
| 36 | def get_meta(self) -> Dict[str, Union[str, Dict]]: | 36 | def get_meta(self) -> Dict[str, Union[str, Dict]]: |
| 37 | """Return all the metadata of the current file""" | 37 | """Return all the metadata of the current file |
| 38 | |||
| 39 | :raises RuntimeError: Raised if the cleaning process went wrong. | ||
| 40 | """ | ||
| 38 | 41 | ||
| 39 | @abc.abstractmethod | 42 | @abc.abstractmethod |
| 40 | def remove_all(self) -> bool: | 43 | def remove_all(self) -> bool: |
diff --git a/libmat2/audio.py b/libmat2/audio.py index 4e447c5..2029d9c 100644 --- a/libmat2/audio.py +++ b/libmat2/audio.py | |||
| @@ -82,6 +82,8 @@ class FLACParser(MutagenParser): | |||
| 82 | with open(fname, 'wb') as f: | 82 | with open(fname, 'wb') as f: |
| 83 | f.write(picture.data) | 83 | f.write(picture.data) |
| 84 | p, _ = parser_factory.get_parser(fname) # type: ignore | 84 | p, _ = parser_factory.get_parser(fname) # type: ignore |
| 85 | if p is None: | ||
| 86 | raise ValueError | ||
| 85 | p.sandbox = self.sandbox | 87 | p.sandbox = self.sandbox |
| 86 | # Mypy chokes on ternaries :/ | 88 | # Mypy chokes on ternaries :/ |
| 87 | meta[name] = p.get_meta() if p else 'harmful data' # type: ignore | 89 | meta[name] = p.get_meta() if p else 'harmful data' # type: ignore |
