Commit graph

13088 commits

Author SHA1 Message Date
Damon McDougall
268075063f Use python3 print in plugins.rst 2025-07-29 10:06:30 +02:00
Šarūnas Nejus
0fec858a13
Update deps to address security vulnerabilities (#5873)
This PR updates dependencies to address security vulnerabilities

### Key changes
- **GitHub Actions:** Updated `tj-actions/changed-files` from v44/v45 to
v46 across all workflows
- **Python package updates:**
<img width="618" height="548" alt="image"
src="https://github.com/user-attachments/assets/c48ccd41-55f4-4dd6-b43a-4eb921c28b7d"
/>
2025-07-20 09:50:08 +01:00
Martin Atukunda
5043dcc78d
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-18 00:31:08 +03:00
Martin Atukunda
4a7e474efc
Merge branch 'master' into feature/add-artist-to-item-entry-template 2025-07-18 00:25:42 +03:00
Šarūnas Nejus
62bbd187a9
Bump tj-actions/changed-files 2025-07-17 13:30:34 +01:00
Šarūnas Nejus
7a79adb1e6
Update Python deps 2025-07-17 13:30:31 +01:00
Maxr1998
8db661b115
Add test 2025-07-16 21:46:03 +02:00
Maxr1998
55ef006b3e
Add changelog entry 2025-07-16 21:41:50 +02:00
Maxr1998
1c64b8be32
Convert flexible field values to SQL before storing them
This is required to support multivalued fields as flexible fields.
2025-07-16 21:41:50 +02:00
Šarūnas Nejus
bde5de42b3
Register types and queries from plugins on models dynamically (#5872)
## Fix dynamic plugin type and query registration

This PR refactors the plugin system to properly handle dynamic type and
query registration by converting static class attributes to cached class
properties.

**Problem**: Plugin types and queries were stored as mutable class
attributes that were manually updated during plugin loading/unloading.
This caused issues where:
- Plugin types weren't properly registered in test environments
- Shared mutable state between test runs caused inconsistent behavior  
- Manual cleanup was error-prone and incomplete

See https://github.com/beetbox/beets/pull/5833 and specifically
https://github.com/beetbox/beets/pull/5833#issuecomment-3016635209 for
the context.

**Solution**: 
- Convert `_types` and `_queries` from static dictionaries to
`@cached_classproperty` decorators
- Types and queries are now dynamically computed from loaded plugins
when accessed
- Eliminates manual mutation of class attributes during plugin loading
- Properly clears cached properties when plugins are loaded/unloaded
- Ensures plugin types are available immediately after registration

**Key Changes**:
- `Model._types` and `LibModel._queries` now use `@cached_classproperty`
- Removed manual `_types.update()` calls in plugin loading code
- Added proper cache clearing in test infrastructure
- Plugin types are now inherited through the class hierarchy correctly

This fixes the developer's issue where `item_types` weren't being
registered properly in tests - the new dynamic property approach ensures
plugin types are available as soon as plugins are loaded.
2025-07-16 20:19:14 +01:00
Š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