Commit graph

13583 commits

Author SHA1 Message Date
Šarūnas Nejus
8c0820b9ea
Remove lastgenre separator config 2026-02-16 21:49:50 +00:00
Šarūnas Nejus
f3f81c1b2c
Update changelog note 2026-02-16 21:49:50 +00:00
Šarūnas Nejus
588e0eaee0
Replace genre: with genres: in docs 2026-02-16 21:49:50 +00:00
Šarūnas Nejus
9618137dbf
Fix the rest of the tests 2026-02-16 21:49:50 +00:00
Šarūnas Nejus
ce8128b8c4
Follow untyped imports 2026-02-16 21:44:56 +00:00
Šarūnas Nejus
11138a9e00
Update default split separator to '\␀' in %first func 2026-02-16 21:44:56 +00:00
Šarūnas Nejus
61562e10e3
Remove genre field 2026-02-16 21:44:56 +00:00
Šarūnas Nejus
0363b9233f
Stop overwriting this test file name 2026-02-16 21:44:56 +00:00
Šarūnas Nejus
ce2000a2cf
Only handle multiple genres in discogs 2026-02-16 21:44:56 +00:00
Šarūnas Nejus
8750191a29
Fix deprecation warning 2026-02-16 21:43:47 +00:00
Šarūnas Nejus
8bddfb2421
Add migration for multi-value genres field
* Move genre-to-genres migration into a dedicated Migration class and
  wire it into Library._migrations for items and albums.
* Add batched SQL updates via mutate_many and share the multi-value
  delimiter as a constant.
* Cover migration behavior with new tests.

I initially attempted to migrate using our model infrastructure
/ Model.store(), see the comparison below:

Durations migrating my library of ~9000 items and ~2300 albums:
1. Using our Python logic: 11 minutes
2. Using SQL directly: 4 seconds

That's why I've gone ahead with option 2.
2026-02-16 21:43:47 +00:00
Šarūnas Nejus
79167f1df7
Add generic Migration implementation 2026-02-16 21:43:46 +00:00
Šarūnas Nejus
a1bed02a58
Add support for migrations 2026-02-16 21:43:46 +00:00
Šarūnas Nejus
0048779aeb
Merge branch 'master' 2026-02-16 21:43:46 +00:00
dunkla
351332bca5
Fix mypy incompatible return type in lastgenre 2026-02-16 21:11:45 +00:00
Šarūnas Nejus
230399fd98
Adjust types for fully typed confuse (#6268)
* Update configuration handling to use fully typed confuse API which
will be released in confuse `v2.2.0`.
* Use `Subview`, `.sequence()`, `MappingTemplate`, and typed `OneOf`.
* Replace 'naked' configuration dictionary access with typed
`.get/.as_*` equivalents.
* Add typing annotations and `cached_property` where appropriate. 
* Fix related issues in `discogs`, `fetchart`, `lyrics`, `playlist`,
`smartplaylist`, and `titlecase` plugins.

> [!IMPORTANT]
> Depends on https://github.com/beetbox/confuse/pull/187 being merged
and released (as `v2.2.0`)
2026-02-16 12:51:14 +00:00
Šarūnas Nejus
15755c1ff9
Update confuse 2026-02-16 12:45:05 +00:00
Šarūnas Nejus
37e18fbb46
Adapt code to fully typed confuse library 2026-02-16 12:45:05 +00:00
Šarūnas Nejus
942638ae28
Clarify Azure Translator resource region requirement (#6363)
Added note about setting the translator resource region to Global to
avoid 401 errors.

## Description

Had a bit of trouble with the lyrics plugin where the translator was not
working. Creating a global resource instead of a regional one fixed the
issue. Added a small note to the documentation so that people won't run
into the same issue in the future.

For a bit more info, you need to specify the region in the request
headers if its a regional resource. This is not required for a global
one.
2026-02-16 12:00:22 +00:00
Šarūnas Nejus
3b670cdf18
In test I/O utility, restore the old stdin/stdout instead of the "true" I/O streams (#5049)
I got a little bit nerdsniped by the problems observed in #5027. In
short, my high-level diagnosis in
https://github.com/beetbox/beets/pull/5027#issuecomment-1857953929 seems
to have been correct: other tests were suppressing the legitimate
failure of a flaky test.

I found the problem by running other tests before the problem test, like
this:

```
$ pytest -k 'test_nonexistant_db or test_delete_removes_item' test/test_ui.py
```

When running `test_nonexistant_db` alone, it fails. When running it like
this with another test that goes first, it passes. That's the problem.

However, `test_delete_removes_item` is just one example that works to
make this problem happen. It appeared that _any_ test in a class that
used our `_common.TestCase` base class had this power. I tracked down
the issue to our `DummyIO` utility, which was having an unintentional
effect even when it was never actually used.

Here's the solution. Instead of restoring `sys.stdin` to
`sys.__stdin__`, we now restore it to whatever it was before we
installed out dummy I/O hooks. This is relevant in pytest, for example,
which installs its *own* `sys.stdin`, which we were then clobbering.
This was leading to the suppression of test failures observed in #5021
and addressed in #5027.

The CI will fail for this PR because it now (correctly) exposes a
failing test. Hopefully by combining this with the fixes in the works in
#5027, we'll be back to a passing test suite. 😃 @Phil305, could
you perhaps help validate that hypothesis?

Edit: @snejus:

I've now consolidated test I/O handling by removing the legacy
`control_stdin`/`capture_stdout` context managers and the custom
`DummyOut` stream, replacing them with a pytest-driven `io` fixture
that:
- provides controllable `stdin` via a lightweight `DummyIn`
- captures `stdout` via `capteesys`
- attaches a `DummyIO` helper to test classes as `self.io`
2026-02-14 18:03:34 +00:00
J0J0 Todos
8eed22c457
fix: wrong count in badfiles log message (#6366)
## Description

Small fix in badfiles: the wrong variable was used for the number of
found errors in badfiles' log messages.
2026-02-13 20:22:45 +01:00
pbnoxious
e4cbbccfdf
append badfiles fix to changelog 2026-02-12 22:58:11 +01:00
pbnoxious
144fd243ec
fix: wrong count in badfiles log message 2026-02-12 22:50:32 +01:00
Meth Munindradasa
e7dfbc96b1
Merge branch 'master' into patch-1 2026-02-13 08:32:39 +11:00
henry
f67c28be0b
Fix #6302: musicbrainz: crash when releases lack the "track" key. (#6364)
## Description

Fixes #6302

Todo: Test. I could not figure out how to add a test for this bug.

<!--
- If you believe one of below checkpoints is not required for the change
you
are submitting, cross it out and check the box nonetheless to let us
know.
  For example: - [x] ~Changelog~
- Regarding the changelog, often it makes sense to add your entry only
once
reviewing is finished. That way you might prevent conflicts from other
PR's in
that file, as well as keep the chance high your description fits with
the
  latest revision of your feature/fix.
- Regarding documentation, bugfixes often don't require additions to the
docs.
- Please remove the descriptive sentences in braces from the enumeration
below,
  which helps to unclutter your PR description.
-->

- [x] Documentation. (If you've added a new command-line flag, for
example, find the appropriate page under `docs/` to describe it.)
- [x] Changelog. (Add an entry to `docs/changelog.rst` to the bottom of
one of the lists near the top of the document.)
- [x] Tests. (Very much encouraged but not strictly required.)
2026-02-11 20:26:07 -08:00
Meth Munindradasa
f41f1839be Format docs to pass lint checker 2026-02-12 07:51:04 +11:00
w4grfw
be8d25ffa4
Update docs/changelog.rst
Co-authored-by: Šarūnas Nejus <snejus@protonmail.com>
2026-02-11 21:21:14 +01:00
w4grfw
7f1e7d7bc8 format changelog 2026-02-11 18:28:57 +01:00
w4grfw
63ec1f2f56 changelog entry 2026-02-11 18:25:53 +01:00
w4grfw
fe833d8377 test added 2026-02-11 18:23:55 +01:00
w4grfw
57bd3189df Fix #6302: musicbrainz: crash when releases lack the "track" key. 2026-02-11 16:26:00 +01:00
Meth Munindradasa
b3c1da3c4f
Clarify Azure Translator resource region requirement
Added note about setting the translator resource region to Global to avoid 401 errors.
2026-02-11 21:43:55 +11:00
Šarūnas Nejus
bc52682428
Improve GitHub release rendering (#6356)
This PR hardens the release/changelog generation pipeline so ReST ->
Markdown conversion produces stable, correctly formatted links and
inline code.

- Fix broken rendering of generated references by ensuring RST
`~`-shortened forms like ``` `:class:`~beetsplug._utils...``` are
converted into real Markdown links.
- Updates `extra/release.py` to generate clearer link text for CLI
command refs (e.g., `list-cmd` becomes 'list command') while keeping the
same documentation targets.
- Simplifies the Markdown post-processing step by removing the redundant
`MD_REPLACEMENTS` layer, reducing ad-hoc formatting logic in the release
script.
- Standardizes changelog section header structure in
`docs/changelog.rst` (and the release template) to align with
Sphinx/ReST conventions and avoid ambiguous colon-based headers.
- Strengthens CI by extending `lint-docs` in `pyproject.toml` to fail on
single-backtick inline literals in `.rst`, enforcing double-backtick
literals so `pandoc` does not emit meaningless `<span
class="title-ref">...` output that breaks Markdown rendering.

Net effect: more predictable release notes output, fewer conversion edge
cases, and earlier detection of docs formatting that would render
incorrectly downstream.
2026-02-10 23:59:38 +00:00
Šarūnas Nejus
d613981efe
Replace capture_output with io.getoutput 2026-02-10 00:53:20 +00:00
Šarūnas Nejus
fea789bb59
Replace control_stdin with io.addinput 2026-02-10 00:53:20 +00:00
Šarūnas Nejus
6a65f13776
Replace custom stdio mocks with pytest io fixture
Create a centralised pytest fixture to provide controllable stdin and
captured stdout in all tests. Simplify DummyIO/DummyIn and remove the
custom DummyOut implementation and make use of pytest builtin fixtures.

Create a centralised pytest fixture to provide controllable stdin and
captured stdout that can be applied to any tests, regardless whether
they are based on pytest or unittest.

* `io` fixture can be used as a fixture in pytest-based tests
* `IOMixin` can be used to attach `io` attribute to any test class,
  including `unittest.TestCase`
2026-02-10 00:53:20 +00:00
Šarūnas Nejus
1c87da2c05
Fix test failures 2026-02-10 00:53:20 +00:00
Šarūnas Nejus
a4249af700
Patch sys.stdin and sys.stdout in tests 2026-02-10 00:53:20 +00:00
Šarūnas Nejus
6dbee2437e
Fix fetching large MusicBrainz releases (#6357)
Fixes #6355 

- Fix `plugins/musicbrainz` handling of very large MusicBrainz releases
by passing the missing `limit` and `includes` kwargs to
`mb_api.browse_recordings`.
2026-02-08 21:18:16 +00:00
Šarūnas Nejus
838681790c
Name these track/recording vars properly 2026-02-08 11:09:59 +00:00
Šarūnas Nejus
9f4c94f512
Provide missing kwargs to musicbrainz browse 2026-02-08 11:09:59 +00:00
Šarūnas Nejus
4fd5c5ef79
Fix single backticks issues 2026-02-08 08:01:31 +00:00
Šarūnas Nejus
e4314b700f
Add rst inline-literal check to lint-docs task
Fail the docs lint task when single-backtick inline literals are used.

This is required because `pandoc` converts:

  `$playlist` -> <span class="title-ref">\$playlist</span>

Where this `span` element has no meaning in markdown context, and
`$playlist` loses its formatting. On the other hand, double backticks
are converted appropriately:

  ``$playlist`` -> `$playlist`
2026-02-08 07:28:09 +00:00
Šarūnas Nejus
1eb74aa740
Improve reference title for command links 2026-02-08 07:28:09 +00:00
Šarūnas Nejus
575f539282
Remove redundant MD_REPLACEMENTS 2026-02-08 07:28:09 +00:00
Šarūnas Nejus
616a674db0
Properly format changelog section headers 2026-02-08 07:28:08 +00:00
Šarūnas Nejus
10d8e5fc04
Sort changelog bullet points case-insensitively
Use a case-insensitive sort key when ordering Markdown changelog bullet
points to produce stable ordering regardless of capitalization.

Diff for the last release:

diff --git a/before b/after
index 51303c65f..d88eda894 100644
--- a/before
+++ b/after
@@ -4,3 +4,2 @@ Beets now requires Python 3.10 or later since support for EOL Python 3.9 has bee

-- Added support for Python 3.13.
 - [Convert Plugin](https://beets.readthedocs.io/en/stable/plugins/convert.html): `force` can be passed to override checks like no_convert, never_convert_lossy_files, same format, and max_bitrate
@@ -23,2 +22,3 @@ Beets now requires Python 3.10 or later since support for EOL Python 3.9 has bee
 - [Titlecase Plugin](https://beets.readthedocs.io/en/stable/plugins/titlecase.html): Add the [Titlecase Plugin](https://beets.readthedocs.io/en/stable/plugins/titlecase.html) plugin to allow users to resolve differences in metadata source styles.
+- Added support for Python 3.13.

@@ -26,9 +26,2 @@ Beets now requires Python 3.10 or later since support for EOL Python 3.9 has bee

-- Errors in metadata plugins during autotage process will now be logged but won't crash beets anymore. If you want to raise exceptions instead, set the new configuration option `raise_on_error` to `yes` 🐛 (#5903), 🐛 (#4789).
-- Fix a bug introduced in release 2.4.0 where import from any valid import-log-file always threw a "none of the paths are importable" error.
-- Handle potential OSError when unlinking temporary files in ArtResizer. 🐛 (#5615)
-- Running <span class="title-ref">beet --config \<mypath\> config -e</span> now edits <span class="title-ref">\<mypath\></span> rather than the default config path. 🐛 (#5652)
-- Sanitize log messages by removing control characters preventing terminal rendering issues.
-- When hardlinking from a symlink (e.g. importing a symlink with hardlinking enabled), dereference the symlink then hardlink, rather than creating a new (potentially broken) symlink 🐛 (#5676)
-- When using [FromFilename Plugin](https://beets.readthedocs.io/en/stable/plugins/fromfilename.html) together with [Edit Plugin](https://beets.readthedocs.io/en/stable/plugins/edit.html), temporary tags extracted from filenames are no longer lost when discarding or cancelling an edit session during import. 🐛 (#6104)
 - [Command-Line Interface](https://beets.readthedocs.io/en/stable/reference/cli.html): Fix 'from_scratch' option for singleton imports: delete all (old) metadata when new metadata is applied. 🐛 (#3706)
@@ -44,4 +37,11 @@ Beets now requires Python 3.10 or later since support for EOL Python 3.9 has bee
 - [Spotify Plugin](https://beets.readthedocs.io/en/stable/plugins/spotify.html): Updated Spotify API credentials. 🐛 (#6270)
-- [Web Plugin](https://beets.readthedocs.io/en/stable/plugins/web.html): repair broken <span class="title-ref">/item/values/…</span> and <span class="title-ref">/albums/values/…</span> endpoints. Previously, due to single-quotes (ie. string literal) in the SQL query, the query eg. <span class="title-ref">GET /item/values/albumartist</span> would return the literal "albumartist" instead of a list of unique album artists.
 - [update](https://beets.readthedocs.io/en/stable/reference/cli.html#update-cmd) [Edit Plugin](https://beets.readthedocs.io/en/stable/plugins/edit.html) fix display formatting of field changes to clearly show added and removed flexible fields.
+- [Web Plugin](https://beets.readthedocs.io/en/stable/plugins/web.html): repair broken <span class="title-ref">/item/values/…</span> and <span class="title-ref">/albums/values/…</span> endpoints. Previously, due to single-quotes (ie. string literal) in the SQL query, the query eg. <span class="title-ref">GET /item/values/albumartist</span> would return the literal "albumartist" instead of a list of unique album artists.
+- Errors in metadata plugins during autotage process will now be logged but won't crash beets anymore. If you want to raise exceptions instead, set the new configuration option `raise_on_error` to `yes` 🐛 (#5903), 🐛 (#4789).
+- Fix a bug introduced in release 2.4.0 where import from any valid import-log-file always threw a "none of the paths are importable" error.
+- Handle potential OSError when unlinking temporary files in ArtResizer. 🐛 (#5615)
+- Running <span class="title-ref">beet --config \<mypath\> config -e</span> now edits <span class="title-ref">\<mypath\></span> rather than the default config path. 🐛 (#5652)
+- Sanitize log messages by removing control characters preventing terminal rendering issues.
+- When hardlinking from a symlink (e.g. importing a symlink with hardlinking enabled), dereference the symlink then hardlink, rather than creating a new (potentially broken) symlink 🐛 (#5676)
+- When using [FromFilename Plugin](https://beets.readthedocs.io/en/stable/plugins/fromfilename.html) together with [Edit Plugin](https://beets.readthedocs.io/en/stable/plugins/edit.html), temporary tags extracted from filenames are no longer lost when discarding or cancelling an edit session during import. 🐛 (#6104)

@@ -71,2 +71,4 @@ Beets now requires Python 3.10 or later since support for EOL Python 3.9 has bee

+- [BPD Plugin](https://beets.readthedocs.io/en/stable/plugins/bpd.html): Raise ImportError instead of ValueError when GStreamer is unavailable, enabling `importorskip` usage in pytest setup.
+- dbcore: Allow models to declare SQL indices; add an `items.album_id` index to speed up `album.items()` queries. 🐛 (#5809)
 - Finally removed gmusic plugin and all related code/docs as the Google Play Music service was shut down in 2020.
@@ -76,3 +78 @@ Beets now requires Python 3.10 or later since support for EOL Python 3.9 has bee
 - Updated color documentation with `bright_*` and `bg_bright_*` entries.
-- [BPD Plugin](https://beets.readthedocs.io/en/stable/plugins/bpd.html): Raise ImportError instead of ValueError when GStreamer is unavailable, enabling `importorskip` usage in pytest setup.
-- dbcore: Allow models to declare SQL indices; add an `items.album_id` index to speed up `album.items()` queries. 🐛 (#5809)
2026-02-08 07:20:44 +00:00
Šarūnas Nejus
50959bb316
Fix rendering generated refs
This specifically fixes v2.6.0 changelog:

diff --git a/before b/after
index dc9a2ecd2..51303c65f 100644
--- a/before
+++ b/after
@@ -51,3 +51,3 @@ Beets now requires Python 3.10 or later since support for EOL Python 3.9 has bee

-- Added a reusable requests handler which can be used by plugins to make HTTP requests with built-in retry and backoff logic. It uses beets user-agent and configures timeouts. See `~beetsplug._utils.requests.RequestHandler` for documentation.
+- Added a reusable requests handler which can be used by plugins to make HTTP requests with built-in retry and backoff logic. It uses beets user-agent and configures timeouts. See [beetsplug.\_utils.requests.RequestHandler](https://beets.readthedocs.io/en/stable/api/generated/beetsplug._utils.requests.RequestHandler.html#beetsplug._utils.requests.RequestHandler) for documentation.

@@ -62,3 +62,3 @@ Beets now requires Python 3.10 or later since support for EOL Python 3.9 has bee

-  See `~beetsplug._utils.musicbrainz.MusicBrainzAPI` for documentation.
+  See [beetsplug.\_utils.musicbrainz.MusicBrainzAPI](https://beets.readthedocs.io/en/stable/api/generated/beetsplug._utils.musicbrainz.MusicBrainzAPI.html#beetsplug._utils.musicbrainz.MusicBrainzAPI) for documentation.
2026-02-08 07:20:44 +00:00
Šarūnas Nejus
3b89d722ea
Fix mb search term formatting (#6354)
Fixes #6347

- Fixed MusicBrainz Lucene query formatting in
`MusicBrainzAPI.format_search_term()` (lowercase + trim + escape Lucene
special chars).
- Fixed `plugins.musicbrainz:extra_tags` support by mapping `alias` and
`tracks` into MusicBrainz search fields.
- Adjusted logging to make MusicBrainz API logs visible under the shared
`beets` logger (and removed an unused per-module logger in
`beetsplug.bpd`).
2026-02-08 07:20:11 +00:00
Šarūnas Nejus
bf6c0a1bdf
Disable Tekstowo by default as they block requests with the beets UA (#6344) 2026-02-08 01:29:30 +00:00