Skip to content

Commit 5c97e66

Browse files
committed
chore: Run ruff check --fix
1 parent 959dbcc commit 5c97e66

16 files changed

Lines changed: 147 additions & 134 deletions

examples/collection.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def show_collection(collection_id, ctype):
9696
name=collection["name"], editor=collection["editor"], mbid=collection["id"]
9797
)
9898
)
99-
print("")
99+
print()
100100
# release count is only available starting with musicbrainzngs 0.5
101101
if "release-count" in collection:
102102
print("{} releases".format(collection["release-count"]))
@@ -110,7 +110,7 @@ def show_collection(collection_id, ctype):
110110
print("{} recordings".format(collection["recording-count"]))
111111
if "work-count" in collection:
112112
print("{} works".format(collection["work-count"]))
113-
print("")
113+
print()
114114

115115
if "release-list" in collection:
116116
show_releases(collection)
@@ -124,7 +124,7 @@ def show_releases(collection):
124124
print("Releases:")
125125
releases_fetched = 0
126126
while len(release_list) > 0:
127-
print("")
127+
print()
128128
releases_fetched += len(release_list)
129129
for release in release_list:
130130
print("{title} ({mbid})".format(title=release["title"], mbid=release["id"]))
@@ -136,7 +136,7 @@ def show_releases(collection):
136136
collection = result["collection"]
137137
release_list = collection["release-list"]
138138

139-
print("")
139+
print()
140140
print("Number of fetched releases: %d" % releases_fetched)
141141

142142

@@ -154,7 +154,7 @@ def show_releases(collection):
154154
username = args.pop(0)
155155

156156
# Input the password.
157-
password = getpass.getpass("Password for {}: ".format(username))
157+
password = getpass.getpass(f"Password for {username}: ")
158158

159159
# Call musicbrainzngs.auth() before making any API calls that
160160
# require authentication.
@@ -175,9 +175,9 @@ def show_releases(collection):
175175
sys.exit("only release collections can be modified ATM")
176176
else:
177177
# Print out the collection's contents.
178-
print("")
178+
print()
179179
show_collection(collection_id, options.type)
180180
else:
181181
# Show all collections.
182-
print("")
182+
print()
183183
show_collections()

examples/find_disc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ def show_offsets(offset_list):
4141
offsets = str(offset)
4242
else:
4343
offsets += " " + str(offset)
44-
print("\toffsets: {}".format(offsets))
44+
print(f"\toffsets: {offsets}")
4545

4646

4747
if __name__ == "__main__":
4848
args = sys.argv[1:]
4949
if len(args) != 1:
50-
sys.exit("usage: {} DISC_ID".format(sys.argv[0]))
50+
sys.exit(f"usage: {sys.argv[0]} DISC_ID")
5151
discid = args[0]
5252

5353
try:
@@ -69,7 +69,7 @@ def show_offsets(offset_list):
6969
print("\tTracks: {}".format(result["disc"]["offset-count"]))
7070
for release in result["disc"]["release-list"]:
7171
show_release_details(release)
72-
print("")
72+
print()
7373
elif result.get("cdstub"):
7474
print("cdstub:")
7575
print("\tArtist: {}".format(result["cdstub"]["artist"]))

examples/releasesearch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def show_release_details(rel):
3333
if __name__ == "__main__":
3434
args = sys.argv[1:]
3535
if len(args) != 2:
36-
sys.exit("usage: {} ARTIST ALBUM".format(sys.argv[0]))
36+
sys.exit(f"usage: {sys.argv[0]} ARTIST ALBUM")
3737
artist, album = args
3838

3939
# Keyword arguments to the "search_*" functions limit keywords to
@@ -46,6 +46,6 @@ def show_release_details(rel):
4646
if not result["release-list"]:
4747
sys.exit("no release found")
4848
for idx, release in enumerate(result["release-list"]):
49-
print("match #{}:".format(idx + 1))
49+
print(f"match #{idx + 1}:")
5050
show_release_details(release)
5151
print()

musicbrainzngs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
from musicbrainzngs.musicbrainz import *
21
from musicbrainzngs.caa import *
2+
from musicbrainzngs.musicbrainz import *

musicbrainzngs/caa.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
# See the COPYING file for more information.
55

66
__all__ = [
7-
"set_caa_hostname",
7+
"get_image",
8+
"get_image_back",
9+
"get_image_front",
810
"get_image_list",
9-
"get_release_group_image_list",
1011
"get_release_group_image_front",
11-
"get_image_front",
12-
"get_image_back",
13-
"get_image",
12+
"get_release_group_image_list",
13+
"set_caa_hostname",
1414
]
1515

1616
import json
@@ -83,10 +83,9 @@ def _caa_request(mbid, imageid=None, size=None, entitytype="release"):
8383
if imageid:
8484
# If we asked for an image, return the image
8585
return resp
86-
else:
87-
# Otherwise it's json
88-
data = _unicode(resp)
89-
return json.loads(data)
86+
# Otherwise it's json
87+
data = _unicode(resp)
88+
return json.loads(data)
9089

9190

9291
def get_image_list(releaseid):

musicbrainzngs/mbxml.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ def fixtag(tag, namespaces: dict[str, str]):
3333
def get_error_message(error):
3434
"""Given an error XML message from the webservice containing
3535
<error><text>x</text><text>y</text></error>, return a list
36-
of [x, y]"""
36+
of [x, y]
37+
"""
3738
try:
3839
tree = util.bytes_to_elementtree(error)
3940
root = tree.getroot()
@@ -92,7 +93,7 @@ def parse_elements(valid_els: list[str], inner_els: dict, element) -> dict:
9293
t = t.split(":")[1]
9394
if t in valid_els:
9495
result[t] = sub.text or ""
95-
elif t in inner_els.keys():
96+
elif t in inner_els:
9697
inner_result = inner_els[t](sub)
9798
if isinstance(inner_result, tuple) and inner_result[0]:
9899
result.update(inner_result[1])
@@ -368,8 +369,7 @@ def parse_relation_target(tgt):
368369
attributes = parse_attributes(["id"], tgt)
369370
if "id" in attributes:
370371
return (True, {"target-id": attributes["id"]})
371-
else:
372-
return (True, {"target-id": tgt.text})
372+
return (True, {"target-id": tgt.text})
373373

374374

375375
def parse_relation_list(rl):
@@ -460,7 +460,8 @@ def parse_release(release):
460460
def parse_medium_list(ml):
461461
"""medium-list results from search have an additional
462462
<track-count> element containing the number of tracks
463-
over all mediums. Optionally add this"""
463+
over all mediums. Optionally add this
464+
"""
464465
medium_list = []
465466
track_count = None
466467
for m in ml:

0 commit comments

Comments
 (0)