Commit graph

12019 commits

Author SHA1 Message Date
Konstantin
3d937e037b fix formatting 2024-08-27 09:45:47 +00:00
Konstantin
f3bfd8a47a use new kind of type annotations 2024-08-27 09:40:26 +00:00
Konstantin
56232864ce fix 2024-08-27 08:15:51 +00:00
Konstantin
f51d5249d2 Revert "fixed + improved typing in some places"
This reverts commit 647d6ab29a.
2024-08-27 06:51:42 +00:00
Konstantin
647d6ab29a fixed + improved typing in some places 2024-08-27 00:16:30 +02:00
ThinkChaos
bf32d9a1be
refactor(autotag/mb): reduce repeated code for external link parsing
Co-authored-by: Šarūnas Nejus <snejus@protonmail.com>
2024-08-26 13:06:28 -04:00
ThinkChaos
65f2285dd3
fix(import): don't throw away album flexible fields
As noted by 5bf4e3d92f, MusicBrainz
external IDs (`*_album_id`) were only saved for items and not albums.
This commit addresses that by copying `AlbumInfo` fields to the `Album`,
i.e. what's saved in the DB.
This is similar to how `TrackInfo` fields are copied to `Item` instances
except the copying is done at a different time since we only get an
`Album` much later in the import flow.
2024-08-26 13:06:28 -04:00
Šarūnas Nejus
4416b9857f
Fix autobpm and improve its docs (#5389)
Fixes #5289 and #5185

Tried using the `autobpm` plugin and found a couple of issues:

1. #5185 `librosa` dependency was missing in `pyproject.toml`
2. Simply including the plugin in the configuration made `beet` take
over 4 seconds to start up.
3. BPM detection failed due to another missing dependency, `resampy`
4. #5289 Librosa `beat_track` function returned unexpected type which
made the plugin and the entire import process fail.

Addressed each of the above, slightly refactored the plugin and added
tests.
2024-08-26 17:18:48 +01:00
Konstantin
e04f3e5597 Use typing.Dict instead of dict 2024-08-26 16:34:53 +02:00
Konstantin
b84912db5f This should do… 2024-08-25 19:18:15 +02:00
Konstantin
5d1da3e438 Didn't mean to do that... 2024-08-25 16:37:36 +02:00
Konstantin
ccda7405b9 Utilize new way of declaring a NamedTuple 2024-08-25 16:26:19 +02:00
Šarūnas Nejus
111686e563
autobpm: add tests 2024-08-19 22:44:17 +01:00
Šarūnas Nejus
591e04a894
Add Item.filepath property to simplify path handling
Additionally, fix DefaultTemplateFunctions._func_names definition.
2024-08-19 22:44:17 +01:00
Šarūnas Nejus
8f02020db4
autobpm: handle errors in beat.beat_track as well 2024-08-19 22:44:17 +01:00
Šarūnas Nejus
3c51128d9b
autobpm: do not call get on boolean config options 2024-08-19 22:44:17 +01:00
Šarūnas Nejus
ee2f114342
autobpm: add types 2024-08-19 22:44:17 +01:00
Šarūnas Nejus
e3776f1910
autobpm: Do not import 'beat' subpackage immediately to improve startup time 2024-08-19 22:44:16 +01:00
Šarūnas Nejus
5b5c564a69
autobpm: Add a new beat_track_kwargs configuration option to autobpm 2024-08-19 22:44:16 +01:00
Šarūnas Nejus
49cae5ca23
autobpm: Fix the issue with tempo being a numpy array 2024-08-19 22:44:16 +01:00
Šarūnas Nejus
03cf567a90
autobpm: Add autobpm extra and update the docs
Given that librosa has been introducing breaking changes like there's no
tomorrow, use '^' version specifier to only allow updating the patch
version.
2024-08-19 22:44:16 +01:00
Šarūnas Nejus
38a26af149
Replace unittest assert methods by assert statement (#5386)
... continuing the test suite migration to `pytest` (#5361), this PR
replaces `unittest` method assertions with `assert` statement.

See the table below for a list of the replaced methods and their counts.
This should help clarify the size of the pull request 😆.

To keep things simple for the review, I have replaced each method in its
own commit. This
way, things should be easy to follow if you step through the commits one
by one. 🙂

method                   | count
---                      | ---
**`assertEqual`**        | 1747
**`assertIn`**           | 200
**`assertTrue`**         | 149
**`assertIsNone`**       | 87
**`assertFalse`**        | 85
**`assertRaises`**       | 69
**`assertNotIn`**        | 64
**`assertNotEqual`**     | 39
**`assertIsNotNone`**    | 35
**`assertIsInstance`**   | 35
**`assertLessEqual`**    | 23
**`assertGreater`**      | 15
**`assertLess`**         | 14
**`assertGreaterEqual`** | 14
**`assertAlmostEqual`**  | 9
**`assertRaisesRegex`**  | 4
**`assertCountEqual`**   | 2
**`assertListEqual`**    | 1


 Note that this *only* replaces methods provided by
`unittest` by default.
**Custom** assertion method replacements (like `assertExists` will be
addressed in a separate PR).
2024-08-19 08:08:16 +01:00
Šarūnas Nejus
4b69b493d2
Use f-string syntax 2024-08-16 17:47:23 +01:00
Šarūnas Nejus
093949bf2b
Fixup: use fast queries for fields shared between albums and items tables (#5385)
I surprisingly found that many queries for fields that exist in the
database are 'slow'. Querying items with `month:0` used a slow query
while `title:0` used a fast one.

I found the mistake in the logic: the field existence in the db check
was done *after* prepending the table name to the field. This meant that
the logic wrongly checked e.g. `items.field` instead of `field`.

This commit fixes the above and renames the variables for more clarity.
2024-08-12 09:59:38 +01:00
Šarūnas Nejus
090b62f5b0
Make this test ignore my local beets config 2024-08-12 08:49:30 +01:00
Šarūnas Nejus
d3bdd93bf6
Replace assertAlmostEqual 2024-08-12 08:49:30 +01:00
Šarūnas Nejus
fcc4d8481d
Replace assertListEqual 2024-08-12 08:43:43 +01:00
Šarūnas Nejus
fdb8c28271
Replace assertCountEqual 2024-08-12 08:43:43 +01:00
Šarūnas Nejus
46bdb84b46
Replace assertGreater and assertGreaterEqual 2024-08-12 08:43:43 +01:00
Šarūnas Nejus
6a3380bcb5
Replace assertLess and assertLessEqual 2024-08-12 08:43:43 +01:00
Šarūnas Nejus
eda0ef11d6
Replace assertIsInstance 2024-08-12 08:43:42 +01:00
Šarūnas Nejus
f9359df0d1
Replace assertNotEqual 2024-08-12 08:43:42 +01:00
Šarūnas Nejus
847e3858a6
Replace assertRaises 2024-08-12 08:43:42 +01:00
Šarūnas Nejus
9a05d27acf
Replace assertEqual 2024-08-12 08:43:42 +01:00
Šarūnas Nejus
6631b6aef6
Replace assertNotIn 2024-08-12 08:43:42 +01:00
Šarūnas Nejus
11e948121c
Replace assertIn 2024-08-12 08:43:42 +01:00
Šarūnas Nejus
2616bcc950
Replace assertIsNotNone 2024-08-12 08:43:41 +01:00
Šarūnas Nejus
5d4911e905
Replace assertIsNone 2024-08-12 08:43:41 +01:00
Šarūnas Nejus
cb82917fe0
Replace assertFalse 2024-08-12 08:43:41 +01:00
Šarūnas Nejus
c216b636ac
Fixup: make common fields use fast queries
I surprisingly found that many queries for fields that exist in the
database are 'slow'. Querying items with 'month:0' used a slow query
while 'title:0' used a fast one.

I found the mistake in the logic: the field existence in the db check
was done *after* prepending the table name to the field. This meant that
the logic wrongly checked e.g. 'items.field' instead of 'field'.

This commit fixes the above and renames the variables for more clarity.
2024-08-11 21:35:28 +01:00
Šarūnas Nejus
0ecc345143
Replace assertTrue 2024-08-05 17:11:16 +01:00
Šarūnas Nejus
7703c9e338
Remove redundant unicode decoding (#5379)
These days musicbrainz returns unicode strings as expected.
2024-08-04 20:09:16 +01:00
Šarūnas Nejus
f006476dcf
Remove redundant unicode decode
These days musicbrainz returns unicode strings as expected.
2024-08-04 15:03:53 +01:00
Serene
8f44568ddd
Add @bal-e to docs/team.rst (#5374)
Thanks for adding me as a contributor, @snejus!
2024-08-02 09:31:19 +10:00
Arav K.
657fffd5b7 [docs/team] Add '@bal-e' 2024-07-31 23:24:18 +02:00
Šarūnas Nejus
c05b3cff82
Centralize test setup (#5362)
This PR deduplicates shared tests setup that was used across test files.
It attempts to centralise the setup into a single source of truth
implementation in `beets.test.helper`.

This works towards the eventual migration to `pytest` (#5361) making it
easier to replace the tests setup with `pytest` fixtures.

It builds upon the temporary files cleanup in #5345.

## Details

### Test setup

* Mostly duplicate test setup implementations in
`beets.test._common.TestCase` and `beets.test.helper.TestHelper` were
merged into a single implementation as
`beets.test.helper.BeetsTestCase`.
* Replaced `unittest.TestCase` and `beets.test.helper.TestHelper`
combination with `beets.test.helper.ImportTestCase`
* Refactored `test/test_plugins.py` removing duplicate import files
setup.
* Centralised setting up the database on disk.
* Centralised plugin test setup into `beets.test.helpers.PluginMixin`.

### Removals

* Around 1/3 of the removed lines correspond to the removal of `def
suite()` functions that were previously used for tests collection.
* Removed redundant `setUp` and `tearDown` methods from many test files
given that the functions that they performed had been centralised in
`beets.test.helper`.
* Removed redundant library initialisations


### Importing

* Centralised import directory creation (only gets created on the first
access).
* Deduplicated `_setup_import_session` implementations in
`TerminalImportSessionSetup` and `ImportHelper`.
* Merged `ImportHelper._create_import_dir` and
`TestHelper.create_importer` implementations into
`ImportHelper.setup_importer`.
* Merged various takes on import files prep into
`ImportHelper.prepare_albums_for_import` and
`ImportHelper.prepare_album_for_import`.
* Seeing that many tests used it, defined `AsIsImporterMixin` which
provides a method `run_asis_importer` to setup _asis_ (non-autotag)
importer and run it
2024-07-31 08:53:33 +01:00
Šarūnas Nejus
5f395ab4f4
Configure plugins using PluginMixin.configure_plugin 2024-07-29 15:33:12 +01:00
Šarūnas Nejus
199f3079f2
Use PluginMixin in tests that load plugins manually
A constant `preload_plugin` is used to disable loading the plugin in the
`setUp` initialisation, allowing the plugin to be loaded manually by the
tests.

Also added a cleanup instruction to remove listeners from configured
plugins, and removed this logic from several tests.
2024-07-28 18:58:54 +01:00
Šarūnas Nejus
9c75513686
test_ui: Fix Config/Plugin/Completion tests interdependency
"test" plugin was not properly cleaned up after loading and would
therefore stay around and picked up by other tests.
2024-07-28 18:58:54 +01:00
Šarūnas Nejus
e097f1a8c6
Rewrite FileFilterPluginTest
And rewrite the tests since they were far too confusing to follow.
2024-07-28 18:58:54 +01:00