Commit Graph
15276 Commits
Author SHA1 Message Date
Šarūnas Nejus 6e9720af68 Replace memoryview with bytes 2026-09-01 14:58:27 +01:00
J0J0 Todos fe7ff0d595 importsource: Only register listener if configured (#6297)
## Description

If the feature is not enabled, registering a listener is not required.

Added 2 new tests that prove this is the case.
2026-09-01 11:32:52 +00:00
Šarūnas Nejus e7720ce362 docs: fix two dead external links (#6950)
## Summary

A live sweep of external URLs in `docs/` found two dead links. This PR
fixes them:

| File | Dead URL | Replacement |
|------|----------|-------------|
| `docs/plugins/autobpm.rst` |
`https://librosa.org/doc/latest/generated/librosa.beat.beat_track.html`
(404) |
`https://librosa.org/doc/latest/api/generated/librosa.beat.beat_track.html`
(200) |
| `docs/plugins/chroma.rst` |
`https://developer.apple.com/technologies/mac/audio-and-video.html`
(404) | `https://developer.apple.com/documentation/coreaudio` (200) |

The ID3v2.4 URL in `docs/faq.rst` remains unchanged after review
confirmed that it is accessible.

All replacement URLs were verified HTTP 200 before this PR. Other unique
external URLs in `docs/` were checked as part of the sweep; remaining
non-2xx results were example placeholders, localhost examples, or hosts
that still exist but reject automated requests.
2026-09-01 11:52:56 +01:00
Šarūnas Nejus ca5cf8c1c8 Merge branch 'master' into docs/fix-dead-links 2026-09-01 11:26:42 +01:00
Šarūnas Nejus 6c82b43494 Typing follow up fixes (#6965)
Two small follow up fixes after merging all typing changes:

1. Removed incorrect/outdated comment in `advancedrewrite`.
2. Included commits from the last PR to `.git-blame-ignore-revs`.
2026-09-01 11:17:02 +01:00
Šarūnas Nejus 0e14dce718 Merge branch 'master' into typing-follow-up 2026-09-01 11:07:26 +01:00
Šarūnas Nejus 123ce82fc2 fetchart: Fix downloading pre-sized thumbnails from CAA (#6870)
## Description

Fixes issue in which thumbnails were rescaled locally instead of
downloading pre-sized ones from CAA.

From the
[docs](https://beets.readthedocs.io/en/stable/plugins/fetchart.html#cover-art-archive-pre-sized-thumbnails):

>The CAA provides pre-sized thumbnails of width 250, 500, and 1200
pixels. If you set the maxwidth option to one of these values, the
corresponding image will be downloaded, saving beets the need to scale
down the image. It can also speed up the downloading process, as some
cover arts can sometimes be very large.

I noticed that the fetchart plugin didn't download the pre-sized
thumbnails from CAA for some of my releases because the API didn't
provide them under the keys "500" and "250" but instead "large" and
"small". These are [legacy
keys](https://musicbrainz.org/doc/Cover_Art_Archive/API) but for some
releases they're the only ones available so I wrote this fix to use them
as a fallback.

#### Example
```sh
curl -sL "https://coverartarchive.org/release/d51434bc-fcb6-4fc0-864f-e1ab13a51de2" | jq
```
```json
{
  "images": [
    {
      "types": [
        "Front"
      ],
      "front": true,
      "back": false,
      "edit": 30140717,
      "image": "http://coverartarchive.org/release/d51434bc-fcb6-4fc0-864f-e1ab13a51de2/8891190287.png",
      "comment": "",
      "approved": true,
      "id": "8891190287",
      "thumbnails": {
        "large": "http://coverartarchive.org/release/d51434bc-fcb6-4fc0-864f-e1ab13a51de2/8891190287-500.jpg",
        "small": "http://coverartarchive.org/release/d51434bc-fcb6-4fc0-864f-e1ab13a51de2/8891190287-250.jpg"
      }
    }
  ],
  "release": "http://musicbrainz.org/release/d51434bc-fcb6-4fc0-864f-e1ab13a51de2"
}
```
2026-09-01 11:00:29 +01:00
Šarūnas Nejus e4256b5232 Fix chroma original_year type 2026-09-01 10:55:55 +01:00
Šarūnas Nejus cfe1a52f41 Remove incorrect comment 2026-09-01 10:55:55 +01:00
Šarūnas Nejus d5300af4c1 Add commits from the previous PR to git blame ignore 2026-09-01 10:55:55 +01:00
Šarūnas Nejus 3e90e2168e Merge branch 'master' into docs/fix-dead-links 2026-09-01 10:50:09 +01:00
Šarūnas Nejus 388689d911 Merge branch 'master' into master 2026-09-01 09:30:49 +01:00
Šarūnas Nejus 39ff8cccc9 Have convert use the new format when deciding path (#6105)
By overriding the format attribute of the item, beets comes up with a
destination path that the user expects.

## Description

Fixes #1360

Currently when doing a convert command, when beets determines what the
new file path should be, it uses the path to the original file, and
changes the extension, but the new format is not referenced at all when
determining the new destination path. This PR overrides the format
attribute of the item just before the destination path is resolved, thus
returning the path that takes the new format in mind.

## To Do

This is my first contribution to`beets` (and frankly, the first time
I've had reason to look at the codebase). There could very well be a
relevant class method I missed to better accomplish what I want rather
than overriding the `format` attribute
2026-09-01 09:20:03 +01:00
Šarūnas Nejus 345e839314 Merge branch 'master' into have-convert-plugin-use-new-format-in-pathing 2026-09-01 09:08:17 +01:00
Šarūnas Nejus e9a51399d9 typing: type the rest of plugins (#6940)
Fixes #6924.

- Enables repo-wide annotation checks in `pyproject.toml` via `ruff`'s
`flake8-annotations` rules, with practical carve-outs for `test/**`,
`docs/conf.py`, `Any`, and noisy variadic args. This adds a clear
enforcement layer without forcing annotations in low-value areas.

- Finishes typing the entire codebase, including command entrypoints,
import hooks, config-driven code, helper utilities, and
library/model-facing APIs. Architecturally, plugin boundaries now
describe their inputs and outputs explicitly instead of relying on
implicit contracts.

- Includes a small set of follow-on fixes uncovered by typing, mainly
around bytes vs. strings, optional values, and collection shapes. These
are mostly correctness and consistency fixes rather than intentional
behavior changes.

- Overall impact: this completes typing coverage for the full codebase.
The result is stronger static guarantees, clearer extension points, and
safer future refactors across both core and plugin code.
2026-08-31 23:07:43 +01:00
Šarūnas Nejus 95a300130b typing: relax FieldTFuncs output type 2026-08-31 11:27:12 +01:00
Šarūnas Nejus 4e9677dfa3 play: test play on import 2026-08-31 11:27:12 +01:00
Šarūnas Nejus 5c3695da26 typing: various consistency fixes 2026-08-31 11:27:12 +01:00
Šarūnas Nejus 2a45e99b63 typing: configure flake8-annotations 2026-08-31 11:27:12 +01:00
Šarūnas Nejus 0b5a5b0350 typing: fix missing types in plugins 2026-08-31 11:27:12 +01:00
Šarūnas Nejus 11d41aee7d typing: add missing types to plugins 2026-08-31 11:27:12 +01:00
Šarūnas Nejus 12c9f4233f typing: type and refactor duplicates plugin (#6947)
Part of #6924.

### What changed

- Types added to `beetsplug/duplicates.py`.
- Refactors `beetsplug/duplicates.py` so album and item commands now
share one execution path through `_run_command()`.
- Replaces the old generic `_merge()` dispatch with an explicit
`merge_func` passed into `_duplicates()`, so album and item merge
behavior stays separate but simpler.
- Tightens typing across the plugin by using clearer `Album`, `Item`,
`AlbumOrItem`, and `LibModel` annotations in the main helper methods.

### Why it matters

- The plugin's architecture is now more direct: command setup decides
`'albums'` vs `'items'`, and the shared duplicate-processing flow
handles the rest.
- This removes branching and type ambiguity from the core duplicate
logic, which makes the code easier to follow and safer to change.
- Functional behavior stays the same at a high level, but the plugin is
now easier to maintain, reason about, and extend.
2026-08-31 11:26:48 +01:00
Šarūnas Nejus 6dbb4ce756 typing: fix types and refactor duplicates plugin 2026-08-31 11:19:31 +01:00
Šarūnas Nejus 4a99a991cb Add commits to git blame ignore 2026-08-31 11:19:27 +01:00
Šarūnas Nejus 8e4fa56acb typing: add types to duplicates plugin 2026-08-31 11:01:12 +01:00
Šarūnas Nejus 301677ad00 typing: type mpdstats, thumbnails plugins (#6939)
Part of #6924.

- This PR is a typing and interface cleanup for `beetsplug/mpdstats.py`
and `beetsplug/thumbnails.py`. It does not add new features; it makes
the code's internal contracts clearer and more explicit.

- In `mpdstats`, MPD responses and `now_playing` state now have concrete
types, path lookup uses the correct beets path shape, and player event
handling is narrowed to known states. This makes the control flow easier
to follow and reduces hidden assumptions in the plugin.

- In `thumbnails`, the code stops passing full `Album` objects where
only `album.path` or `artpath` is needed. That separates album metadata
from file-path operations, removes ambiguity around optional
`album.artpath`, and makes thumbnail generation steps more direct.

- Tests were updated to match the narrower method signatures and the
corrected path handling.

- High-level impact: safer internal APIs, clearer data flow, and lower
risk of type-related bugs. The only visible behavior change is that
missing album art is now logged as a warning instead of info.
2026-08-31 11:00:44 +01:00
Šarūnas Nejus 9611a23a87 typing: fix annotations in thumbnails 2026-08-31 10:55:33 +01:00
Šarūnas Nejus 6b4f8fa25b typing: add annotations to thumbnails 2026-08-31 10:55:33 +01:00
Šarūnas Nejus b64c693252 typing: fix annotations in mpdstats 2026-08-31 10:55:33 +01:00
Šarūnas Nejus 4f0ac15b99 typing: add annotations to mpdstats 2026-08-31 10:55:33 +01:00
Šarūnas Nejus 7d67ca0c75 typing: type metadata source plugins: discogs, deezer, beatport, spotify chroma, listenbrainz, mbsubmit, spotify (#6938)
Part of #6924.

- This change tightens typing across metadata source plugins and shared
request/MusicBrainz utilities, so plugin code lines up better with the
data it actually consumes.

- Biggest architecture change is in `beetsplug/_utils/musicbrainz.py`:
common release fields move into `BaseRelease`, and new
`RecordingWithReleases` plus `get_recording_with_releases()` make
`'recording with releases'` an explicit shape instead of loose dict
guessing.

- Plugin code in `listenbrainz`, `chroma`, `acousticbrainz`, `beatport`,
`deezer`, `spotify`, `discogs`, and `mbsubmit` is then updated to use
clearer return types, typed collections, and safer access patterns for
optional API data.

- High-level impact: less ambiguity at plugin boundaries, better
editor/type-checker help, and fewer runtime mistakes from assuming
fields exist when remote APIs may omit them.

- There is also a small cleanup in `mbsubmit`: output formatting now
goes through `format()` with a cached config value, which removes a
cross-plugin helper dependency and keeps the command simpler.
2026-08-31 10:55:05 +01:00
Šarūnas Nejus 4e1fdf0bf3 typing: fix annotations in metadata source plugins 2026-08-31 10:48:16 +01:00
Šarūnas Nejus 21e045795d typing: add annotations to metadata source plugins 2026-08-31 10:48:16 +01:00
Šarūnas Nejus 0f27b2964c web: Remove typing t alias 2026-08-31 10:48:13 +01:00
Šarūnas Nejus db3680c501 typing: type aura, web plugin and export plugin (#6937)
Part of #6924.

- This change tightens typing across `beetsplug/aura.py`,
`beetsplug/export.py`, and `beetsplug/web/__init__.py` so plugin
interfaces better match real runtime behavior.

- High-level impact: no big feature shift, but architecture become more
explicit. Plugin boundaries, data shapes, and format handling are
clearer, which should make future changes safer and type errors easier
to catch.

#### `aura`

- base document methods are more explicit
- request args are lined up with `MultiDict`
- add safer handling for missing included resources.

I could not resolve typing without using `type: ignore` in two places
and I found both pieces of logic should be removed:

1. Field value conversion
- It caused `sqlite3.InterfaceError` when using `filter[genres]`,
because it was split into, e.g. `"genres" -> ["g", "e", "n", "r", "e",
"s"]`.
- The rest of the field types are either `str` and `int`. `MatchQuery`
happily accepts a `str` pattern when matching `int` fields.
2. When sorting by a `field`, excluding empty/null values: I'm pretty
sure this is not the behaviour we want 😅.

Extended tests to prove both of the above.

#### `export`

- simplify format selection and moves export flow to a single
iterable-based pipeline
- `json`, `jsonlines`, `csv`, and `xml` now share one higher-level data
path, with path-like byte fields normalized before writing

#### `web`

- add clearer endpoint and decorator annotations
- a small safety fix for missing item files returning `404` instead of
failing later
2026-08-31 10:29:01 +01:00
Šarūnas Nejus 21ffeff202 aura: fix filtering and sorting 2026-08-29 21:15:38 +01:00
Šarūnas Nejus 526f6ec4ba typing: fix API and export plugins 2026-08-29 21:15:38 +01:00
Šarūnas Nejus df767c7602 Add commit to git blame ignore 2026-08-29 21:15:38 +01:00
Šarūnas Nejus ee4d6eef36 typing: add annotations to API and export plugins 2026-08-29 21:10:29 +01:00
Šarūnas Nejus e7a788fd37 typing: type bpd plugin (#6936)
Part of #6924.

- This PR makes the `beetsplug.bpd` server stack easier to understand by
adding explicit type annotations across the main layers: `BaseServer`,
`Server`, `Connection`, `MPDConnection`, `ControlConnection`, `Command`,
and `GstPlayer`.

- At an architectural level, it clarifies how data moves through the
plugin:
  - command handlers now have clearer input and return types,
- shared server state like `playlist`, `connections`, and notification
sets is declared directly,
- internal playback paths that do not come from a live client are
modeled explicitly with `MPDConnection | None`.

- It also includes a few small refactors that support that clearer
structure without changing the design:
- `_parse_range` is moved into `BaseServer` so the shared logic is
actually available where it is used,
  - command parsing is simplified,
  - socket reads now separate raw bytes from decoded text,
  - VFS and library lookups are guarded more carefully.

- High-level impact: this is mainly a maintainability and correctness
change, not a feature change. It makes internal interfaces in `bpd` more
explicit, improves static type checking, and reduces the chance of
type-related bugs while keeping the plugin's overall behavior and
architecture the same.
2026-08-29 21:09:45 +01:00
Šarūnas Nejus a5080942c8 Add commit to git blame ignore 2026-08-29 17:49:13 +01:00
Šarūnas Nejus 743eb3b36b bpd: fix search when any field is used 2026-08-29 17:49:13 +01:00
Šarūnas Nejus bfe5ba51c5 typing: fix annotations in bpd plugin 2026-08-29 17:49:13 +01:00
Šarūnas Nejus 1ae8778385 typing: add annotations to bpd plugin 2026-08-29 17:38:48 +01:00
Shurong Cao 9d15446c3d docs: fix two dead external links
- Update the librosa beat_track API reference path.

- Update the Apple Core Audio developer documentation link.
2026-08-28 03:51:05 +08:00
Šarūnas Nejus 31c917b8c8 ui: remove do_query to tighten input_select_objects (#6942)
Part of #6924.

Closes #2802.
Closes #4880.

## Summary

- Fix `modify` interactive selection by displaying the changes already
prepared for each object and syncing only the objects returned by
`ui.input_select_objects`. Previously, the selection prompt could apply
the pending mutations again, producing incorrect output or raising a
`TypeError`.
- Fix `move --album --timid` when choosing individual albums. The
selection preview now uses the command's model-specific path expansion,
so it displays the album's item paths instead of trying to read
item-only fields from an `Album`.
- Remove `beets.ui.commands.utils.do_query` and let `modify`, `move`,
`remove`, `update`, `write`, and `edit` own their item and album queries
and no-match behavior.
- Keep thin model-specific query wrappers where mypy needs help
preserving item and album types. Shared `modify` parameters use
`Unpack[TypedDict]` so callers remain checked without duplicating the
parameter list.
- Narrow the return type of `ui.input_select_objects` from `Any` to
`Sequence[T]` and keep `remove` confirmation counts accurate.
- Document both user-facing fixes in the changelog.

## Tests

- Add CLI regression coverage for `modify` selection output and timid
album selection in `move`.
- Update command tests for `fields`, `import`, `list`, `move`, `remove`,
and `update` to exercise their CLI entrypoints, including selective
removal and confirmation counts.
- Remove the obsolete `do_query` unit tests with the helper.
- GitHub checks pass for linting, formatting, typing, docs, CodeQL, base
installation, all Ubuntu Python 3.11-3.14 jobs, and Windows Python 3.13.
The remaining matrix jobs were still running when checked.
2026-08-27 09:50:16 +01:00
Šarūnas Nejus 03877cc20b move: fix moving albums in timid mode 2026-08-27 06:47:40 +01:00
Šarūnas Nejus e5846915d4 modify: fix selecting objects 2026-08-27 06:47:39 +01:00
Šarūnas Nejus efc7e4f206 remove: fix ui formatting and test it 2026-08-27 06:47:39 +01:00
Šarūnas Nejus 2971393618 Replace do_query with model-specific logic
This allows to define a proper return type for input_select_objects.
2026-08-27 06:47:39 +01:00