Bump ruff from 0.4.10 to 0.5.0 (#1430)
authordependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Wed, 3 Jul 2024 06:44:33 +0000 (08:44 +0200)
committerGitHub <noreply@github.com>
Wed, 3 Jul 2024 06:44:33 +0000 (08:44 +0200)
* Bump ruff from 0.4.10 to 0.5.0

Bumps [ruff](https://github.com/astral-sh/ruff) from 0.4.10 to 0.5.0.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](https://github.com/astral-sh/ruff/compare/v0.4.10...0.5.0)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Marcel van der Veldt <m.vanderveldt@outlook.com>
music_assistant/common/helpers/util.py
music_assistant/common/models/config_entries.py
music_assistant/common/models/media_items.py
music_assistant/server/helpers/compare.py
pyproject.toml

index 62b5c433601f610849c581b8bbe942884d66e7b9..cdc4f1c05280e97f805c75076a7c27eb516410e9 100644 (file)
@@ -21,8 +21,8 @@ keyword_pattern = re.compile("title=|artist=")
 title_pattern = re.compile(r"title=\"(?P<title>.*?)\"")
 artist_pattern = re.compile(r"artist=\"(?P<artist>.*?)\"")
 dot_com_pattern = re.compile(r"(?P<netloc>\(?\w+\.(?:\w+\.)?(\w{2,3})\)?)")
-ad_pattern = re.compile(r"((ad|advertisement)_)|^AD\s\d+$|ADBREAK", flags=re.I)
-title_artist_order_pattern = re.compile(r"(?P<title>.+)\sBy:\s(?P<artist>.+)", flags=re.I)
+ad_pattern = re.compile(r"((ad|advertisement)_)|^AD\s\d+$|ADBREAK", flags=re.IGNORECASE)
+title_artist_order_pattern = re.compile(r"(?P<title>.+)\sBy:\s(?P<artist>.+)", flags=re.IGNORECASE)
 multi_space_pattern = re.compile(r"\s{2,}")
 end_junk_pattern = re.compile(r"(.+?)(\s\W+)$")
 
index 27ccf59d16b67e260f859766747409a4c5831688..7dc60b1d2ce87b93cfbd923cf80252dc1e09a4e7 100644 (file)
@@ -146,10 +146,10 @@ class ConfigEntry(DataClassDictMixin):
             value = self.label
         if not isinstance(value, expected_type):
             # handle common conversions/mistakes
-            if expected_type == float and isinstance(value, int):
+            if expected_type is float and isinstance(value, int):
                 self.value = float(value)
                 return self.value
-            if expected_type == int and isinstance(value, float):
+            if expected_type is int and isinstance(value, float):
                 self.value = int(value)
                 return self.value
             for val_type in (int, float):
index d271b111956c026d9433c68eda6ab63acd277c47..28a3a4cd20605b9b5e9f3b1b499ef1b46689f3e1 100644 (file)
@@ -415,6 +415,7 @@ class Album(MediaItem):
 class Track(MediaItem):
     """Model for a track."""
 
+    __hash__ = _MediaItemBase.__hash__
     __eq__ = _MediaItemBase.__eq__
 
     media_type: MediaType = MediaType.TRACK
@@ -425,10 +426,6 @@ class Track(MediaItem):
     disc_number: int | None = None  # required for album tracks
     track_number: int | None = None  # required for album tracks
 
-    def __hash__(self) -> int:
-        """Return custom hash."""
-        return hash((self.provider, self.item_id))
-
     @property
     def has_chapters(self) -> bool:
         """
index 38f3c3911a377eb31ad0eb30b055421f3330b4d9..692890600028993a2b7d52ac8271393b3379d069 100644 (file)
@@ -192,16 +192,13 @@ def compare_track(
         for track_album in track_albums:
             if compare_album(track_album, compare_item.album, False):
                 return True
-    # edge case: albumless track
-    if (
+    # accept last resort: albumless track and (near) exact duration
+    # otherwise fail all other cases
+    return (
         base_item.album is None
         and compare_item.album is None
         and abs(base_item.duration - compare_item.duration) <= 1
-    ):
-        return True
-
-    # all efforts failed, this is NOT a match
-    return False
+    )
 
 
 def compare_playlist(
@@ -384,9 +381,7 @@ def loose_compare_strings(base: str, alt: str) -> bool:
     alt_comp = create_safe_string(alt)
     if base_comp in alt_comp:
         return True
-    if alt_comp in base_comp:
-        return True
-    return False
+    return alt_comp in base_comp
 
 
 def compare_strings(str1: str, str2: str, strict: bool = True) -> bool:
index 28c16849d205be053d9b8d141e4713567affcf72..582328219ba1037eb9e0102c71140bc067ec035a 100644 (file)
@@ -54,7 +54,7 @@ test = [
   "pytest-cov==5.0.0",
   "syrupy==4.6.1",
   "tomli==2.0.1",
-  "ruff==0.4.10",
+  "ruff==0.5.0",
 ]
 
 [project.scripts]