Commit graph

13230 commits

Author SHA1 Message Date
Šarūnas Nejus
98bb7f12be
refactor: convert _queries from class attributes to cached properties
Convert _queries from mutable class attributes to cached class properties
that dynamically fetch plugin queries. This eliminates the need for manual
query registration and cleanup in plugin loading/unloading logic.
2025-07-16 14:45:25 +01:00
Šarūnas Nejus
3be4a89aee
refactor: convert _types from class attributes to cached properties
Convert static _types dictionaries to dynamic cached class properties to
enable proper plugin type inheritance and avoid mutating shared state.

Key changes:
- Replace static _types dicts with @cached_classproperty decorators
- Update cached_classproperty to support proper caching with class names
- Remove manual _types mutation in plugin loading/unloading
- Add pluginload event and cache clearing for proper plugin integration
- Fix test to trigger type checking during item creation

This ensures plugin types are properly inherited through the class
hierarchy and eliminates issues with shared mutable state between
test runs.
2025-07-16 14:45:25 +01:00
Šarūnas Nejus
852cbd2650
Fix a pair of regressions, types and enforce mypy in CI (#5870)
**Bug Fixes**:
   - Wrong `raw_seconds_short` module in `DurationQuery`.
   - Missing `byte_paths` variable in `import_func`.

Otherwise

- Addressed all static type checking errors in the codebase (except
`spotify` plugin which has already been fixed in a separate PR)
- Removed `continue-on-error` from in `mypy` CI job, which means any
errors in type checking will now fail the CI job.
2025-07-16 14:36:13 +01:00
Šarūnas Nejus
ada672b759
Do not install not required apt deps in ci 2025-07-16 14:30:03 +01:00
Šarūnas Nejus
7509843517
Fix a generic type error and warnings in spotify 2025-07-16 14:15:27 +01:00
Šarūnas Nejus
3495a7ef36
Update mypy config
Remove 'files' configuration from the config to make sure that mypy runs
quicker when invoked from the editor (where ideally it should only check
the file being edited).

Remove 'disallow_any_generics' from the config since we already have
this configured centrally.

And finally, do not allow variable redefinitions.
2025-07-16 14:15:27 +01:00
Šarūnas Nejus
2ac612b696
Post coverage status comment 2025-07-16 14:06:35 +01:00
Šarūnas Nejus
46318a113c
Install gstreamer1.0-plugins-base, python3-gst-1.0 for bpd 2025-07-16 14:06:35 +01:00
Šarūnas Nejus
e1162b7e0f
Rename test_player -> test_bpd 2025-07-16 14:06:35 +01:00
Šarūnas Nejus
a5bbe57490
Fix types in test_player 2025-07-16 14:06:34 +01:00
Šarūnas Nejus
72003ba192
Let mypy failure block CI 2025-07-16 14:06:34 +01:00
Šarūnas Nejus
816d06f160
Fix plugin types 2025-07-16 14:06:34 +01:00
Šarūnas Nejus
d3c64d8506
Add missing types to importer and pipeline 2025-07-16 14:06:34 +01:00
Šarūnas Nejus
21459c70ee
importer: provides search_ids into lookup_candidates explicitly 2025-07-16 14:06:33 +01:00
Šarūnas Nejus
5677f9beee
Fix breaking issues 2025-07-16 14:06:33 +01:00
Šarūnas Nejus
4d648510cc
Fix regression in chroma plugin (#5877)
closes #5876.
2025-07-16 11:54:12 +01:00
Sebastian Mohr
f70e5ec758 split imports 2025-07-16 12:07:49 +02:00
Sebastian Mohr
47f8fbe629 Plugin should call super init. 2025-07-16 11:48:34 +02:00
Sebastian Mohr
0c6b383b06 Track info should not be imported from metadata_plugin. 2025-07-16 11:43:17 +02:00
Šarūnas Nejus
f67d40c7db
Refactor of metadata plugin and opt in all metadata plugins to new baseclass (#5787)
At the moment the `MetaDataSourcePlugin` has multiple responsibilities:

- fetch data via `_search` api
- defines contract for interaction within the beets autotag lookup

I propose splitting these responsibilities, as it would enable us to use
the `MetaDataSourcePlugin` baseclass with plugins that use external
packages to fetch data.
  
This follows from discussion in #5761 and
https://github.com/beetbox/beets/pull/5748#discussion_r2075070638.

Feedback is highly appreciated, as this is mainly architectural decision
and I would prefer if the new behavior is a shared consensus.

## To Do

- [x] Opt in plugins into the new `MetaDataSourcePlugin` 
     - [x] Spotify
    - [x] Musicbrainz
    - [x] Deezer
    - [x] Beatport
    - [x] Chroma
    - [x] Disccogs
- [x] Remove old MetaDataSourcePlugin and related functions
- [x] Documentation on the ontology of plugins
- [x] Changelog


This PR was initially #5764 and was accidentally closed as the target
branch was deleted. Wasn't able to recover the original PR.
2025-07-15 14:10:01 +01:00
Sebastian Mohr
a0ae9db0c6 Added tpyehint to fix mypy issue. 2025-07-15 15:03:14 +02:00
Sebastian Mohr
0f085fb91b Updated changelog 2025-07-15 15:03:14 +02:00
Sebastian Mohr
1d33580b68 Renamed class method to _extract_id. 2025-07-15 15:03:14 +02:00
Sebastian Mohr
648a9be172 Added deprecation warning for legacy type metadata plugins. 2025-07-15 15:03:14 +02:00
Sebastian Mohr
5cd6a39a01 Edited changelog and fixed an issue with plugin loading. 2025-07-15 15:03:14 +02:00
Sebastian Mohr
04f0339172 Added python version check for typing_Extensions 2025-07-15 15:03:14 +02:00
Sebastian Mohr
29b77cfbd4 Added changelog entry. 2025-07-15 15:03:14 +02:00
Sebastian Mohr
3ce33631a6 Renamed import in mbsync and missing plugins. 2025-07-15 15:03:14 +02:00
Sebastian Mohr
3eadf17e8f Opt in beatport plugin. Also enhanced type hints and minor cleanup for
the beatport plugin.
2025-07-15 15:03:14 +02:00
Sebastian Mohr
a97633dbf6 Opt in dicogs plugin. 2025-07-15 15:03:14 +02:00
Sebastian Mohr
6f623ee7b0 Opt in deezer plugin. 2025-07-15 15:03:14 +02:00
Sebastian Mohr
a770cfb669 Opt in chroma plugin. 2025-07-15 15:03:14 +02:00
Sebastian Mohr
b62fb10da8 Opt in musicbrainz plugin. 2025-07-15 15:03:14 +02:00
Sebastian Mohr
fd800dce7c Opt in spotify plugin and enhanced typing for the search responses. 2025-07-15 15:03:14 +02:00
Sebastian Mohr
8552eb9a37 Added debug message when id extractor pattern is not found. 2025-07-15 15:03:14 +02:00
Sebastian Mohr
178e27f11f Fixed imports for all tests and added a bit of stricter type checking. 2025-07-15 15:03:14 +02:00
Sebastian Mohr
5fe8431a65 Use inspect instead of isclass in load_plugin function to fix import
issues.
2025-07-15 15:03:14 +02:00
Sebastian Mohr
24295d6844 Renamed plugin, adjusted some docstrings and moved
artists_to_artist_str back into get_artist method.
2025-07-15 15:03:14 +02:00
Sebastian Mohr
06b6f4f27b Isolated autottag related plugin functions into an new metadata_plugins
file.
2025-07-15 15:03:14 +02:00
Martin Atukunda
8126eaa0fa
Merge branch 'master' into feature/add-artist-to-item-entry-template 2025-07-15 13:58:25 +03:00
Martin Atukunda
d476af8ecd
Move change log note to the New features
After some guidance from @snejus this is the proper place to place the
change log entries, not inside the New features section of _released_
versions.
2025-07-15 13:55:49 +03:00
Šarūnas Nejus
24dd40eed2
feat: mpdstats: adds config option for remaining time threshold to determine if track was played. (#5657)
Add new configuration option for mpdstats plugin,
`played_ratio_threshold`, to allow configuring the percentage the song
must be played for it to be counted as played instead of skipped.
2025-07-10 10:32:43 +01:00
54562474
48d45b4df7 feat: mpdstats: add config option for played ratio threshold to determine if a
track was played or skipped.
2025-07-09 14:16:23 -06:00
Šarūnas Nejus
8a43133bbe
Replace custom unittest-like methods with assertions (#5854)
## Replace custom assertion methods with standard assertions

This PR is part of `unittest` -> `pytest` migration #5361 and removes
custom assertion methods from the test suite and replaces them with
standard Python assertions.

### Key Changes

- Removed custom assertion methods
- Updated path handling to use `pathlib.Path` wherever this was relevant
to the methods being replaced
- Simplified some of the tests structure
2025-07-09 13:24:50 +01:00
Šarūnas Nejus
0dd6cb3b6d
Replace assert_equal_path 2025-07-09 09:21:52 +01:00
Šarūnas Nejus
ca3adfe525
Replace assertPrem 2025-07-09 09:21:52 +01:00
Šarūnas Nejus
8dcc69e6d8
Replace _assert_image_operated 2025-07-09 09:21:52 +01:00
Šarūnas Nejus
9f6d5063d1
Replace _assertImageIsValidArt 2025-07-09 09:21:51 +01:00
Šarūnas Nejus
72caf0d2cd
Replace assertCount 2025-07-09 09:21:51 +01:00
Šarūnas Nejus
111cb562ea
Replace assertContains and assertExcludes 2025-07-09 09:21:51 +01:00