Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve some 'mypy' errors #5282

Merged
merged 5 commits into from
Jun 13, 2024
Merged

Resolve some 'mypy' errors #5282

merged 5 commits into from
Jun 13, 2024

Conversation

bal-e
Copy link
Member

@bal-e bal-e commented Jun 3, 2024

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

  • Documentation
  • Changelog
  • Tests

@bal-e
Copy link
Member Author

bal-e commented Jun 6, 2024

Updated to account for merge conflicts.

@bal-e
Copy link
Member Author

bal-e commented Jun 8, 2024

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.

Copy link
Member

@snejus snejus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this, thank you. Just one small comment

beets/autotag/match.py Show resolved Hide resolved
beets/dbcore/types.py Show resolved Hide resolved
beets/library.py Outdated Show resolved Hide resolved
Arav K. added 5 commits June 12, 2024 15:58
'typing.Never' was introduced later, and 'typing.Type' was used instead
of just 'type' until 3.9.  This commit will likely be reverted over time
as these 3.8 etc. get dropped.
In changing the implementation of the 'AttrDict' class to eliminate
'mypy' errors, I had accidentally removed support for storing 'None'
values in the dict.  This commit restores support for them.
Apparently Python 3.8 does not support generic type parameters on the
built-in 'queue.Queue' type?
I had misinterpreted the pattern type for this query to be 'NoReturn',
thinking that it accepted no pattern at all (even so, I should have
typed it as 'None').  However, it does accept a pattern, and uses it to
decide whether to select only singletons or none at all.

See <beetbox#5282 (comment)>.
@bal-e
Copy link
Member Author

bal-e commented Jun 12, 2024

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

@snejus
Copy link
Member

snejus commented Jun 13, 2024

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

Copy link
Member

@snejus snejus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you!

@snejus snejus merged commit b583fb7 into beetbox:master Jun 13, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants