Skip to content

Commit c01dd6f

Browse files
committed
Join concatenated strings
1 parent dfd4b1d commit c01dd6f

File tree

7 files changed

+20
-35
lines changed

7 files changed

+20
-35
lines changed

beets/dbcore/query.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -690,9 +690,7 @@ class Period:
690690
("%Y-%m-%dT%H:%M:%S", "%Y-%m-%d %H:%M:%S"), # second
691691
)
692692
relative_units = {"y": 365, "m": 30, "w": 7, "d": 1}
693-
relative_re = (
694-
"(?P<sign>[+|-]?)(?P<quantity>[0-9]+)" + "(?P<timespan>[y|m|w|d])"
695-
)
693+
relative_re = "(?P<sign>[+|-]?)(?P<quantity>[0-9]+)(?P<timespan>[y|m|w|d])"
696694

697695
def __init__(self, date: datetime, precision: str):
698696
"""Create a period with the given date (a `datetime` object) and

beets/test/helper.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -837,10 +837,8 @@ def _make_track_match(self, artist, album, number):
837837
)
838838

839839
def _make_album_match(self, artist, album, tracks, distance=0, missing=0):
840-
if distance:
841-
id = " " + "M" * distance
842-
else:
843-
id = ""
840+
id = f" {'M' * distance}" if distance else ""
841+
844842
if artist is None:
845843
artist = "Various Artists"
846844
else:

beets/ui/commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def _print_keys(query):
136136
def fields_func(lib, opts, args):
137137
def _print_rows(names):
138138
names.sort()
139-
print_(" " + "\n ".join(names))
139+
print_(f" {'\n '.join(names)}")
140140

141141
print_("Item fields:")
142142
_print_rows(library.Item.all_keys())

beetsplug/bpd/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,7 @@ def cmd_stats(self, conn):
13291329
"albums: " + str(albums),
13301330
"songs: " + str(songs),
13311331
"uptime: " + str(int(time.time() - self.startup_time)),
1332-
"playtime: " + "0", # Missing.
1332+
"playtime: 0", # Missing.
13331333
"db_playtime: " + str(int(totaltime)),
13341334
"db_update: " + str(int(self.updated_time)),
13351335
)

beetsplug/fish.py

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,9 @@ def run(self, lib, opts, args):
127127
totstring += get_cmds_list([name[0] for name in cmd_names_help])
128128
totstring += "" if nobasicfields else get_standard_fields(fields)
129129
totstring += get_extravalues(lib, extravalues) if extravalues else ""
130-
totstring += (
131-
"\n" + "# ====== setup basic beet completion =====" + "\n" * 2
132-
)
130+
totstring += "\n# ====== setup basic beet completion =====\n\n"
133131
totstring += get_basic_beet_options()
134-
totstring += (
135-
"\n"
136-
+ "# ====== setup field completion for subcommands ====="
137-
+ "\n"
138-
)
132+
totstring += "\n# ====== setup field completion for subcommands =====\n"
139133
totstring += get_subcommands(cmd_names_help, nobasicfields, extravalues)
140134
# Set up completion for all the command options
141135
totstring += get_all_commands(beetcmds)
@@ -153,17 +147,13 @@ def _escape(name):
153147

154148
def get_cmds_list(cmds_names):
155149
# Make a list of all Beets core & plugin commands
156-
substr = ""
157-
substr += "set CMDS " + " ".join(cmds_names) + ("\n" * 2)
158-
return substr
150+
return f"set CMDS {' '.join(cmds_names)}\n\n"
159151

160152

161153
def get_standard_fields(fields):
162154
# Make a list of album/track fields and append with ':'
163155
fields = (field + ":" for field in fields)
164-
substr = ""
165-
substr += "set FIELDS " + " ".join(fields) + ("\n" * 2)
166-
return substr
156+
return f"set FIELDS {' '.join(fields)}\n\n"
167157

168158

169159
def get_extravalues(lib, extravalues):
@@ -223,16 +213,16 @@ def get_subcommands(cmd_name_and_help, nobasicfields, extravalues):
223213
for cmdname, cmdhelp in cmd_name_and_help:
224214
cmdname = _escape(cmdname)
225215

226-
word += "\n" + f"# ------ fieldsetups for {cmdname} -------" + "\n"
216+
word += "\n" + f"# ------ fieldsetups for {cmdname} -------\n"
227217
word += BL_NEED2.format(
228-
("-a " + cmdname), ("-f " + "-d " + wrap(clean_whitespace(cmdhelp)))
218+
("-a " + cmdname), ("-f -d " + wrap(clean_whitespace(cmdhelp)))
229219
)
230220

231221
if nobasicfields is False:
232222
word += BL_USE3.format(
233223
cmdname,
234224
("-a " + wrap("$FIELDS")),
235-
("-f " + "-d " + wrap("fieldname")),
225+
("-f -d " + wrap("fieldname")),
236226
)
237227

238228
if extravalues:
@@ -242,7 +232,7 @@ def get_subcommands(cmd_name_and_help, nobasicfields, extravalues):
242232
" ".join(
243233
BL_EXTRA3.format(
244234
(cmdname + " " + f + ":"),
245-
("-f " + "-A " + "-a " + setvar),
235+
("-f -A -a " + setvar),
246236
("-d " + wrap(f)),
247237
).split()
248238
)
@@ -260,8 +250,7 @@ def get_all_commands(beetcmds):
260250
for name in names:
261251
name = _escape(name)
262252

263-
word += "\n"
264-
word += ("\n" * 2) + f"# ====== completions for {name} =====" + "\n"
253+
word += f"\n\n\n# ====== completions for {name} =====\n"
265254

266255
for option in cmd.parser._get_all_options()[1:]:
267256
cmd_l = (
@@ -306,7 +295,7 @@ def get_all_commands(beetcmds):
306295
word = word + " ".join(
307296
BL_USE3.format(
308297
name,
309-
("-s " + "h " + "-l " + "help" + " -f "),
298+
("-s h -l help -f "),
310299
("-d " + wrap("print help") + "\n"),
311300
).split()
312301
)

beetsplug/spotify.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -671,8 +671,8 @@ def _output_match_results(self, results):
671671
self._log.info(
672672
f"Attempting to open {self.data_source} with playlist"
673673
)
674-
spotify_url = "spotify:trackset:Playlist:" + ",".join(
675-
spotify_ids
674+
spotify_url = (
675+
f"spotify:trackset:Playlist:{','.join(spotify_ids)}"
676676
)
677677
webbrowser.open(spotify_url)
678678
else:

test/plugins/test_playlist.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def setup_test(self):
132132
[
133133
os.path.join("a", "b", "c.mp3") + "\n",
134134
os.path.join("d", "e", "f.mp3") + "\n",
135-
"nonexisting.mp3" + "\n",
135+
"nonexisting.mp3\n",
136136
]
137137
)
138138

@@ -155,7 +155,7 @@ def setup_test(self):
155155
[
156156
os.path.join("a", "b", "c.mp3") + "\n",
157157
os.path.join("d", "e", "f.mp3") + "\n",
158-
"nonexisting.mp3" + "\n",
158+
"nonexisting.mp3\n",
159159
]
160160
)
161161

@@ -214,7 +214,7 @@ def setup_test(self):
214214
[
215215
os.path.join("a", "b", "c.mp3") + "\n",
216216
os.path.join("d", "e", "f.mp3") + "\n",
217-
"nonexisting.mp3" + "\n",
217+
"nonexisting.mp3\n",
218218
]
219219
)
220220

0 commit comments

Comments
 (0)