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

Properly type db on the model, sort out generic types issues #5545

Merged
merged 8 commits into from
Dec 19, 2024

Conversation

snejus
Copy link
Member

@snejus snejus commented Dec 10, 2024

Thanks to @wisp3rwind's suggestion this PR adds types to the relationship between Model, Database and Library.

Then I worked through the rest of the issues found in the edited files. Most of this involved providing type parameters for generic types (or defining defaults, rather 😉).

There queryparse module had a somewhat significant issue where the sorting construction logic only expected to receive FieldSort subclasses, while SmartArtistSort was not one. Thus SmartArtistSort has now been forced to behave and is a FieldSort subclass. It's also been moved to query.py module which is where the rest of sorts are defined.

@snejus snejus self-assigned this Dec 10, 2024
@snejus snejus requested a review from wisp3rwind December 10, 2024 16:36
Copy link

Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.

Copy link
Member

@wisp3rwind wisp3rwind left a comment

Choose a reason for hiding this comment

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

Woohoo, this really looks like the pieces are falling into place for wrapping up typings of beets' core 🎉

I left a few small nitpicks, overall this is looking great!

beets/dbcore/db.py Show resolved Hide resolved
beets/dbcore/query.py Show resolved Hide resolved
beets/dbcore/query.py Show resolved Hide resolved
beets/dbcore/query.py Show resolved Hide resolved
beets/dbcore/db.py Show resolved Hide resolved
beets/dbcore/types.py Show resolved Hide resolved
Copy link
Member

@wisp3rwind wisp3rwind left a comment

Choose a reason for hiding this comment

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

Looks good to me! Feel free to merge this after addressing the question of where the SmartArtistSort should go.

@snejus snejus merged commit fe0083b into fix-legalize-path Dec 19, 2024
11 checks passed
@snejus snejus deleted the fix-types-in-general branch December 19, 2024 16:36
snejus added a commit that referenced this pull request Dec 19, 2024
Thanks to @wisp3rwind's suggestion this PR adds types to the
relationship between `Model`, `Database` and `Library`.

Then I worked through the rest of the issues found in the edited files.
Most of this involved providing type parameters for generic types (or
defining defaults, rather 😉).

There `queryparse` module had a somewhat significant issue where the
sorting construction logic only expected to receive `FieldSort`
subclasses, while `SmartArtistSort` was not one. Thus `SmartArtistSort`
has now been forced to behave and is a `FieldSort` subclass. It's also
been moved to `query.py` module which is where the rest of sorts are
defined.
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