Skip to content

Commit 7985897

Browse files
committed
chore: refactor code quality issues
1 parent debd382 commit 7985897

13 files changed

Lines changed: 19 additions & 18 deletions

File tree

beets/dbcore/db.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,10 +729,10 @@ def __iter__(self):
729729
def _get_indexed_flex_attrs(self):
730730
""" Index flexible attributes by the entity id they belong to
731731
"""
732-
flex_values = dict()
732+
flex_values = {}
733733
for row in self.flex_rows:
734734
if row['entity_id'] not in flex_values:
735-
flex_values[row['entity_id']] = dict()
735+
flex_values[row['entity_id']] = {}
736736

737737
flex_values[row['entity_id']][row['key']] = row['value']
738738

beets/importer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def __init__(self, lib, loghandler, paths, query):
187187
self.logger = self._setup_logging(loghandler)
188188
self.paths = paths
189189
self.query = query
190-
self._is_resuming = dict()
190+
self._is_resuming = {}
191191
self._merged_items = set()
192192
self._merged_dirs = set()
193193

beets/ui/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ def _store_dict(option, opt_str, value, parser):
791791
if option_values is None:
792792
# This is the first supplied ``key=value`` pair of option.
793793
# Initialize empty dictionary and get a reference to it.
794-
setattr(parser.values, dest, dict())
794+
setattr(parser.values, dest, {})
795795
option_values = getattr(parser.values, dest)
796796

797797
try:

beetsplug/bpd/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from __future__ import division, absolute_import, print_function
2222

2323
import re
24+
import sys
2425
from string import Template
2526
import traceback
2627
import random
@@ -334,7 +335,7 @@ def cmd_idle(self, conn, *subsystems):
334335

335336
def cmd_kill(self, conn):
336337
"""Exits the server process."""
337-
exit(0)
338+
sys.exit(0)
338339

339340
def cmd_close(self, conn):
340341
"""Closes the connection."""

beetsplug/export.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
class ExportEncoder(json.JSONEncoder):
3434
"""Deals with dates because JSON doesn't have a standard"""
3535
def default(self, o):
36-
if isinstance(o, datetime) or isinstance(o, date):
36+
if isinstance(o, (datetime, date)):
3737
return o.isoformat()
3838
return json.JSONEncoder.default(self, o)
3939

beetsplug/fetchart.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ def get(self, album, plugin, paths):
504504

505505
matches = []
506506
# can there be more than one releasegroupid per response?
507-
for mbid, art in data.get(u'albums', dict()).items():
507+
for mbid, art in data.get(u'albums', {}).items():
508508
# there might be more art referenced, e.g. cdart, and an albumcover
509509
# might not be present, even if the request was successful
510510
if album.mb_releasegroupid == mbid and u'albumcover' in art:

beetsplug/fish.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def run(self, lib, opts, args):
110110
# Collect commands, their aliases, and their help text
111111
cmd_names_help = []
112112
for cmd in beetcmds:
113-
names = [alias for alias in cmd.aliases]
113+
names = list(cmd.aliases)
114114
names.append(cmd.name)
115115
for name in names:
116116
cmd_names_help.append((name, cmd.help))
@@ -238,7 +238,7 @@ def get_all_commands(beetcmds):
238238
# Formatting for Fish to complete command options
239239
word = ""
240240
for cmd in beetcmds:
241-
names = [alias for alias in cmd.aliases]
241+
names = list(cmd.aliases)
242242
names.append(cmd.name)
243243
for name in names:
244244
name = _escape(name)

beetsplug/importadded.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __init__(self):
2727
# album.path for old albums that were replaced by a reimported album
2828
self.replaced_album_paths = None
2929
# item path in the library to the mtime of the source file
30-
self.item_mtime = dict()
30+
self.item_mtime = {}
3131

3232
register = self.register_listener
3333
register('import_task_created', self.check_config)

beetsplug/info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def filter_(data):
235235
matchers.append(re.compile(key + '$'))
236236

237237
def filter_(data):
238-
filtered = dict()
238+
filtered = {}
239239
for key, value in data.items():
240240
if any([m.match(key) for m in matchers]):
241241
filtered[key] = value

beetsplug/mbsync.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def albums(self, lib, query, move, pretend, write):
123123
# Map release track and recording MBIDs to their information.
124124
# Recordings can appear multiple times on a release, so each MBID
125125
# maps to a list of TrackInfo objects.
126-
releasetrack_index = dict()
126+
releasetrack_index = {}
127127
track_index = defaultdict(list)
128128
for track_info in album_info.tracks:
129129
releasetrack_index[track_info.release_track_id] = track_info

0 commit comments

Comments
 (0)