1- # -*- coding: utf-8 -*-
21# Copyright (C) 2005 Michael Urman
32#
43# This program is free software; you can redistribute it and/or modify
76# (at your option) any later version.
87
98import warnings
9+ from typing import List
1010
1111from mutagen ._util import DictMixin , loadfile
12- from mutagen ._compat import izip
1312
1413
1514class FileType (DictMixin ):
@@ -83,9 +82,9 @@ def __delitem__(self, key):
8382 if self .tags is None :
8483 raise KeyError (key )
8584 else :
86- del ( self .tags [key ])
85+ del self .tags [key ]
8786
88- def keys (self ):
87+ def keys (self ) -> list :
8988 """Return a list of keys in the metadata tag.
9089
9190 If the file has no tags at all, an empty list is returned.
@@ -132,12 +131,13 @@ def save(self, filething=None, **kwargs):
132131 if self .tags is not None :
133132 return self .tags .save (filething , ** kwargs )
134133
135- def pprint (self ):
134+ def pprint (self ) -> str :
136135 """
137136 Returns:
138137 text: stream information and comment key=value pairs.
139138 """
140139
140+ assert self .info is not None
141141 stream = "%s (%s)" % (self .info .pprint (), self .mime [0 ])
142142 try :
143143 tags = self .tags .pprint ()
@@ -146,7 +146,7 @@ def pprint(self):
146146 else :
147147 return stream + ((tags and "\n " + tags ) or "" )
148148
149- def add_tags (self ):
149+ def add_tags (self ) -> None :
150150 """Adds new tags to the file.
151151
152152 Raises:
@@ -157,7 +157,7 @@ def add_tags(self):
157157 raise NotImplementedError
158158
159159 @property
160- def mime (self ):
160+ def mime (self ) -> List [ str ] :
161161 """A list of mime types (:class:`mutagen.text`)"""
162162
163163 mimes = []
@@ -168,7 +168,7 @@ def mime(self):
168168 return mimes
169169
170170 @staticmethod
171- def score (filename , fileobj , header ):
171+ def score (filename , fileobj , header ) -> int :
172172 """Returns a score for how likely the file can be parsed by this type.
173173
174174 Args:
@@ -196,7 +196,7 @@ class StreamInfo(object):
196196
197197 __module__ = "mutagen"
198198
199- def pprint (self ):
199+ def pprint (self ) -> str :
200200 """
201201 Returns:
202202 text: Print stream information
@@ -221,13 +221,13 @@ def File(filething, options=None, easy=False):
221221 filething (filething)
222222 options: Sequence of :class:`FileType` implementations,
223223 defaults to all included ones.
224- easy (bool): If the easy wrappers should be returnd if available.
224+ easy (bool): If the easy wrappers should be returned if available.
225225 For example :class:`EasyMP3 <mp3.EasyMP3>` instead of
226226 :class:`MP3 <mp3.MP3>`.
227227
228228 Returns:
229229 FileType: A FileType instance for the detected type or `None` in case
230- the type couln 't be determined.
230+ the type couldn 't be determined.
231231
232232 Raises:
233233 MutagenError: in case the detected type fails to load the file.
@@ -268,10 +268,12 @@ def File(filething, options=None, easy=False):
268268 from mutagen .smf import SMF
269269 from mutagen .tak import TAK
270270 from mutagen .dsf import DSF
271+ from mutagen .dsdiff import DSDIFF
272+ from mutagen .wave import WAVE
271273 options = [MP3 , TrueAudio , OggTheora , OggSpeex , OggVorbis , OggFLAC ,
272274 FLAC , AIFF , APEv2File , MP4 , ID3FileType , WavPack ,
273275 Musepack , MonkeysAudio , OptimFROG , ASF , OggOpus , AAC , AC3 ,
274- SMF , TAK , DSF ]
276+ SMF , TAK , DSF , DSDIFF , WAVE ]
275277
276278 if not options :
277279 return None
@@ -289,7 +291,7 @@ def File(filething, options=None, easy=False):
289291 results = [(Kind .score (filething .name , fileobj , header ), Kind .__name__ )
290292 for Kind in options ]
291293
292- results = list (izip (results , options ))
294+ results = list (zip (results , options ))
293295 results .sort ()
294296 (score , name ), Kind = results [- 1 ]
295297 if score > 0 :
0 commit comments