beetbox / beets

music library manager and MusicBrainz tagger
http://beets.io/
MIT License
12.57k stars 1.8k forks source link

Resolve some 'mypy' errors #5282

Closed bal-e closed 2 weeks ago

bal-e commented 3 weeks ago

Description

I noticed that some development work was waiting on cleaner mypy runs, so I thought I would help out a bit. This PR just contains a number of miscellaneous fixes across the codebase that I hit. I'm happy to add more, or remove any problematic changes (though I don't think I've broken anything, only type annotations have changed).

To Do

bal-e commented 3 weeks ago

Updated to account for merge conflicts.

bal-e commented 3 weeks ago

Many remaining mypy errors are from util/__init__.py, but I'm not touching it right now since there are other PRs addressing it. The remaining type errors mostly stem from APIs that allow for arbitrary-type data storage, such as the database and AlbumInfo / TrackInfo. For the latter two, some refactoring could eliminate type errors (organizing expected fields into new classes with strongly-typed attributes and turning AttrDict into a container object managing those classes). I'm not sure how to eliminate mypy errors related to dbcore and the query subsystems.

bal-e commented 2 weeks ago

I don't think this PR needs a changelog entry, but please confirm if so.

snejus commented 2 weeks ago

Nah I don't think the changelog entry is needed!