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

typing: corrections for dbcore/types.py #4828

Merged
merged 2 commits into from
Jun 26, 2023

Conversation

wisp3rwind
Copy link
Member

Yet another follow-up to dbcore typing. I've had this in the pipeline for a while, but only now got around to finishing it up and figure out the last bits around handling the model_type Type-valued field.

Please have a close look at this PR; does the approach look sensible? I restructured the class hierarchy a bit to avoid some conflicting signature. This could potentially break plugins that depend on details of the db and type handling (as it turns out, the edit plugin does).

@wisp3rwind wisp3rwind force-pushed the dbcore_typing_2 branch 2 times, most recently from 813cdac to f98987c Compare June 23, 2023 14:57
@wisp3rwind
Copy link
Member Author

Oh, given the second commit here: Shall we drop Python 3.7 very soon? It's EOL in a few days if I'm no mistaken.

Copy link
Member

@sampsyo sampsyo left a comment

Choose a reason for hiding this comment

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

Wow, this is very tricky indeed! It was a really good idea to parameterize Type on both a "main" type and a null type; this seems to help clarify types work in general (i.e., on "input," you're supposed to provide the main type; on "output," you need to expect that you might get the null type as well). Really nice work nailing this down!

I have few assorted thoughts scattered throughout.

beets/dbcore/types.py Outdated Show resolved Hide resolved
beets/dbcore/types.py Show resolved Hide resolved
beets/dbcore/types.py Outdated Show resolved Hide resolved
beets/dbcore/types.py Outdated Show resolved Hide resolved
beets/dbcore/types.py Outdated Show resolved Hide resolved
@wisp3rwind
Copy link
Member Author

Thanks for the swift and thorough review! I've addressed the comments and rebased, let's see what CI says.

tricky...
- the only way I found to express the concept of the "associated type"
  (in Rust lingo) model_type was by making Type generic over its value
  and null types.
- in addition, the class hierarchy of Integer and Float types had to be
  modified, since previously some of them would have conflicting null
  types relative to their super class (this required a change to the
  edit plugin; hopefully no more breakage is caused by these changes)
- don't import the query module, but only the relevant Query's to avoid
  confusing the module query and the class variable query
Copy link
Member

@sampsyo sampsyo left a comment

Choose a reason for hiding this comment

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

Awesome; this looks great!!

@sampsyo sampsyo merged commit 998d55b into beetbox:master Jun 26, 2023
@wisp3rwind wisp3rwind deleted the dbcore_typing_2 branch June 30, 2023 12:39
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