3131FEATURES_IMPLEMENTED = list (_FEATURE_MAPPING .keys ())
3232
3333
34- def read (device = None , features = None ):
34+ def read (
35+ device : str | bytes | None = None , features : list [str ] | None = None
36+ ) -> "Disc" :
3537 """Reads the TOC from the device given as string
3638 and returns a :class:`Disc` object.
3739
38- That string can be either of :obj:`str <python:str>` or :obj:`bytes`.
40+ The device string can be either of :obj:`str <python:str>` or :obj:`bytes`.
3941 However, it should in no case contain non-ASCII characters.
4042 If no device is given, a default, also given by :func:`get_default_device`
4143 is used.
@@ -48,27 +50,31 @@ def read(device=None, features=None):
4850 A :exc:`DiscError` exception is raised when the reading fails,
4951 and :exc:`NotImplementedError` when libdiscid doesn't support
5052 reading discs on the current platform.
53+
54+ :param device: the device name to use or :obj:`None` for using the default device
55+ :param features: list of features to enable ("read" will always be assumed)
5156 """
5257 disc = Disc ()
5358 disc .read (device , features )
5459 return disc
5560
5661
57- def put (first , last , disc_sectors , track_offsets ) :
62+ def put (first : int , last : int , disc_sectors : int , track_offsets : list [ int ]) -> "Disc" :
5863 """Creates a TOC based on the information given
5964 and returns a :class:`Disc` object.
6065
61- Takes the `first` track and `last` **audio** track as :obj:`int`.
62- `disc_sectors` is the end of the last audio track,
63- normally the total sector count of the disc.
64- `track_offsets` is a list of all audio track offsets.
65-
6666 Depending on how you get the total sector count,
6767 you might have to subtract 11400 (2:32 min.) for discs with data tracks.
6868
6969 A :exc:`TOCError` exception is raised when illegal parameters
7070 are provided.
7171
72+ :param first: number of the first audio track
73+ :param last: number of the last audio track
74+ :param disc_sectors: the end of the last audio track, normally the total
75+ sector count of the disc
76+ :param track_offsets: list of all audio track offsets
77+
7278 .. seealso:: :musicbrainz:`Disc ID Calculation`
7379 """
7480 disc = Disc ()
@@ -125,7 +131,9 @@ def _get_error_msg(self):
125131 except AttributeError :
126132 pass
127133
128- def read (self , device = None , features = None ):
134+ def read (
135+ self , device : str | bytes | None = None , features : list [str ] | None = None
136+ ) -> bool :
129137 """Reads the TOC from the device given as string
130138
131139 The user is supposed to use :func:`discid.read`.
@@ -162,7 +170,9 @@ def read(self, device=None, features=None):
162170 _LIB .discid_put .argtypes = (c_void_p , c_int , c_int , c_void_p )
163171 _LIB .discid_put .restype = c_int
164172
165- def put (self , first , last , disc_sectors , track_offsets ):
173+ def put (
174+ self , first : int , last : int , disc_sectors : int , track_offsets : list [int ]
175+ ) -> bool :
166176 """Creates a TOC based on the input given.
167177
168178 The user is supposed to use :func:`discid.put`.
@@ -282,21 +292,21 @@ def _get_mcn(self):
282292 return None
283293
284294 @property
285- def id (self ):
295+ def id (self ) -> str :
286296 """This is the MusicBrainz :musicbrainz:`Disc ID`,
287297 a :obj:`str <python:str>` object.
288298 """
289299 return self ._get_id ()
290300
291301 @property
292- def freedb_id (self ):
302+ def freedb_id (self ) -> str :
293303 """This is the :musicbrainz:`FreeDB` Disc ID (without category),
294304 a :obj:`str <python:str>` object.
295305 """
296306 return self ._get_freedb_id ()
297307
298308 @property
299- def submission_url (self ):
309+ def submission_url (self ) -> str | None :
300310 """Disc ID / TOC Submission URL for MusicBrainz
301311
302312 With this url you can submit the current TOC
@@ -313,7 +323,7 @@ def submission_url(self):
313323 return url
314324
315325 @property
316- def toc_string (self ):
326+ def toc_string (self ) -> str :
317327 """The TOC suitable as value of the `toc parameter`
318328 when accessing the MusicBrainz Web Service.
319329
@@ -337,33 +347,30 @@ def toc_string(self):
337347 return toc_string
338348
339349 @property
340- def first_track_num (self ):
350+ def first_track_num (self ) -> int :
341351 """Number of the first track"""
342352 return self ._get_first_track_num ()
343353
344354 @property
345- def last_track_num (self ):
355+ def last_track_num (self ) -> int :
346356 """Number of the last **audio** track"""
347357 return self ._get_last_track_num ()
348358
349359 @property
350- def sectors (self ):
360+ def sectors (self ) -> int :
351361 """Total length in sectors"""
352362 return self ._get_sectors ()
353363
354364 length = sectors
355365 """This is an alias for :attr:`sectors`"""
356366
357367 @property
358- def seconds (self ):
368+ def seconds (self ) -> int :
359369 """Total length in seconds"""
360- if self .sectors is None :
361- return None
362- else :
363- return _sectors_to_seconds (self .sectors )
370+ return _sectors_to_seconds (self .sectors )
364371
365372 @property
366- def mcn (self ):
373+ def mcn (self ) -> str | None :
367374 """This is the Media Catalogue Number (MCN/UPC/EAN)
368375
369376 It is set after the `"mcn"` feature was requested on a read
@@ -373,7 +380,7 @@ def mcn(self):
373380 return self ._get_mcn ()
374381
375382 @property
376- def tracks (self ):
383+ def tracks (self ) -> list [ Track ] :
377384 """A list of :class:`Track` objects for this Disc."""
378385 tracks = []
379386 assert self ._success
@@ -382,7 +389,7 @@ def tracks(self):
382389 return tracks
383390
384391 @property
385- def cddb_query_string (self ):
392+ def cddb_query_string (self ) -> str :
386393 """A CDDB query string suitable for querying CDDB servers.
387394
388395 This is a :obj:`str <python:str>` object
0 commit comments