Commit graph

12502 commits

Author SHA1 Message Date
Šarūnas Nejus
43032f7bc7
translations: make sure we do not re-translate 2025-02-20 03:47:04 +00:00
Šarūnas Nejus
7893766e4c
Improve flags structure and add tests 2025-02-20 03:47:04 +00:00
Šarūnas Nejus
c95156adcd
Refactor writing rest files 2025-02-20 03:47:04 +00:00
Šarūnas Nejus
d7201062a8
Resurrect translation functionality 2025-02-20 03:47:04 +00:00
Šarūnas Nejus
c315487bd2
Importer typehints and small importer refactor (#5611)
## Description

Hello y'all. 

One of the dev from the [beets-flask
app](https://github.com/pSpitzner/beets-flask) here. We are extending
the `ImportSession` in our application to get the interactive imports
working in our application. Overall that was not a too pleasant
experience as a ton of typehints are missing in that area of the beets
code. This PR wants to fix this ;)

### Changes

Moved importer state logic into a dataclass. Is clearer and more
isolated now in my opinion, we are not using it but I found it quite
confusing when looking at it.

Added a ton of typehints to the `importer.py` file. Predominantly the
`ImportSession`, `ImportTask` (and derivatives) and pipeline stage
decorators are now (hopefully) completely typed. Additionally I fixed
some typhint issues in the `util.__init__.py` file, mainly related to
the `PathLike` type.

If you have some strong opinions about any of the changes feel free to
revert or edit the PR.

Best,
Sebastian

P.S: I noticed that beets does not use Abstract Base Classes is there
any reason for that or is it just of historic nature? I think some Base
Classes could be adapted to use an ABC metaclass quite easily.
2025-02-18 09:37:29 +00:00
Sebastian Mohr
918fd863f3
Merge branch 'master' into importer-typehints-and-refactor 2025-02-17 23:02:00 +01:00
J0J0 Todos
1c5aaf5532
smartplaylist: change encoding of additional field (#5563)
## Description

URL-encode additional item `fields` within generated EXTM3U playlists
instead of JSON-encoding them.
This is because JSON-encoding additional fields/attributes made it
difficult to parse the `EXTINF` line but using URL-encoding for these
values makes parsing easy (because URL-encoded values cannot contain
commas, quotation marks and spaces; see
[here](https://github.com/mgoltzsche/beets-webm3u/blob/v0.6.4/beetsplug/webm3u/playlist.py#L102)
and
[here](https://github.com/mgoltzsche/beets-webm3u/blob/v0.6.4/beetsplug/webm3u/playlist.py#L122)).

[I introduced the generation of additional EXTM3U item fields earlier
this year](https://github.com/beetbox/beets/pull/5121) and I want to
correct that now.
2025-02-17 21:49:53 +01:00
J0J0 Todos
f01707b477
Merge branch 'master' into smartplaylist-attr-url-encoding 2025-02-17 21:40:51 +01:00
Sebastian Mohr
115b502353
Merge branch 'master' into importer-typehints-and-refactor 2025-02-17 21:33:57 +01:00
Šarūnas Nejus
044818a8dd
Fix musicbrainz genres fetching (#5609)
- genres are now called tags
- tags needs to be in "mb fetch includes"
- release-group has them
- release has them
- and recording as well but we don't use them
- not sure what this outdated check was doing, it looked at "recordings"
in the valid list even though genre fetching is only included in the
`album_info` code and not `track_info` 🤷
- see musicbrainz.VALID_INCLUDES for reference
2025-02-17 20:31:24 +00:00
J0J0 Todos
2286511ebe
Merge branch 'master' into smartplaylist-attr-url-encoding 2025-02-17 21:16:09 +01:00
J0J0 Todos
795545c1fa
Merge branch 'master' into fixmbgenre 2025-02-17 21:12:46 +01:00
Sebastian Mohr
9683a5b956 See https://github.com/beetbox/beets/pull/5611#discussion_r1957433785 2025-02-17 16:30:42 +01:00
Sebastian Mohr
cf1b4d8913 See https://github.com/beetbox/beets/pull/5611#discussion_r1958356845.
Revert normpath additions
2025-02-17 16:25:41 +01:00
Sebastian Mohr
87b022e48c See https://github.com/beetbox/beets/pull/5611#discussion_r1957443692 2025-02-17 16:09:18 +01:00
Sebastian Mohr
bdabafeefd See https://github.com/beetbox/beets/pull/5611#discussion_r1957443316 2025-02-17 15:48:11 +01:00
Šarūnas Nejus
4e7b054f48
Populate bug issue template automatically (#5612)
Update documentation to use specific GitHub issue templates instead of
generic issue links. This helps users provide better structured feedback
when reporting bugs or requesting features.

This was noted in
https://github.com/beetbox/beets/issues/5610#issuecomment-2628985640
2025-02-17 00:29:26 +00:00
Šarūnas Nejus
5a9c769f5c
Link to specific bug report/feature request templates in docs 2025-02-16 23:41:00 +00:00
Sebastian Mohr
0447df6510 Session args to kwargs in manipulate files 2025-02-15 13:27:45 +01:00
Sebastian Mohr
9acb2b4ca3 Added typehints to ImportTask init and reverted some initial changes. 2025-02-15 13:21:47 +01:00
Sebastian Mohr
0ee17c0b06 Removed unnecessary comments & raise same not implemented error for all
not implemented methods
2025-02-15 13:18:21 +01:00
Sebastian Mohr
d29ef500b9 Session path can't be None anymore. Empty list if none 2025-02-15 13:17:20 +01:00
Sebastian Mohr
803a0d1fcb
Apply suggestions from code review
Co-authored-by: Šarūnas Nejus <snejus@protonmail.com>
2025-02-15 13:17:00 +01:00
J0J0 Todos
459ca6498a Refactor musicbrainzngs fetch-includes sanity checks
in autotag.mb module.
2025-02-12 07:16:01 +01:00
Sebastian Mohr
ebe88885c5 Renamed to ignore_bytes and reverted typevar rename 2025-02-10 11:46:50 +01:00
Sebastian Mohr
10e52c68c9
Merge branch 'master' into importer-typehints-and-refactor 2025-02-10 11:43:05 +01:00
Sebastian Mohr
c17a774dd6 Removed Optional and Union and resolved a minor mypy shadowing issue. 2025-02-09 20:23:19 +01:00
Sebastian Mohr
fdf7afbfe3 Formatting 2025-02-09 11:23:22 +01:00
Sebastian Mohr
716720d2a5 Removed unnecessary cast even tho it now produces issues locally. 2025-02-09 11:23:01 +01:00
Sebastian Mohr
bbd92d97ab Removed optional type hints for pipe based optional with None 2025-02-09 11:05:09 +01:00
Šarūnas Nejus
810af1f87b
Close file descriptor generated from tempfile.mkstemp() (#5617)
Without explicitly closing this file descriptor, the temp file would be
kept open until the program exited and could not be deleted by the
fetchart plugin.

Fixes #5521
2025-02-09 00:58:44 +00:00
Sebastian Mohr
1a24e3f1d0 Formatting 2025-02-08 22:20:40 +01:00
Sebastian Mohr
44074d7464 Readded copyright and union. 2025-02-08 22:19:37 +01:00
Sebastian Mohr
bbe4fb454b Renamed ignore to _ignore to prevent mypy error 2025-02-08 22:12:55 +01:00
Sebastian Mohr
10c0aa3f6a Replaced pathlike with pathbytes and remove unnecessary type ignores 2025-02-08 22:03:03 +01:00
seth-milojevic
3dfb95eb69
Merge branch 'master' into patch-1 2025-02-08 12:41:59 -05:00
seth-milojevic
6205e19b74
Update docs/changelog.rst
Co-authored-by: Šarūnas Nejus <snejus@protonmail.com>
2025-02-08 12:41:37 -05:00
Sebastian Mohr
b46dbb93f7
Merge branch 'master' into importer-typehints-and-refactor 2025-02-08 17:43:31 +01:00
Šarūnas Nejus
25ccb9fdcd
Fix lyrics tests (#5618)
Adjust lyrics integration tests to make sure that expected lyrics from
`musica` match what's actually returned.
2025-02-08 16:00:37 +00:00
Šarūnas Nejus
5685cf43cf
Align musica lyrics source expected lyrics with whats returned 2025-02-08 09:09:24 +00:00
Šarūnas Nejus
b6d24ecc1f
Fix matcher typo (#5589)
Fixes a confusing typo when setting the MusicBrainz matcher in a few
tests. It looks like the matcher defaults to `IDENT` so change it to
that, since that would have been the value used in the tests with the
typo.
2025-02-08 09:00:13 +00:00
seth-milojevic
12fa3432a9 Close file descriptor generated from tempfile.mkstemp()
Without explicitly closing this file descriptor, the temp file would be kept open until the program exited and could not be deleted by the fetchart plugin.
2025-02-08 01:03:20 -05:00
Sebastian Mohr
12b21c48e9 Changelog addition 2025-02-07 16:55:26 +01:00
Sebastian Mohr
34101c2d13
Merge branch 'master' into importer-typehints-and-refactor 2025-02-07 16:22:34 +01:00
Sebastian Mohr
23f4f8261c Added some more typehints 2025-02-04 16:38:24 +01:00
valrus
99d2da66dc use actual value of matcher, not typo'd one 2025-02-03 19:32:27 -08:00
valrus
d298738612 add missing space in comment 2025-02-03 19:32:27 -08:00
valrus
f520790713 s/macthin/matching/ 2025-02-03 19:32:27 -08:00
Sebastian Mohr
ed92f9b997 Do not skip tests in ci.
The return type of the stage decorator should in theory be `T|None`
but the return of task types is not consistent in its usage. Would need
some bigger changes for which I'm not ready at the moment.
2025-02-03 11:37:33 +01:00
Šarūnas Nejus
731519b0a3
Use up-to-date namespace package setup for plugins (#5505)
Refactor `beetsplug` to use native namespace packages by removing
`__init__.py`. Update documentation and `setup.cfg` to support namespace
packages.

### Motivation

Adopt PEP 420 native namespace packages to simplify plugin management
and eliminate the need for `__init__.py`.

See https://realpython.com/python-namespace-package.

This setup is backwards-compatible, so plugins using the old
pkgutil-based setup will continue working fine.

The advantage with this setup is that external plugins will now be able
to import modules from 'beetsplug' package for typing purposes.
Previously, mypy could not resolve these modules due to presence of
`__init__.py`.
2025-02-02 16:32:53 +00:00