Skip to content

Commit

Permalink
Merge pull request #370 from pylast/pre-commmit
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Aug 2, 2021
2 parents e193106 + a850f09 commit fd520ad
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 26 deletions.
21 changes: 12 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v2.10.0
rev: v2.23.1
hooks:
- id: pyupgrade
args: ["--py36-plus"]

- repo: https://github.com/psf/black
rev: 20.8b1
rev: 21.7b0
hooks:
- id: black
args: ["--target-version", "py36"]
Expand All @@ -15,35 +15,38 @@ repos:
types: []

- repo: https://github.com/asottile/blacken-docs
rev: v1.9.2
rev: v1.10.0
hooks:
- id: blacken-docs
args: ["--target-version", "py36"]
additional_dependencies: [black==20.8b1]

- repo: https://github.com/PyCQA/isort
rev: 5.7.0
rev: 5.9.3
hooks:
- id: isort

- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
hooks:
- id: flake8
additional_dependencies: [flake8-2020, flake8-implicit-str-concat]

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.7.1
rev: v1.9.0
hooks:
- id: python-check-blanket-noqa

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
rev: v4.0.1
hooks:
- id: check-merge-conflict
- id: check-yaml

- repo: https://github.com/tox-dev/tox-ini-fmt
rev: 0.5.0
rev: 0.5.1
hooks:
- id: tox-ini-fmt

ci:
autoupdate_schedule: quarterly
35 changes: 20 additions & 15 deletions src/pylast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,7 @@ def remove_tags(self, tags):
self.remove_tag(tag)

def clear_tags(self):
"""Clears all the user-set tags. """
"""Clears all the user-set tags."""

self.remove_tags(*(self.get_tags()))

Expand Down Expand Up @@ -1702,7 +1702,7 @@ def __init__(self, name, network, username=None, info=None):
self.info = info

def __repr__(self):
return "pylast.Artist({}, {})".format(repr(self.get_name()), repr(self.network))
return f"pylast.Artist({repr(self.get_name())}, {repr(self.network)})"

def __unicode__(self):
return str(self.get_name())
Expand Down Expand Up @@ -1798,9 +1798,14 @@ def get_bio(self, section, language=None):
else:
params = None

return self._extract_cdata_from_request(
self.ws_prefix + ".getInfo", section, params
)
try:
bio = self._extract_cdata_from_request(
self.ws_prefix + ".getInfo", section, params
)
except IndexError:
bio = None

return bio

def get_bio_published_date(self):
"""Returns the date on which the artist's biography was published."""
Expand Down Expand Up @@ -1886,7 +1891,7 @@ def __init__(self, name, network):
self.name = name

def __repr__(self):
return "pylast.Country({}, {})".format(repr(self.name), repr(self.network))
return f"pylast.Country({repr(self.name)}, {repr(self.network)})"

@_string_output
def __str__(self):
Expand All @@ -1902,7 +1907,7 @@ def _get_params(self): # TODO can move to _BaseObject
return {"country": self.get_name()}

def get_name(self):
"""Returns the country name. """
"""Returns the country name."""

return self.name

Expand Down Expand Up @@ -1964,7 +1969,7 @@ def __init__(self, user, network):
self.user = User(user, self.network)

def __repr__(self):
return "pylast.Library({}, {})".format(repr(self.user), repr(self.network))
return f"pylast.Library({repr(self.user)}, {repr(self.network)})"

@_string_output
def __str__(self):
Expand Down Expand Up @@ -2010,7 +2015,7 @@ def __init__(self, name, network):
self.name = name

def __repr__(self):
return "pylast.Tag({}, {})".format(repr(self.name), repr(self.network))
return f"pylast.Tag({repr(self.name)}, {repr(self.network)})"

@_string_output
def __str__(self):
Expand All @@ -2026,7 +2031,7 @@ def _get_params(self):
return {self.ws_prefix: self.get_name()}

def get_name(self, properly_capitalized=False):
"""Returns the name of the tag. """
"""Returns the name of the tag."""

if properly_capitalized:
self.name = _extract(
Expand Down Expand Up @@ -2149,12 +2154,12 @@ def get_album(self):
return Album(_extract(node, "artist"), _extract(node, "title"), self.network)

def love(self):
"""Adds the track to the user's loved tracks. """
"""Adds the track to the user's loved tracks."""

self._request(self.ws_prefix + ".love")

def unlove(self):
"""Remove the track to the user's loved tracks. """
"""Remove the track to the user's loved tracks."""

self._request(self.ws_prefix + ".unlove")

Expand Down Expand Up @@ -2220,7 +2225,7 @@ def __init__(self, user_name, network):
self.name = user_name

def __repr__(self):
return "pylast.User({}, {})".format(repr(self.name), repr(self.network))
return f"pylast.User({repr(self.name)}, {repr(self.network)})"

@_string_output
def __str__(self):
Expand Down Expand Up @@ -2259,7 +2264,7 @@ def get_name(self, properly_capitalized=False):
return self.name

def get_friends(self, limit=50, cacheable=False, stream=False):
"""Returns a list of the user's friends. """
"""Returns a list of the user's friends."""

def _get_friends():
for node in _collect_nodes(
Expand Down Expand Up @@ -2604,7 +2609,7 @@ def get_url(self, domain_name=DOMAIN_ENGLISH):
return self.network._get_url(domain_name, "user") % {"name": name}

def get_library(self):
"""Returns the associated Library object. """
"""Returns the associated Library object."""

return Library(self, self.network)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_album.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ def test_get_cover_image(self):

# Assert
self.assert_startswith(image, "https://")
self.assert_endswith(image, ".png")
self.assert_endswith(image, ".gif")
4 changes: 3 additions & 1 deletion tests/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,10 @@ def test_artist_mbid(self):

# Assert
assert isinstance(artist, pylast.Artist)
assert artist.name == "MusicBrainz Test Artist"
assert artist.name in ("MusicBrainz Test Artist", "MusicBrainzz Test Artist")

@pytest.mark.xfail(reason="Broken at Last.fm: Track not found")
# https://support.last.fm/t/track-getinfo-with-mbid-returns-6-track-not-found/47905
def test_track_mbid(self):
# Arrange
mbid = "ebc037b1-cc9c-44f2-a21f-83c219f0e1e0"
Expand Down

0 comments on commit fd520ad

Please sign in to comment.