From 7f7db33cf887c76805b7d9325d5642a628804bb7 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Mon, 31 Jul 2023 10:00:41 -0700 Subject: [PATCH 1/3] Adapt to some recent flake8/pycodestyle changes As surfaced in this CI run: https://github.com/beetbox/beets/actions/runs/5716141601/job/15486984755?pr=4866 These all look like perfectly reasonable improvements that are unlikely to break anything. --- beets/autotag/hooks.py | 2 +- beets/dbcore/query.py | 6 +++--- beets/importer.py | 2 +- beetsplug/acousticbrainz.py | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/beets/autotag/hooks.py b/beets/autotag/hooks.py index 787b81991..96208dd0c 100644 --- a/beets/autotag/hooks.py +++ b/beets/autotag/hooks.py @@ -18,7 +18,7 @@ from __future__ import annotations from collections import namedtuple from functools import total_ordering import re -from typing import Dict, List, Tuple, Iterator, Union, Any, Optional,\ +from typing import Dict, List, Tuple, Iterator, Union, Any, Optional, \ Iterable, Callable, cast from beets import logging diff --git a/beets/dbcore/query.py b/beets/dbcore/query.py index 9c04dc0ee..2e8d6eb2c 100644 --- a/beets/dbcore/query.py +++ b/beets/dbcore/query.py @@ -108,7 +108,7 @@ class Query(ABC): return f"{self.__class__.__name__}()" def __eq__(self, other) -> bool: - return type(self) == type(other) + return type(self) is type(other) def __hash__(self) -> int: """Minimalistic default implementation of a hash. @@ -868,7 +868,7 @@ class Sort: return 0 def __eq__(self, other) -> bool: - return type(self) == type(other) + return type(self) is type(other) class MultipleSort(Sort): @@ -1014,7 +1014,7 @@ class NullSort(Sort): return False def __eq__(self, other) -> bool: - return type(self) == type(other) or other is None + return type(self) is type(other) or other is None def __hash__(self) -> int: return 0 diff --git a/beets/importer.py b/beets/importer.py index 18e4bf0f1..de67b6e3f 100644 --- a/beets/importer.py +++ b/beets/importer.py @@ -1363,7 +1363,7 @@ def _freshen_items(items): def _extend_pipeline(tasks, *stages): # Return pipeline extension for stages with list of tasks - if type(tasks) == list: + if type(tasks) is list: task_iter = iter(tasks) else: task_iter = tasks diff --git a/beetsplug/acousticbrainz.py b/beetsplug/acousticbrainz.py index cda0012cf..eeb22cfdb 100644 --- a/beetsplug/acousticbrainz.py +++ b/beetsplug/acousticbrainz.py @@ -323,11 +323,11 @@ class AcousticPlugin(plugins.BeetsPlugin): """ for k, v in subscheme.items(): if k in subdata: - if type(v) == dict: + if isinstance(v, dict): yield from self._data_to_scheme_child(subdata[k], v, composites) - elif type(v) == tuple: + elif isinstance(v, tuple): composite_attribute, part_number = v attribute_parts = composites[composite_attribute] # Parts are not guaranteed to be inserted in order From 5602e9aaa8d8bb2990445adfb586efc4081c4b4f Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Mon, 31 Jul 2023 10:03:18 -0700 Subject: [PATCH 2/3] Prefer `isinstance` over `type`/`is` --- beets/importer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beets/importer.py b/beets/importer.py index de67b6e3f..15b5acc3d 100644 --- a/beets/importer.py +++ b/beets/importer.py @@ -1363,7 +1363,7 @@ def _freshen_items(items): def _extend_pipeline(tasks, *stages): # Return pipeline extension for stages with list of tasks - if type(tasks) is list: + if isinstance(tasks, list): task_iter = iter(tasks) else: task_iter = tasks From af0df4ca034abdf660e5fe3b6ccf5c6924ac7004 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Mon, 31 Jul 2023 10:26:59 -0700 Subject: [PATCH 3/3] Missed a couple of cases in tests --- test/test_datequery.py | 2 +- test/test_mbsync.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_datequery.py b/test/test_datequery.py index 56664e212..7432cffc6 100644 --- a/test/test_datequery.py +++ b/test/test_datequery.py @@ -19,7 +19,7 @@ from test import _common from datetime import datetime, timedelta import unittest import time -from beets.dbcore.query import _parse_periods, DateInterval, DateQuery,\ +from beets.dbcore.query import _parse_periods, DateInterval, DateQuery, \ InvalidQueryArgumentValueError diff --git a/test/test_mbsync.py b/test/test_mbsync.py index d1c5e48b0..443aa044e 100644 --- a/test/test_mbsync.py +++ b/test/test_mbsync.py @@ -16,7 +16,7 @@ import unittest from unittest.mock import patch -from test.helper import TestHelper,\ +from test.helper import TestHelper, \ generate_album_info, \ generate_track_info, \ capture_log