diff options
| author | jvoisin | 2022-08-28 22:29:06 +0200 |
|---|---|---|
| committer | jvoisin | 2022-08-28 22:29:06 +0200 |
| commit | cc5be8608b49d74a633b80a95a49a018d4dcd477 (patch) | |
| tree | 322c21ba2543831d5a1804ebce50a3f7c2391029 /libmat2/audio.py | |
| parent | 292f44c0861a57b54a289641ead7e59f158e307e (diff) | |
Simplify the typing annotations
Diffstat (limited to 'libmat2/audio.py')
| -rw-r--r-- | libmat2/audio.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/libmat2/audio.py b/libmat2/audio.py index 598d93d..366d451 100644 --- a/libmat2/audio.py +++ b/libmat2/audio.py | |||
| @@ -2,7 +2,7 @@ import mimetypes | |||
| 2 | import os | 2 | import os |
| 3 | import shutil | 3 | import shutil |
| 4 | import tempfile | 4 | import tempfile |
| 5 | from typing import Dict, Union | 5 | from typing import Union |
| 6 | 6 | ||
| 7 | import mutagen | 7 | import mutagen |
| 8 | 8 | ||
| @@ -18,7 +18,7 @@ class MutagenParser(abstract.AbstractParser): | |||
| 18 | except mutagen.MutagenError: | 18 | except mutagen.MutagenError: |
| 19 | raise ValueError | 19 | raise ValueError |
| 20 | 20 | ||
| 21 | def get_meta(self) -> Dict[str, Union[str, dict]]: | 21 | def get_meta(self) -> dict[str, Union[str, dict]]: |
| 22 | f = mutagen.File(self.filename) | 22 | f = mutagen.File(self.filename) |
| 23 | if f.tags: | 23 | if f.tags: |
| 24 | return {k:', '.join(map(str, v)) for k, v in f.tags.items()} | 24 | return {k:', '.join(map(str, v)) for k, v in f.tags.items()} |
| @@ -38,8 +38,8 @@ class MutagenParser(abstract.AbstractParser): | |||
| 38 | class MP3Parser(MutagenParser): | 38 | class MP3Parser(MutagenParser): |
| 39 | mimetypes = {'audio/mpeg', } | 39 | mimetypes = {'audio/mpeg', } |
| 40 | 40 | ||
| 41 | def get_meta(self) -> Dict[str, Union[str, dict]]: | 41 | def get_meta(self) -> dict[str, Union[str, dict]]: |
| 42 | metadata = {} # type: Dict[str, Union[str, dict]] | 42 | metadata = {} # type: dict[str, Union[str, dict]] |
| 43 | meta = mutagen.File(self.filename).tags | 43 | meta = mutagen.File(self.filename).tags |
| 44 | if not meta: | 44 | if not meta: |
| 45 | return metadata | 45 | return metadata |
| @@ -68,7 +68,7 @@ class FLACParser(MutagenParser): | |||
| 68 | f.save(deleteid3=True) | 68 | f.save(deleteid3=True) |
| 69 | return True | 69 | return True |
| 70 | 70 | ||
| 71 | def get_meta(self) -> Dict[str, Union[str, dict]]: | 71 | def get_meta(self) -> dict[str, Union[str, dict]]: |
| 72 | meta = super().get_meta() | 72 | meta = super().get_meta() |
| 73 | for num, picture in enumerate(mutagen.File(self.filename).pictures): | 73 | for num, picture in enumerate(mutagen.File(self.filename).pictures): |
| 74 | name = picture.desc if picture.desc else 'Cover %d' % num | 74 | name = picture.desc if picture.desc else 'Cover %d' % num |
