mutagen icon indicating copy to clipboard operation
mutagen copied to clipboard

Type `tag` properly

Open sakgoyal opened this issue 4 months ago • 2 comments

https://github.com/quodlibet/mutagen/blob/9e3ff54b7413b36046754d06f7c50a110ee8327b/mutagen/_file.py#L39

Here, tag should be typed as ID3 | None = None right? (Optional[ID3] for python<3.12)

sakgoyal avatar Aug 29 '25 16:08 sakgoyal

I had an interest in typing this too and had a look, sadly it is not that easy.

Have a look where tags are assigned, tags can be an instance of a number of different classes (all inheriting from Tags but some also inheriting from Metadata and/or DictProxy ).

E.g.: https://github.com/quodlibet/mutagen/blob/9e3ff54b7413b36046754d06f7c50a110ee8327b/mutagen/m4a.py#L91

https://github.com/quodlibet/mutagen/blob/4394c43cb5e17812b93be2878e5def924caf858f/mutagen/dsdiff.py#L257

semohr avatar Oct 21 '25 17:10 semohr

can't the type be overridden in those instances then?

sakgoyal avatar Oct 21 '25 23:10 sakgoyal