Skip to content

Move queries and types to respective modules #5775

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

snejus
Copy link
Member

@snejus snejus commented May 11, 2025

This PR moves query and type definitions away from library.py to dbcore to improve modularity and organization.

Key Changes:

  • Query and Type Relocation:
    • PathQuery and SingletonQuery moved from beets.library to beets.dbcore.query.
    • DateType, PathType (and its variants NullPathType), MusicalKey, and DurationType moved from beets.library to beets.dbcore.types.
    • The BLOB_TYPE definition was moved from beets.library to beets.dbcore.query and then referenced in beets.dbcore.types.
    • The human_seconds_short utility function was moved from beets.ui to beets.util due to circular dependency.
  • Test Modernization:
    • The PathQueryTest class in test/test_query.py has been rewritten to use pytest.mark.parametrize for more concise and readable test cases.
  • Import Updates: All internal references to these moved classes and functions have been updated across the codebase.

@snejus snejus requested review from Copilot, semohr and wisp3rwind May 11, 2025 18:11
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.

@snejus snejus changed the title Move queries types to respective modules Move queries and types to respective modules May 11, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves the modularity and organization of query and type definitions by relocating them from the legacy library module into separate modules within beets.dbcore. In addition, tests and dependent modules (such as those in beetsplug and beets.ui) are updated to reference the new locations.

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/test_query.py Refactored tests to use pytest fixtures and parametrize cases in the new TestPathQuery class.
test/test_library.py Removed legacy tests for library-specific type parsing.
beetsplug/web/init.py Updated import of PathQuery to use the relocated definition in beets.dbcore.query.
beetsplug/types.py Updated usage of DateType to types.DATE and removed legacy imports from beets.library.
beetsplug/spotify.py Replaced DateType instantiation with types.DATE for Spotify tags.
beetsplug/playlist.py Updated imports to source BLOB_TYPE and InQuery from beets.dbcore.query.
beetsplug/mpdstats.py Updated date field and query usage; note a key name change in item_types mapping.
beetsplug/metasync/itunes.py Replaced DateType with types.DATE.
beetsplug/metasync/amarok.py Replaced DateType with types.DATE in query definitions.
beetsplug/deezer.py Changed reference of DateType to types.DATE.
beets/util/init.py Introduced human_seconds_short function to replace the version previously in beets.ui.
beets/ui/commands.py Updated tag formatting to call util.human_seconds_short instead of ui.human_seconds_short.
beets/ui/init.py Removed the legacy human_seconds_short function.
beets/library.py Removed legacy query and type definitions (SingletonQuery, PathQuery, DateType, PathType, MusicalKey, DurationType) and updated references to their new locations.
beets/dbcore/types.py Incorporated type definitions (DateType, MusicalKey, DurationType, etc.) now sourced from the dbcore layer.
beets/dbcore/query.py Moved query definitions (e.g., PathQuery, SingletonQuery) into the beets.dbcore.query module.
Comments suppressed due to low confidence (1)

beetsplug/mpdstats.py:325

  • The key 'last_played' appears to have been mistakenly renamed to 'last_playtypes'. This typo may result in incorrect metadata handling; please revert the key name to 'last_played' to maintain consistency.
"last_playtypes": types.DATE,

@snejus snejus force-pushed the move-queries-types-to-respective-modules branch 4 times, most recently from 49f6be1 to 39cc0ee Compare May 12, 2025 08:50
@snejus snejus force-pushed the move-queries-types-to-respective-modules branch from 39cc0ee to c8cb902 Compare May 12, 2025 11:19
snejus added 5 commits May 12, 2025 13:45
And remove `force_implicit_query_detection` attribute from `PathQuery`
class.
The case_sensitive parameter was only used in tests, which now use
monkeypatch to control the behavior of util.case_sensitive() instead.
This simplifies the PathQuery initialization logic while maintaining
test coverage.
@snejus snejus force-pushed the move-queries-types-to-respective-modules branch from c8cb902 to 219aed9 Compare May 12, 2025 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants