#488 Add some type annotations and ignore comments to make mypy happy

Open Christoph Reiter lazka
Coverage Reach
mutagen/id3/_frames.py mutagen/id3/_specs.py mutagen/id3/_tags.py mutagen/id3/_file.py mutagen/id3/_id3v1.py mutagen/id3/_util.py mutagen/id3/__init__.py mutagen/mp4/__init__.py mutagen/mp4/_as_entry.py mutagen/mp4/_atom.py mutagen/mp4/_util.py mutagen/asf/_objects.py mutagen/asf/_attrs.py mutagen/asf/__init__.py mutagen/asf/_util.py mutagen/_tools/mid3v2.py mutagen/_tools/mid3iconv.py mutagen/_tools/mid3cp.py mutagen/_tools/mutagen_pony.py mutagen/_tools/_util.py mutagen/_tools/moggsplit.py mutagen/_tools/mutagen_inspect.py mutagen/mp3/_util.py mutagen/mp3/__init__.py mutagen/_util.py mutagen/flac.py mutagen/apev2.py mutagen/ogg.py mutagen/easyid3.py mutagen/aac.py mutagen/_iff.py mutagen/dsf.py mutagen/ac3.py mutagen/musepack.py mutagen/_vorbis.py mutagen/dsdiff.py mutagen/easymp4.py mutagen/smf.py mutagen/tak.py mutagen/aiff.py mutagen/_file.py mutagen/wave.py mutagen/oggtheora.py mutagen/oggvorbis.py mutagen/oggflac.py mutagen/oggopus.py mutagen/oggspeex.py mutagen/wavpack.py mutagen/m4a.py mutagen/monkeysaudio.py mutagen/optimfrog.py mutagen/_tags.py mutagen/_riff.py mutagen/trueaudio.py mutagen/__init__.py mutagen/_constants.py tests/test_id3.py tests/test__id3frames.py tests/test_mp4.py tests/test__util.py tests/test_ogg.py tests/test_flac.py tests/test___init__.py tests/test_asf.py tests/test_easyid3.py tests/test_mp3.py tests/test_apev2.py tests/test_aiff.py tests/test_tools_mid3v2.py tests/test__id3specs.py tests/test__vorbis.py tests/test_oggvorbis.py tests/test_wave.py tests/test_tools_mid3cp.py tests/test_easymp4.py tests/test__riff.py tests/test_dsf.py tests/__init__.py tests/test_oggflac.py tests/test_musepack.py tests/test__id3util.py tests/test_tools_mid3iconv.py tests/test_aac.py tests/test_oggopus.py tests/test_wavpack.py tests/test_dsdiff.py tests/test_oggtheora.py tests/test_oggspeex.py tests/test_optimfrog.py tests/test_tools.py tests/test_monkeysaudio.py tests/test_trueaudio.py tests/test_tak.py tests/test_ac3.py tests/test_tools_moggsplit.py tests/test_encoding.py tests/test_tools_util.py tests/test_m4a.py tests/quality/test_flake8.py tests/test_tools_mutagen_inspect.py tests/test_smf.py tests/test_tools_mutagen_pony.py tests/test__iff.py

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.


@@ -81,16 +81,16 @@
Loading
81 81
82 82
    # Map (version, layer) tuples to bitrates.
83 83
    __BITRATE = {
84 -
        (1, 1): [0, 32, 64, 96, 128, 160, 192, 224,
85 -
                 256, 288, 320, 352, 384, 416, 448],
86 -
        (1, 2): [0, 32, 48, 56, 64, 80, 96, 112, 128,
87 -
                 160, 192, 224, 256, 320, 384],
88 -
        (1, 3): [0, 32, 40, 48, 56, 64, 80, 96, 112,
89 -
                 128, 160, 192, 224, 256, 320],
90 -
        (2, 1): [0, 32, 48, 56, 64, 80, 96, 112, 128,
91 -
                 144, 160, 176, 192, 224, 256],
92 -
        (2, 2): [0, 8, 16, 24, 32, 40, 48, 56, 64,
93 -
                 80, 96, 112, 128, 144, 160],
84 +
        (1., 1): [0, 32, 64, 96, 128, 160, 192, 224,
85 +
                  256, 288, 320, 352, 384, 416, 448],
86 +
        (1., 2): [0, 32, 48, 56, 64, 80, 96, 112, 128,
87 +
                  160, 192, 224, 256, 320, 384],
88 +
        (1., 3): [0, 32, 40, 48, 56, 64, 80, 96, 112,
89 +
                  128, 160, 192, 224, 256, 320],
90 +
        (2., 1): [0, 32, 48, 56, 64, 80, 96, 112, 128,
91 +
                  144, 160, 176, 192, 224, 256],
92 +
        (2., 2): [0, 8, 16, 24, 32, 40, 48, 56, 64,
93 +
                  80, 96, 112, 128, 144, 160],
94 94
    }
95 95
96 96
    __BITRATE[(2, 3)] = __BITRATE[(2, 2)]
@@ -479,4 +479,4 @@
Loading
479 479
    """
480 480
481 481
    from mutagen.easyid3 import EasyID3 as ID3
482 -
    ID3 = ID3
482 +
    ID3 = ID3  # type: ignore

@@ -365,8 +365,7 @@
Loading
365 365
                    self.__parse_text(atom, data, implicit=False)
366 366
            except MP4MetadataError:
367 367
                # parsing failed, save them so we can write them back
368 -
                key = _name2key(atom.name)
369 -
                self._failed_atoms.setdefault(key, []).append(data)
368 +
                self._failed_atoms.setdefault(_name2key(atom.name), []).append(data)
370 369
371 370
    def __setitem__(self, key, value):
372 371
        if not isinstance(key, str):

@@ -8,6 +8,7 @@
Loading
8 8
# (at your option) any later version.
9 9
10 10
import struct
11 +
from typing import Dict, Type
11 12
12 13
from mutagen._util import cdata, get_size
13 14
from mutagen._tags import PaddingInfo
@@ -19,8 +20,8 @@
Loading
19 20
class BaseObject(object):
20 21
    """Base ASF object."""
21 22
22 -
    GUID = None
23 -
    _TYPES = {}
23 +
    GUID: bytes
24 +
    _TYPES: "Dict[bytes, Type[BaseObject]]" = {}
24 25
25 26
    def __init__(self):
26 27
        self.objects = []

@@ -208,7 +208,7 @@
Loading
208 208
        return u"\n".join(tags)
209 209
210 210
211 -
class VCommentDict(VComment, DictMixin):
211 +
class VCommentDict(VComment, DictMixin):  # type: ignore
212 212
    """A VComment that looks like a dictionary.
213 213
214 214
    This object differs from a dictionary in two ways. First,

@@ -8,6 +8,7 @@
Loading
8 8
9 9
import zlib
10 10
from struct import unpack
11 +
from typing import Sequence
11 12
12 13
from ._util import ID3JunkFrameError, ID3EncryptionUnsupportedError, unsynch, \
13 14
    ID3SaveConfig, error
@@ -17,7 +18,7 @@
Loading
17 18
    VolumeAdjustmentSpec, ChannelSpec, MultiSpec, SynchronizedTextSpec, \
18 19
    KeyEventSpec, TimeStampSpec, EncodedNumericPartTextSpec, \
19 20
    EncodedNumericTextSpec, SpecError, PictureTypeSpec, ID3FramesSpec, \
20 -
    Latin1TextListSpec, CTOCFlagsSpec, FrameIDSpec, RVASpec
21 +
    Latin1TextListSpec, CTOCFlagsSpec, FrameIDSpec, RVASpec, Spec
21 22
22 23
23 24
def _bytes2key(b):
@@ -49,8 +50,8 @@
Loading
49 50
    FLAG24_UNSYNCH = 0x0002
50 51
    FLAG24_DATALEN = 0x0001
51 52
52 -
    _framespec = []
53 -
    _optionalspec = []
53 +
    _framespec: Sequence[Spec] = []
54 +
    _optionalspec: Sequence[Spec] = []
54 55
55 56
    def __init__(self, *args, **kwargs):
56 57
        if len(args) == 1 and len(kwargs) == 0 and \
@@ -291,7 +292,7 @@
Loading
291 292
        frame._readData(header, data)
292 293
        return frame
293 294
294 -
    def __hash__(self):
295 +
    def __hash__(self: object):
295 296
        raise TypeError("Frame objects are unhashable")
296 297
297 298
@@ -514,7 +515,7 @@
Loading
514 515
    ASCII.
515 516
    """
516 517
517 -
    _framespec = [
518 +
    _framespec: Sequence[Spec] = [
518 519
        Latin1TextSpec('url'),
519 520
    ]
520 521

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Everything is accounted for!

No changes detected that need to be reviewed.
What changes does Codecov check for?
Lines, not adjusted in diff, that have changed coverage data.
Files that introduced coverage data that had none before.
Files that have missing coverage data that once were tracked.
Files Coverage
mutagen 0.01% 90.88%
tests 98.62%
Project Totals (103 files) 94.53%
Loading