Skip to content

Commit

Permalink
drop musify object on get_max_width + fix get max width on log_sync
Browse files Browse the repository at this point in the history
  • Loading branch information
geo-martino committed Jan 1, 2025
1 parent 33d7be3 commit 91059aa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
7 changes: 4 additions & 3 deletions docs/info/release-history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ and this project adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0
1.2.5
=====

Changed
-------
* :py:func:`.get_max_width` extracts name when collection of :py:class:`.MusifyObject` given
Fixed
-----
* :py:meth:`.RemoteLibrary.log_sync` now correctly gets max width from results
when :py:class:`.RemotePlaylist` is given in results


1.2.4
Expand Down
2 changes: 1 addition & 1 deletion musify/libraries/remote/core/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ def log_sync(
if not isinstance(results, Mapping):
results = {"": results}

max_width = get_max_width(results)
max_width = get_max_width({pl.name if isinstance(pl, RemotePlaylist) else pl for pl in results})

self.logger.stat(f"\33[1;96mSync {self.api.source} playlists' stats: \33[0m")
for pl, result in results.items():
Expand Down
3 changes: 0 additions & 3 deletions musify/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from aiorequestful.types import Number

from musify.base import MusifyObject
from musify.exception import MusifyTypeError, MusifyImportError


Expand Down Expand Up @@ -126,8 +125,6 @@ def get_max_width(values: Collection[Any], min_width: int = 15, max_width: int =
"""
if len(values) == 0:
return min_width

values = {val.name if isinstance(val, MusifyObject) else val for val in values}
max_len = unicode_len(max(map(str, values), key=unicode_len))
return limit_value(value=max_len + 1, floor=min_width, ceil=max_width)

Expand Down

0 comments on commit 91059aa

Please sign in to comment.