From d6ac687de162c372e888a1a45b6af344500845c5 Mon Sep 17 00:00:00 2001 From: Adam Harder Date: Wed, 6 Nov 2024 23:14:47 -0500 Subject: [PATCH 1/4] fix #4840 and add to test case --- beets/importer.py | 5 +++-- test/test_importer.py | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/beets/importer.py b/beets/importer.py index ea5b1cc51..9cb77c606 100644 --- a/beets/importer.py +++ b/beets/importer.py @@ -605,7 +605,8 @@ class ImportTask(BaseImportTask): """ items = self.imported_items() for field, view in config["import"]["set_fields"].items(): - value = view.get() + value = str(view.get()) + print("EEE ", value) log.debug( "Set field {1}={2} for {0}", displayable_path(self.paths), @@ -1062,7 +1063,7 @@ class SingletonImportTask(ImportTask): values, for the singleton item. """ for field, view in config["import"]["set_fields"].items(): - value = view.get() + value = str(view.get()) log.debug( "Set field {1}={2} for {0}", displayable_path(self.paths), diff --git a/test/test_importer.py b/test/test_importer.py index 116e750e7..ad6b837f5 100644 --- a/test/test_importer.py +++ b/test/test_importer.py @@ -395,11 +395,13 @@ class ImportSingletonTest(ImportTestCase): def test_set_fields(self): genre = "\U0001f3b7 Jazz" collection = "To Listen" + disc = 0 config["import"]["set_fields"] = { "collection": collection, "genre": genre, "title": "$title - formatted", + "disc": disc, } # As-is item import. @@ -412,6 +414,7 @@ class ImportSingletonTest(ImportTestCase): assert item.genre == genre assert item.collection == collection assert item.title == "Tag Track 1 - formatted" + assert item.disc == disc # Remove item from library to test again with APPLY choice. item.remove() @@ -426,6 +429,7 @@ class ImportSingletonTest(ImportTestCase): assert item.genre == genre assert item.collection == collection assert item.title == "Applied Track 1 - formatted" + assert item.disc == disc class ImportTest(ImportTestCase): @@ -583,12 +587,14 @@ class ImportTest(ImportTestCase): genre = "\U0001f3b7 Jazz" collection = "To Listen" comments = "managed by beets" + disc = 0 config["import"]["set_fields"] = { "genre": genre, "collection": collection, "comments": comments, "album": "$album - formatted", + "disc": disc, } # As-is album import. @@ -608,6 +614,7 @@ class ImportTest(ImportTestCase): item.get("album", with_album=False) == "Tag Album - formatted" ) + assert item.disc == disc # Remove album from library to test again with APPLY choice. album.remove() @@ -629,6 +636,7 @@ class ImportTest(ImportTestCase): item.get("album", with_album=False) == "Applied Album - formatted" ) + assert item.disc == disc class ImportTracksTest(ImportTestCase): From 507c91765dac7244088e98966544e41f264431e9 Mon Sep 17 00:00:00 2001 From: Adam Harder Date: Wed, 6 Nov 2024 23:17:38 -0500 Subject: [PATCH 2/4] remove debugging code --- beets/importer.py | 1 - 1 file changed, 1 deletion(-) diff --git a/beets/importer.py b/beets/importer.py index 9cb77c606..ab2382c9f 100644 --- a/beets/importer.py +++ b/beets/importer.py @@ -606,7 +606,6 @@ class ImportTask(BaseImportTask): items = self.imported_items() for field, view in config["import"]["set_fields"].items(): value = str(view.get()) - print("EEE ", value) log.debug( "Set field {1}={2} for {0}", displayable_path(self.paths), From 8448d8b4be2172e7c26c0b0766d4cfe6731cc800 Mon Sep 17 00:00:00 2001 From: Adam Harder Date: Wed, 6 Nov 2024 23:27:18 -0500 Subject: [PATCH 3/4] changelog --- docs/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 3e4266db1..15511702e 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -51,6 +51,7 @@ Bug fixes: that it no longer treats "and" and "or" queries the same. To maintain previous behaviour add commas between your query keywords. For help see :ref:`combiningqueries`. +* Fix the ``TypeError`` when ``import.set_fields`` is provided non-string values. :bug:`4840` For packagers: From a98cf47c06cc5c78ba4bd820f94b076856cd408b Mon Sep 17 00:00:00 2001 From: adamharder3 <112984767+adamharder3@users.noreply.github.com> Date: Mon, 11 Nov 2024 10:43:31 -0500 Subject: [PATCH 4/4] Update docs/changelog.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Šarūnas Nejus --- docs/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 15511702e..faa5229f6 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -51,7 +51,7 @@ Bug fixes: that it no longer treats "and" and "or" queries the same. To maintain previous behaviour add commas between your query keywords. For help see :ref:`combiningqueries`. -* Fix the ``TypeError`` when ``import.set_fields`` is provided non-string values. :bug:`4840` +* Fix the ``TypeError`` when :ref:`set_fields` is provided non-string values. :bug:`4840` For packagers: