Skip to content

Commit 2697995

Browse files
authored
Update dependencies and address security issues (#5765)
This PR addresses Dependabot vulnerability alerts and secret scanner reports by updating dependencies and redacting some of the sensitive configuration field. * **Dependency Updates:** Updated various dependencies, including those flagged by Dependabot, as reflected in `poetry.lock`. This resolves known vulnerabilities. * **Secret Redaction:** Addressed secret scanner findings by redacting sensitive configuration values (e.g., `tokenfile`, `apikey`, `password`, `username`, `userid`) in `beatport`, `discogs`, `embyupdate`, `fetchart`, `lastimport`, `spotify`, and `subsonicupdate` plugins. * **Python Version:** Standardized on Python 3.9 across GitHub Actions workflows. * **Code Style:** Minor adjustments for `ruff` compatibility, including string concatenations and f-string quote consistency.
2 parents e1101b7 + a735e74 commit 2697995

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1281
-1128
lines changed

.git-blame-ignore-revs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,7 @@ a6e5201ff3fad4c69bf24d17bace2ef744b9f51b
4343
f36bc497c8c8f89004f3f6879908d3f0b25123e1
4444
# Remove some lint exclusions and fix the issues
4545
5f78d1b82b2292d5ce0c99623ba0ec444b80d24c
46+
47+
# 2025
48+
# Fix formatting
49+
c490ac5810b70f3cf5fd8649669838e8fdb19f4d

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
if: matrix.platform == 'ubuntu-latest'
3434
run: |
3535
sudo apt update
36-
sudo apt install ffmpeg gobject-introspection libcairo2-dev libgirepository1.0-dev pandoc
36+
sudo apt install ffmpeg gobject-introspection libcairo2-dev libgirepository-2.0-dev pandoc
3737
3838
- name: Get changed lyrics files
3939
id: lyrics-update

.github/workflows/integration_test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
uses: BrandonLWhite/[email protected]
1313
- uses: actions/setup-python@v5
1414
with:
15-
python-version: 3.8
15+
python-version: 3.9
1616
cache: poetry
1717

1818
- name: Install dependencies

.github/workflows/make_release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
required: true
99

1010
env:
11-
PYTHON_VERSION: 3.8
11+
PYTHON_VERSION: 3.9
1212
NEW_VERSION: ${{ inputs.version }}
1313
NEW_TAG: v${{ inputs.version }}
1414

@@ -26,7 +26,7 @@ jobs:
2626
cache: poetry
2727

2828
- name: Install dependencies
29-
run: poetry install --only=release
29+
run: poetry install --with=release --extras=docs
3030

3131
- name: Bump project version
3232
run: poe bump "${{ env.NEW_VERSION }}"

.pre-commit-config.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
# See https://pre-commit.com/hooks.html for more hooks
33

44
repos:
5-
- repo: https://github.com/astral-sh/ruff-pre-commit
6-
rev: v0.8.1
5+
- repo: local
76
hooks:
8-
- id: ruff-format
7+
- id: format
8+
name: Format
9+
entry: poe format
10+
language: system
11+
files: '.*.py'
12+
pass_filenames: true

beets/autotag/hooks.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import re
2020
from functools import total_ordering
21-
from typing import TYPE_CHECKING, Any, Callable, NamedTuple, TypeVar, cast
21+
from typing import TYPE_CHECKING, Any, Callable, NamedTuple, TypeVar
2222

2323
from jellyfish import levenshtein_distance
2424
from unidecode import unidecode
@@ -474,7 +474,6 @@ def _eq(self, value1: re.Pattern[str] | Any, value2: Any) -> bool:
474474
matched against `value2`.
475475
"""
476476
if isinstance(value1, re.Pattern):
477-
value2 = cast(str, value2)
478477
return bool(value1.match(value2))
479478
return value1 == value2
480479

beets/autotag/match.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@
2020

2121
import datetime
2222
import re
23-
from collections.abc import Iterable, Sequence
2423
from enum import IntEnum
2524
from functools import cache
26-
from typing import TYPE_CHECKING, Any, NamedTuple, TypeVar, cast
25+
from typing import TYPE_CHECKING, Any, NamedTuple, TypeVar
2726

2827
import lap
2928
import numpy as np
@@ -40,6 +39,8 @@
4039
from beets.util import plurality
4140

4241
if TYPE_CHECKING:
42+
from collections.abc import Iterable, Sequence
43+
4344
from beets.library import Item
4445

4546
# Artist signals that indicate "various artists". These are used at the
@@ -241,12 +242,14 @@ def distance(
241242
# Album.
242243
dist.add_string("album", likelies["album"], album_info.album)
243244

245+
preferred_config = config["match"]["preferred"]
244246
# Current or preferred media.
245247
if album_info.media:
246248
# Preferred media options.
247-
patterns = config["match"]["preferred"]["media"].as_str_seq()
248-
patterns = cast(Sequence[str], patterns)
249-
options = [re.compile(r"(\d+x)?(%s)" % pat, re.I) for pat in patterns]
249+
media_patterns: Sequence[str] = preferred_config["media"].as_str_seq()
250+
options = [
251+
re.compile(r"(\d+x)?(%s)" % pat, re.I) for pat in media_patterns
252+
]
250253
if options:
251254
dist.add_priority("media", album_info.media, options)
252255
# Current media.
@@ -258,7 +261,7 @@ def distance(
258261
dist.add_number("mediums", likelies["disctotal"], album_info.mediums)
259262

260263
# Prefer earliest release.
261-
if album_info.year and config["match"]["preferred"]["original_year"]:
264+
if album_info.year and preferred_config["original_year"]:
262265
# Assume 1889 (earliest first gramophone discs) if we don't know the
263266
# original year.
264267
original = album_info.original_year or 1889
@@ -282,9 +285,8 @@ def distance(
282285
dist.add("year", 1.0)
283286

284287
# Preferred countries.
285-
patterns = config["match"]["preferred"]["countries"].as_str_seq()
286-
patterns = cast(Sequence[str], patterns)
287-
options = [re.compile(pat, re.I) for pat in patterns]
288+
country_patterns: Sequence[str] = preferred_config["countries"].as_str_seq()
289+
options = [re.compile(pat, re.I) for pat in country_patterns]
288290
if album_info.country and options:
289291
dist.add_priority("country", album_info.country, options)
290292
# Country.
@@ -447,9 +449,8 @@ def _add_candidate(
447449
return
448450

449451
# Discard matches without required tags.
450-
for req_tag in cast(
451-
Sequence[str], config["match"]["required"].as_str_seq()
452-
):
452+
required_tags: Sequence[str] = config["match"]["required"].as_str_seq()
453+
for req_tag in required_tags:
453454
if getattr(info, req_tag) is None:
454455
log.debug("Ignored. Missing required tag: {0}", req_tag)
455456
return
@@ -462,8 +463,8 @@ def _add_candidate(
462463

463464
# Skip matches with ignored penalties.
464465
penalties = [key for key, _ in dist]
465-
ignored = cast(Sequence[str], config["match"]["ignored"].as_str_seq())
466-
for penalty in ignored:
466+
ignored_tags: Sequence[str] = config["match"]["ignored"].as_str_seq()
467+
for penalty in ignored_tags:
467468
if penalty in penalties:
468469
log.debug("Ignored. Penalty: {0}", penalty)
469470
return
@@ -499,8 +500,8 @@ def tag_album(
499500
"""
500501
# Get current metadata.
501502
likelies, consensus = current_metadata(items)
502-
cur_artist = cast(str, likelies["artist"])
503-
cur_album = cast(str, likelies["album"])
503+
cur_artist: str = likelies["artist"]
504+
cur_album: str = likelies["album"]
504505
log.debug("Tagging {0} - {1}", cur_artist, cur_album)
505506

506507
# The output result, keys are the MB album ID.

beets/autotag/mb.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@
1919
import re
2020
import traceback
2121
from collections import Counter
22-
from collections.abc import Iterator, Sequence
2322
from itertools import product
24-
from typing import Any, cast
23+
from typing import TYPE_CHECKING, Any
2524
from urllib.parse import urljoin
2625

2726
import musicbrainzngs
@@ -37,6 +36,9 @@
3736
spotify_id_regex,
3837
)
3938

39+
if TYPE_CHECKING:
40+
from collections.abc import Iterator, Sequence
41+
4042
VARIOUS_ARTISTS_ID = "89ad4ac3-39f7-470e-963a-56509c546377"
4143

4244
BASE_URL = "https://musicbrainz.org/"
@@ -178,23 +180,26 @@ def _preferred_alias(aliases: list):
178180
return matches[0]
179181

180182

181-
def _preferred_release_event(release: dict[str, Any]) -> tuple[str, str]:
183+
def _preferred_release_event(
184+
release: dict[str, Any],
185+
) -> tuple[str | None, str | None]:
182186
"""Given a release, select and return the user's preferred release
183187
event as a tuple of (country, release_date). Fall back to the
184188
default release event if a preferred event is not found.
185189
"""
186-
countries = config["match"]["preferred"]["countries"].as_str_seq()
187-
countries = cast(Sequence, countries)
190+
preferred_countries: Sequence[str] = config["match"]["preferred"][
191+
"countries"
192+
].as_str_seq()
188193

189-
for country in countries:
194+
for country in preferred_countries:
190195
for event in release.get("release-event-list", {}):
191196
try:
192197
if country in event["area"]["iso-3166-1-code-list"]:
193198
return country, event["date"]
194199
except KeyError:
195200
pass
196201

197-
return (cast(str, release.get("country")), cast(str, release.get("date")))
202+
return release.get("country"), release.get("date")
198203

199204

200205
def _multi_artist_credit(
@@ -589,7 +594,9 @@ def album_info(release: dict) -> beets.autotag.hooks.AlbumInfo:
589594
if not release_date:
590595
# Fall back if release-specific date is not available.
591596
release_date = release_group_date
592-
_set_date_str(info, release_date, False)
597+
598+
if release_date:
599+
_set_date_str(info, release_date, False)
593600
_set_date_str(info, release_group_date, True)
594601

595602
# Label name.

beets/dbcore/db.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from collections import defaultdict
2727
from collections.abc import Generator, Iterable, Iterator, Mapping, Sequence
2828
from sqlite3 import Connection
29-
from typing import TYPE_CHECKING, Any, AnyStr, Callable, Generic, TypeVar, cast
29+
from typing import TYPE_CHECKING, Any, AnyStr, Callable, Generic, TypeVar
3030

3131
from unidecode import unidecode
3232

@@ -126,8 +126,8 @@ def _get_formatted(self, model: Model, key: str) -> str:
126126
value = value.decode("utf-8", "ignore")
127127

128128
if self.for_path:
129-
sep_repl = cast(str, beets.config["path_sep_replace"].as_str())
130-
sep_drive = cast(str, beets.config["drive_sep_replace"].as_str())
129+
sep_repl: str = beets.config["path_sep_replace"].as_str()
130+
sep_drive: str = beets.config["drive_sep_replace"].as_str()
131131

132132
if re.match(r"^\w:", value):
133133
value = re.sub(r"(?<=^\w):", sep_drive, value)

beets/test/_common.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,15 @@ def assertNotExists(self, path):
121121

122122
def assertIsFile(self, path):
123123
self.assertExists(path)
124-
assert os.path.isfile(
125-
syspath(path)
126-
), "path exists, but is not a regular file: {!r}".format(path)
124+
assert os.path.isfile(syspath(path)), (
125+
"path exists, but is not a regular file: {!r}".format(path)
126+
)
127127

128128
def assertIsDir(self, path):
129129
self.assertExists(path)
130-
assert os.path.isdir(
131-
syspath(path)
132-
), "path exists, but is not a directory: {!r}".format(path)
130+
assert os.path.isdir(syspath(path)), (
131+
"path exists, but is not a directory: {!r}".format(path)
132+
)
133133

134134
def assert_equal_path(self, a, b):
135135
"""Check that two paths are equal."""

0 commit comments

Comments
 (0)