-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add fallback for item access to album's attributes #2988
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7251544
Add fallback for item access to album's attributes
FichteFoll a112358
Override FormattedItemMapping.model_keys
FichteFoll e17c478
Cache an item's album with a property
FichteFoll dfc23e8
Implement database and model revision checking
FichteFoll 26b1aa9
Add changelog for #2797
FichteFoll ed76da5
Add changelog section for developers
FichteFoll 9c35da6
Update the items' type information from plugins
FichteFoll eda9930
Merge remote-tracking branch 'upstream/master' into pr/item-album-fal…
FichteFoll 701cd6c
Merge remote-tracking branch 'upstream/master' into pr/item-album-fal…
FichteFoll 2d024d2
Avoid overeager inclusion of album attributes
FichteFoll 5ace2b6
Merge remote-tracking branch 'upstream/master' into pr/item-album-fal…
FichteFoll 20ec011
Merge remote-tracking branch 'upstream/master' into pr/item-album-fal…
FichteFoll 09a6ec4
Merge branch 'master' into pr/item-album-fallback
sampsyo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really just a matter of aesthetics, but one alternative would be to have
get
just do the necessary exception handling. That is,__getitem__
would continue to contain all the "real" logic and include theraise
at the end. Then,get
would change to contain:That would help keep the docstring for
get
sensible, for example.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might have been a bit of premature optimization, but afaik exception handling in Python isn't exactly performant (creation of exception object, traceback, caching of frames etc.) and combining the code paths was pretty trivial. I also liked that I could use this to have a short implementation in
Item.get
.The docstring issue doesn't bother me personally because it properly describes what
get
can do. It does have a different function signature thandict.get
, which we need for thewith_album
parameter anyway, but it's still compatible. I think I preferOptionally
overAlternatively
, however.I would have made those parameters keyword-only, but that is only possible in Python 3.