From ee4268dabbb728a9c3c4403a6b91a4df5155b809 Mon Sep 17 00:00:00 2001 From: Andrew Rogl Date: Thu, 26 Aug 2021 20:59:48 +1000 Subject: [PATCH] Remove unused imports Fix imports Fix formatting --- beets/autotag/mb.py | 2 +- beets/util/__init__.py | 7 +++---- beets/util/artresizer.py | 2 +- beets/util/pipeline.py | 2 +- beetsplug/acousticbrainz.py | 8 ++++---- beetsplug/badfiles.py | 1 - beetsplug/bareasc.py | 9 ++++----- beetsplug/beatport.py | 1 - beetsplug/bpd/__init__.py | 1 - beetsplug/bpd/gstplayer.py | 5 ++--- beetsplug/bucket.py | 6 +++--- beetsplug/convert.py | 2 +- beetsplug/deezer.py | 1 - beetsplug/discogs.py | 6 +++--- beetsplug/duplicates.py | 1 - beetsplug/edit.py | 1 - beetsplug/embyupdate.py | 4 +--- beetsplug/fetchart.py | 1 - beetsplug/fromfilename.py | 1 - beetsplug/hook.py | 5 +++-- beetsplug/importadded.py | 4 ++-- beetsplug/inline.py | 1 - beetsplug/kodiupdate.py | 1 - beetsplug/lastgenre/__init__.py | 4 +--- beetsplug/lyrics.py | 9 ++++----- beetsplug/mbsubmit.py | 1 - beetsplug/metasync/__init__.py | 1 - beetsplug/metasync/itunes.py | 12 ++++++------ beetsplug/mpdstats.py | 29 +++++++++++++---------------- beetsplug/mpdupdate.py | 1 - beetsplug/permissions.py | 1 - beetsplug/plexupdate.py | 2 +- beetsplug/replaygain.py | 1 - beetsplug/smartplaylist.py | 5 ++--- beetsplug/spotify.py | 1 - beetsplug/subsonicplaylist.py | 4 ++-- beetsplug/thumbnails.py | 1 - beetsplug/unimported.py | 2 +- beetsplug/zero.py | 1 - setup.py | 1 - test/__init__.py | 1 - test/helper.py | 4 ++-- test/test_art_resize.py | 1 - test/test_beatport.py | 1 - test/test_config_command.py | 1 - test/test_convert.py | 3 ++- test/test_dbcore.py | 2 -- test/test_importadded.py | 9 +++++---- test/test_ipfs.py | 3 ++- test/test_lastgenre.py | 1 - test/test_library.py | 1 - test/test_logging.py | 1 - test/test_lyrics.py | 1 - test/test_playlist.py | 17 +++++++++-------- test/test_plugin_mediafield.py | 1 - test/test_query.py | 1 - test/test_replaygain.py | 3 +-- test/test_smartplaylist.py | 2 +- test/test_subsonicupdate.py | 3 ++- test/test_template.py | 1 - test/test_ui_importer.py | 1 - test/test_util.py | 1 - test/test_web.py | 2 +- 63 files changed, 84 insertions(+), 125 deletions(-) diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py index cb74d5b30..f659f15cb 100644 --- a/beets/autotag/mb.py +++ b/beets/autotag/mb.py @@ -18,7 +18,6 @@ import musicbrainzngs import re import traceback -from six.moves.urllib.parse import urljoin from beets import logging from beets import plugins @@ -26,6 +25,7 @@ import beets.autotag.hooks import beets from beets import util from beets import config +from urllib.parse import urljoin VARIOUS_ARTISTS_ID = '89ad4ac3-39f7-470e-963a-56509c546377' diff --git a/beets/util/__init__.py b/beets/util/__init__.py index 7a47ad48e..6ee8d68a3 100644 --- a/beets/util/__init__.py +++ b/beets/util/__init__.py @@ -29,7 +29,6 @@ import subprocess import platform import shlex from beets.util import hidden -import six from unidecode import unidecode from enum import Enum @@ -100,6 +99,7 @@ class FilesystemError(HumanReadableException): via a function in this module. The `paths` field is a sequence of pathnames involved in the operation. """ + def __init__(self, reason, verb, paths, tb=None): self.paths = paths super().__init__(reason, verb, tb) @@ -599,6 +599,7 @@ def unique_path(path): if not os.path.exists(new_path): return new_path + # Note: The Windows "reserved characters" are, of course, allowed on # Unix. They are forbidden here because they cause problems on Samba # shares, which are sufficiently common as to cause frequent problems. @@ -736,8 +737,6 @@ def py3_path(path): if isinstance(path, str): return path assert isinstance(path, bytes) - if six.PY2: - return path return os.fsdecode(path) @@ -801,7 +800,7 @@ def cpu_count(): '/usr/sbin/sysctl', '-n', 'hw.ncpu', - ]).stdout) + ]).stdout) except (ValueError, OSError, subprocess.CalledProcessError): num = 0 else: diff --git a/beets/util/artresizer.py b/beets/util/artresizer.py index 40efbc9fd..725712ed4 100644 --- a/beets/util/artresizer.py +++ b/beets/util/artresizer.py @@ -20,7 +20,7 @@ import subprocess import os import re from tempfile import NamedTemporaryFile -from six.moves.urllib.parse import urlencode +from urllib.parse import urlencode from beets import logging from beets import util diff --git a/beets/util/pipeline.py b/beets/util/pipeline.py index fa7e5eb31..d338cb51b 100644 --- a/beets/util/pipeline.py +++ b/beets/util/pipeline.py @@ -32,7 +32,7 @@ in place of any single coroutine. """ -from six.moves import queue +import queue from threading import Thread, Lock import sys diff --git a/beetsplug/acousticbrainz.py b/beetsplug/acousticbrainz.py index 4e065eaf9..eabc5849f 100644 --- a/beetsplug/acousticbrainz.py +++ b/beetsplug/acousticbrainz.py @@ -287,8 +287,8 @@ class AcousticPlugin(plugins.BeetsPlugin): # The recursive traversal. composites = defaultdict(list) yield from self._data_to_scheme_child(data, - scheme, - composites) + scheme, + composites) # When composites has been populated, yield the composite attributes # by joining their parts. @@ -309,8 +309,8 @@ class AcousticPlugin(plugins.BeetsPlugin): if k in subdata: if type(v) == dict: yield from self._data_to_scheme_child(subdata[k], - v, - composites) + v, + composites) elif type(v) == tuple: composite_attribute, part_number = v attribute_parts = composites[composite_attribute] diff --git a/beetsplug/badfiles.py b/beetsplug/badfiles.py index 874d533ce..ec465895b 100644 --- a/beetsplug/badfiles.py +++ b/beetsplug/badfiles.py @@ -22,7 +22,6 @@ import shlex import os import errno import sys -import six import confuse from beets.plugins import BeetsPlugin from beets.ui import Subcommand diff --git a/beetsplug/bareasc.py b/beetsplug/bareasc.py index 10fd25d46..218369364 100644 --- a/beetsplug/bareasc.py +++ b/beetsplug/bareasc.py @@ -24,7 +24,6 @@ from beets.ui import print_, decargs from beets.plugins import BeetsPlugin from beets.dbcore.query import StringFieldQuery from unidecode import unidecode -import six class BareascQuery(StringFieldQuery): @@ -75,9 +74,9 @@ class BareascPlugin(BeetsPlugin): # Copied from commands.py - list_items if album: for album in lib.albums(query): - bare = unidecode(six.ensure_text(str(album))) - print_(six.ensure_text(bare)) + bare = unidecode(str(album)) + print_(bare) else: for item in lib.items(query): - bare = unidecode(six.ensure_text(str(item))) - print_(six.ensure_text(bare)) + bare = unidecode(str(item)) + print_(bare) diff --git a/beetsplug/beatport.py b/beetsplug/beatport.py index e2701bdb3..133441d7e 100644 --- a/beetsplug/beatport.py +++ b/beetsplug/beatport.py @@ -17,7 +17,6 @@ import json import re -import six from datetime import datetime, timedelta from requests_oauthlib import OAuth1Session diff --git a/beetsplug/bpd/__init__.py b/beetsplug/bpd/__init__.py index dc58c81a5..07198b1b4 100644 --- a/beetsplug/bpd/__init__.py +++ b/beetsplug/bpd/__init__.py @@ -36,7 +36,6 @@ from beets.util import bluelet from beets.library import Item from beets import dbcore from mediafile import MediaFile -import six PROTOCOL_VERSION = '0.16.0' BUFSIZE = 1024 diff --git a/beetsplug/bpd/gstplayer.py b/beetsplug/bpd/gstplayer.py index 8cb6d56cf..64954b1c1 100644 --- a/beetsplug/bpd/gstplayer.py +++ b/beetsplug/bpd/gstplayer.py @@ -17,13 +17,12 @@ music player. """ -import six import sys import time -from six.moves import _thread +import _thread import os import copy -from six.moves import urllib +import urllib from beets import ui import gi diff --git a/beetsplug/bucket.py b/beetsplug/bucket.py index 0837ca8da..9ed50b45c 100644 --- a/beetsplug/bucket.py +++ b/beetsplug/bucket.py @@ -126,9 +126,9 @@ def str2fmt(s): res = {'fromnchars': len(m.group('fromyear')), 'tonchars': len(m.group('toyear'))} res['fmt'] = "{}%s{}{}{}".format(m.group('bef'), - m.group('sep'), - '%s' if res['tonchars'] else '', - m.group('after')) + m.group('sep'), + '%s' if res['tonchars'] else '', + m.group('after')) return res diff --git a/beetsplug/convert.py b/beetsplug/convert.py index 5f07a2e7c..6bc07c287 100644 --- a/beetsplug/convert.py +++ b/beetsplug/convert.py @@ -119,7 +119,7 @@ class ConvertPlugin(BeetsPlugin): 'formats': { 'aac': { 'command': 'ffmpeg -i $source -y -vn -acodec aac ' - '-aq 1 $dest', + '-aq 1 $dest', 'extension': 'm4a', }, 'alac': { diff --git a/beetsplug/deezer.py b/beetsplug/deezer.py index 201ab6992..5f158f936 100644 --- a/beetsplug/deezer.py +++ b/beetsplug/deezer.py @@ -17,7 +17,6 @@ import collections -import six import unidecode import requests diff --git a/beetsplug/discogs.py b/beetsplug/discogs.py index e7c416909..76036f1be 100644 --- a/beetsplug/discogs.py +++ b/beetsplug/discogs.py @@ -24,7 +24,7 @@ import confuse from discogs_client import Release, Master, Client from discogs_client.exceptions import DiscogsAPIError from requests.exceptions import ConnectionError -from six.moves import http_client +import http.client import beets import re import time @@ -40,7 +40,7 @@ API_KEY = 'rAzVUQYRaoFjeBjyWuWZ' API_SECRET = 'plxtUTqoCzwxZpqdPysCwGuBSmZNdZVy' # Exceptions that discogs_client should really handle but does not. -CONNECTION_ERRORS = (ConnectionError, socket.error, http_client.HTTPException, +CONNECTION_ERRORS = (ConnectionError, socket.error, http.client.HTTPException, ValueError, # JSON decoding raises a ValueError. DiscogsAPIError) @@ -505,7 +505,7 @@ class DiscogsPlugin(BeetsPlugin): if self.config['index_tracks']: for subtrack in subtracks: subtrack['title'] = '{}: {}'.format( - index_track['title'], subtrack['title']) + index_track['title'], subtrack['title']) tracklist.extend(subtracks) else: # Merge the subtracks, pick a title, and append the new track. diff --git a/beetsplug/duplicates.py b/beetsplug/duplicates.py index db1e1ee9e..fdd5c1750 100644 --- a/beetsplug/duplicates.py +++ b/beetsplug/duplicates.py @@ -16,7 +16,6 @@ """ import shlex -import six from beets.plugins import BeetsPlugin from beets.ui import decargs, print_, Subcommand, UserError diff --git a/beetsplug/edit.py b/beetsplug/edit.py index 8372563b8..6f03fa4d8 100644 --- a/beetsplug/edit.py +++ b/beetsplug/edit.py @@ -26,7 +26,6 @@ import subprocess import yaml from tempfile import NamedTemporaryFile import os -import six import shlex diff --git a/beetsplug/embyupdate.py b/beetsplug/embyupdate.py index 0f77f17ce..c17fabad2 100644 --- a/beetsplug/embyupdate.py +++ b/beetsplug/embyupdate.py @@ -11,9 +11,7 @@ import hashlib import requests -from six.moves.urllib.parse import urlencode -from six.moves.urllib.parse import urljoin, parse_qs, urlsplit, urlunsplit - +from urllib.parse import urlencode, urljoin, parse_qs, urlsplit, urlunsplit from beets import config from beets.plugins import BeetsPlugin diff --git a/beetsplug/fetchart.py b/beetsplug/fetchart.py index dfc7eb683..2076d5986 100644 --- a/beetsplug/fetchart.py +++ b/beetsplug/fetchart.py @@ -33,7 +33,6 @@ from beets.util.artresizer import ArtResizer from beets.util import sorted_walk from beets.util import syspath, bytestring_path, py3_path import confuse -import six CONTENT_TYPES = { 'image/jpeg': [b'jpg', b'jpeg'], diff --git a/beetsplug/fromfilename.py b/beetsplug/fromfilename.py index de9f2b4ee..55684a274 100644 --- a/beetsplug/fromfilename.py +++ b/beetsplug/fromfilename.py @@ -20,7 +20,6 @@ from beets import plugins from beets.util import displayable_path import os import re -import six # Filename field extraction patterns. diff --git a/beetsplug/hook.py b/beetsplug/hook.py index f11898797..0fe3bffc6 100644 --- a/beetsplug/hook.py +++ b/beetsplug/hook.py @@ -48,7 +48,7 @@ class CodingFormatter(string.Formatter): format_string = format_string.decode(self._coding) return super().format(format_string, *args, - **kwargs) + **kwargs) def convert_field(self, value, conversion): """Converts the provided value given a conversion type. @@ -58,7 +58,7 @@ class CodingFormatter(string.Formatter): See string.Formatter.convert_field. """ converted = super().convert_field(value, - conversion) + conversion) if isinstance(converted, bytes): return converted.decode(self._coding) @@ -68,6 +68,7 @@ class CodingFormatter(string.Formatter): class HookPlugin(BeetsPlugin): """Allows custom commands to be run when an event is emitted by beets""" + def __init__(self): super().__init__() diff --git a/beetsplug/importadded.py b/beetsplug/importadded.py index 39838b5a2..e6665e0ff 100644 --- a/beetsplug/importadded.py +++ b/beetsplug/importadded.py @@ -60,8 +60,8 @@ class ImportAddedPlugin(BeetsPlugin): def record_reimported(self, task, session): self.reimported_item_ids = {item.id for item, replaced_items - in task.replaced_items.items() - if replaced_items} + in task.replaced_items.items() + if replaced_items} self.replaced_album_paths = set(task.replaced_albums.keys()) def write_file_mtime(self, path, mtime): diff --git a/beetsplug/inline.py b/beetsplug/inline.py index b3a779108..e19eaa9d7 100644 --- a/beetsplug/inline.py +++ b/beetsplug/inline.py @@ -20,7 +20,6 @@ import itertools from beets.plugins import BeetsPlugin from beets import config -import six FUNC_NAME = '__INLINE_FUNC__' diff --git a/beetsplug/kodiupdate.py b/beetsplug/kodiupdate.py index b24cd9463..2a885d2c2 100644 --- a/beetsplug/kodiupdate.py +++ b/beetsplug/kodiupdate.py @@ -26,7 +26,6 @@ Put something like the following in your config.yaml to configure: import requests from beets import config from beets.plugins import BeetsPlugin -import six def update_kodi(host, port, user, password): diff --git a/beetsplug/lastgenre/__init__.py b/beetsplug/lastgenre/__init__.py index 3a1e969cf..05412308d 100644 --- a/beetsplug/lastgenre/__init__.py +++ b/beetsplug/lastgenre/__init__.py @@ -13,8 +13,6 @@ # included in all copies or substantial portions of the Software. -import six - """Gets genres for imported music based on Last.fm tags. Uses a provided whitelist file to determine which tags are valid genres. @@ -266,7 +264,7 @@ class LastGenrePlugin(plugins.BeetsPlugin): return None key = '{}.{}'.format(entity, - '-'.join(str(a) for a in args)) + '-'.join(str(a) for a in args)) if key in self._genre_cache: return self._genre_cache[key] else: diff --git a/beetsplug/lyrics.py b/beetsplug/lyrics.py index 9c3155e93..8a9896bc3 100644 --- a/beetsplug/lyrics.py +++ b/beetsplug/lyrics.py @@ -27,8 +27,7 @@ import requests import unicodedata from unidecode import unidecode import warnings -import six -from six.moves import urllib +import urllib try: import bs4 @@ -47,7 +46,7 @@ try: # PY3: HTMLParseError was removed in 3.5 as strict mode # was deprecated in 3.3. # https://docs.python.org/3.3/library/html.parser.html - from six.moves.html_parser import HTMLParseError + from html.parser import HTMLParseError except ImportError: class HTMLParseError(Exception): pass @@ -864,8 +863,8 @@ class LyricsPlugin(plugins.BeetsPlugin): title_str = ":index:`%s`" % item.title.strip() block = '| ' + item.lyrics.replace('\n', '\n| ') self.rest += "{}\n{}\n\n{}\n\n".format(title_str, - '~' * len(title_str), - block) + '~' * len(title_str), + block) def writerest(self, directory): """Write self.rest to a ReST file diff --git a/beetsplug/mbsubmit.py b/beetsplug/mbsubmit.py index 6d21d9b59..3ede0125b 100644 --- a/beetsplug/mbsubmit.py +++ b/beetsplug/mbsubmit.py @@ -22,7 +22,6 @@ implemented by MusicBrainz yet. """ - from beets.autotag import Recommendation from beets.plugins import BeetsPlugin from beets.ui.commands import PromptChoice diff --git a/beetsplug/metasync/__init__.py b/beetsplug/metasync/__init__.py index c2f1d50d7..361071fb5 100644 --- a/beetsplug/metasync/__init__.py +++ b/beetsplug/metasync/__init__.py @@ -22,7 +22,6 @@ from importlib import import_module from confuse import ConfigValueError from beets import ui from beets.plugins import BeetsPlugin -import six METASYNC_MODULE = 'beetsplug.metasync' diff --git a/beetsplug/metasync/itunes.py b/beetsplug/metasync/itunes.py index 7ed940736..e50a57138 100644 --- a/beetsplug/metasync/itunes.py +++ b/beetsplug/metasync/itunes.py @@ -22,7 +22,7 @@ import shutil import tempfile import plistlib -from six.moves.urllib.parse import urlparse, unquote +from urllib.parse import urlparse, unquote from time import mktime from beets import util @@ -61,12 +61,12 @@ def _norm_itunes_path(path): class Itunes(MetaSource): item_types = { - 'itunes_rating': types.INTEGER, # 0..100 scale - 'itunes_playcount': types.INTEGER, - 'itunes_skipcount': types.INTEGER, - 'itunes_lastplayed': DateType(), + 'itunes_rating': types.INTEGER, # 0..100 scale + 'itunes_playcount': types.INTEGER, + 'itunes_skipcount': types.INTEGER, + 'itunes_lastplayed': DateType(), 'itunes_lastskipped': DateType(), - 'itunes_dateadded': DateType(), + 'itunes_dateadded': DateType(), } def __init__(self, config, log): diff --git a/beetsplug/mpdstats.py b/beetsplug/mpdstats.py index 243562409..dd91228e5 100644 --- a/beetsplug/mpdstats.py +++ b/beetsplug/mpdstats.py @@ -14,9 +14,6 @@ import mpd -import socket -import select -import sys import time import os @@ -300,10 +297,10 @@ class MPDStats: self._log.info('playing {0}', displayable_path(path)) self.now_playing = { - 'started': time.time(), - 'remaining': remaining, - 'path': path, - 'id': songid, + 'started': time.time(), + 'remaining': remaining, + 'path': path, + 'id': songid, 'beets_item': self.get_item(path), } @@ -331,22 +328,22 @@ class MPDStats: class MPDStatsPlugin(plugins.BeetsPlugin): item_types = { - 'play_count': types.INTEGER, - 'skip_count': types.INTEGER, + 'play_count': types.INTEGER, + 'skip_count': types.INTEGER, 'last_played': library.DateType(), - 'rating': types.FLOAT, + 'rating': types.FLOAT, } def __init__(self): super().__init__() mpd_config.add({ 'music_directory': config['directory'].as_filename(), - 'strip_path': '', - 'rating': True, - 'rating_mix': 0.75, - 'host': os.environ.get('MPD_HOST', 'localhost'), - 'port': int(os.environ.get('MPD_PORT', 6600)), - 'password': '', + 'strip_path': '', + 'rating': True, + 'rating_mix': 0.75, + 'host': os.environ.get('MPD_HOST', 'localhost'), + 'port': int(os.environ.get('MPD_PORT', 6600)), + 'password': '', }) mpd_config['password'].redact = True diff --git a/beetsplug/mpdupdate.py b/beetsplug/mpdupdate.py index 141f85b08..e5264e182 100644 --- a/beetsplug/mpdupdate.py +++ b/beetsplug/mpdupdate.py @@ -25,7 +25,6 @@ from beets.plugins import BeetsPlugin import os import socket from beets import config -import six # No need to introduce a dependency on an MPD library for such a diff --git a/beetsplug/permissions.py b/beetsplug/permissions.py index 18b554ccc..cd4577e4f 100644 --- a/beetsplug/permissions.py +++ b/beetsplug/permissions.py @@ -9,7 +9,6 @@ import os from beets import config, util from beets.plugins import BeetsPlugin from beets.util import ancestry -import six def convert_perm(perm): diff --git a/beetsplug/plexupdate.py b/beetsplug/plexupdate.py index 42620c0cd..2261a55f4 100644 --- a/beetsplug/plexupdate.py +++ b/beetsplug/plexupdate.py @@ -10,7 +10,7 @@ Put something like the following in your config.yaml to configure: import requests from xml.etree import ElementTree -from six.moves.urllib.parse import urljoin, urlencode +from urllib.parse import urljoin, urlencode from beets import config from beets.plugins import BeetsPlugin diff --git a/beetsplug/replaygain.py b/beetsplug/replaygain.py index 6592da2c6..b6297d937 100644 --- a/beetsplug/replaygain.py +++ b/beetsplug/replaygain.py @@ -18,7 +18,6 @@ import enum import math import os import signal -import six import subprocess import sys import warnings diff --git a/beetsplug/smartplaylist.py b/beetsplug/smartplaylist.py index d2043f0c9..4c921eccc 100644 --- a/beetsplug/smartplaylist.py +++ b/beetsplug/smartplaylist.py @@ -24,7 +24,6 @@ from beets.library import Item, Album, parse_query_string from beets.dbcore import OrQuery from beets.dbcore.query import MultipleSort, ParsingError import os -import six try: from urllib.request import pathname2url @@ -72,8 +71,8 @@ class SmartPlaylistPlugin(BeetsPlugin): args.add(f"{a}.m3u") playlists = {(name, q, a_q) - for name, q, a_q in self._unmatched_playlists - if name in args} + for name, q, a_q in self._unmatched_playlists + if name in args} if not playlists: raise ui.UserError( 'No playlist matching any of {} found'.format( diff --git a/beetsplug/spotify.py b/beetsplug/spotify.py index 69d4f1c0d..2529160dd 100644 --- a/beetsplug/spotify.py +++ b/beetsplug/spotify.py @@ -22,7 +22,6 @@ import base64 import webbrowser import collections -import six import unidecode import requests import confuse diff --git a/beetsplug/subsonicplaylist.py b/beetsplug/subsonicplaylist.py index 42b486f44..ead78919e 100644 --- a/beetsplug/subsonicplaylist.py +++ b/beetsplug/subsonicplaylist.py @@ -43,8 +43,8 @@ def filter_to_be_removed(items, keys): def to_be_removed(item): for artist, album, title in keys: if artist == item['artist'] and\ - album == item['album'] and\ - title == item['title']: + album == item['album'] and\ + title == item['title']: return False return True diff --git a/beetsplug/thumbnails.py b/beetsplug/thumbnails.py index c4ad024dc..6bd9cbac6 100644 --- a/beetsplug/thumbnails.py +++ b/beetsplug/thumbnails.py @@ -33,7 +33,6 @@ from beets.plugins import BeetsPlugin from beets.ui import Subcommand, decargs from beets import util from beets.util.artresizer import ArtResizer, get_im_version, get_pil_version -import six BASE_DIR = os.path.join(BaseDirectory.xdg_cache_home, "thumbnails") diff --git a/beetsplug/unimported.py b/beetsplug/unimported.py index 7c92def91..6c8cb6897 100644 --- a/beetsplug/unimported.py +++ b/beetsplug/unimported.py @@ -42,7 +42,7 @@ class Unimported(BeetsPlugin): in self.config['ignore_extensions'].as_str_seq()] in_folder = { os.path.join(r, file) for r, d, f in os.walk(lib.directory) - for file in f if not any( + for file in f if not any( [file.endswith(extension) for extension in ignore_exts])} in_library = {x.path for x in lib.items()} diff --git a/beetsplug/zero.py b/beetsplug/zero.py index 8d90e952a..f05b1b5a5 100644 --- a/beetsplug/zero.py +++ b/beetsplug/zero.py @@ -14,7 +14,6 @@ """ Clears tag fields in media files.""" -import six import re diff --git a/setup.py b/setup.py index 1f10b345f..8fc2d7f8b 100755 --- a/setup.py +++ b/setup.py @@ -85,7 +85,6 @@ setup( }, install_requires=[ - 'six>=1.9', 'unidecode', 'musicbrainzngs>=0.4', 'pyyaml', diff --git a/test/__init__.py b/test/__init__.py index f34357b7c..52514cb73 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -1,2 +1 @@ # Make python -m testall.py work. - diff --git a/test/helper.py b/test/helper.py index fcd997648..ba71ddc24 100644 --- a/test/helper.py +++ b/test/helper.py @@ -30,7 +30,6 @@ information or mock the environment. """ - import sys import os import os.path @@ -54,7 +53,6 @@ from beets.util import MoveOperation # TODO Move AutotagMock here from test import _common -import six class LogCapture(logging.Handler): @@ -578,6 +576,7 @@ def generate_album_info(album_id, track_values): return album + ALBUM_INFO_FIELDS = ['album', 'album_id', 'artist', 'artist_id', 'asin', 'albumtype', 'va', 'label', 'artist_sort', 'releasegroup_id', 'catalognum', @@ -602,6 +601,7 @@ def generate_track_info(track_id='track info', values={}): setattr(track, field, value) return track + TRACK_INFO_FIELDS = ['artist', 'artist_id', 'artist_sort', 'disctitle', 'artist_credit', 'data_source', 'data_url'] diff --git a/test/test_art_resize.py b/test/test_art_resize.py index fc5af07f4..fd9cc094e 100644 --- a/test/test_art_resize.py +++ b/test/test_art_resize.py @@ -15,7 +15,6 @@ """Tests for image resizing based on filesize.""" - import unittest import os diff --git a/test/test_beatport.py b/test/test_beatport.py index 53330fc26..6e75e5874 100644 --- a/test/test_beatport.py +++ b/test/test_beatport.py @@ -18,7 +18,6 @@ import unittest from test import _common from test.helper import TestHelper -import six from datetime import timedelta from beetsplug import beatport diff --git a/test/test_config_command.py b/test/test_config_command.py index 973f43b61..14e9df32b 100644 --- a/test/test_config_command.py +++ b/test/test_config_command.py @@ -10,7 +10,6 @@ from beets import config from test.helper import TestHelper from beets.library import Library -import six class ConfigCommandTest(unittest.TestCase, TestHelper): diff --git a/test/test_convert.py b/test/test_convert.py index ba7015179..3a248f3f3 100644 --- a/test/test_convert.py +++ b/test/test_convert.py @@ -49,7 +49,7 @@ class TestHelper(helper.TestHelper): # A Python script that copies the file and appends a tag. stub = os.path.join(_common.RSRC, b'convert_stub.py').decode('utf-8') return "{} {} $source $dest {}".format(shell_quote(sys.executable), - shell_quote(stub), tag) + shell_quote(stub), tag) def assertFileTag(self, path, tag): # noqa """Assert that the path is a file and the files content ends with `tag`. @@ -135,6 +135,7 @@ class ConvertCommand: """A mixin providing a utility method to run the `convert`command in tests. """ + def run_convert_path(self, path, *args): """Run the `convert` command on a given path.""" # The path is currently a filesystem bytestring. Convert it to diff --git a/test/test_dbcore.py b/test/test_dbcore.py index 0485756fa..603d85bad 100644 --- a/test/test_dbcore.py +++ b/test/test_dbcore.py @@ -19,12 +19,10 @@ import os import shutil import sqlite3 import unittest -from six import assertRaisesRegex from test import _common from beets import dbcore from tempfile import mkstemp -import six # Fixture: concrete database and model classes. For migration tests, we diff --git a/test/test_importadded.py b/test/test_importadded.py index 263ab34d0..bb160d190 100644 --- a/test/test_importadded.py +++ b/test/test_importadded.py @@ -112,7 +112,7 @@ class ImportAddedTest(unittest.TestCase, ImportHelper): album = self.lib.albums().get() album_added_before = album.added items_added_before = {item.path: item.added - for item in album.items()} + for item in album.items()} # Newer Item path mtimes as if Beets had modified them modify_mtimes(items_added_before.keys(), offset=10000) # Reimport @@ -122,7 +122,7 @@ class ImportAddedTest(unittest.TestCase, ImportHelper): album = self.lib.albums().get() self.assertEqualTimes(album.added, album_added_before) items_added_after = {item.path: item.added - for item in album.items()} + for item in album.items()} for item_path, added_after in items_added_after.items(): self.assertEqualTimes(items_added_before[item_path], added_after, "reimport modified Item.added for " + @@ -151,7 +151,7 @@ class ImportAddedTest(unittest.TestCase, ImportHelper): # Import and record the original added dates self.importer.run() items_added_before = {item.path: item.added - for item in self.lib.items()} + for item in self.lib.items()} # Newer Item path mtimes as if Beets had modified them modify_mtimes(items_added_before.keys(), offset=10000) # Reimport @@ -160,7 +160,7 @@ class ImportAddedTest(unittest.TestCase, ImportHelper): self.importer.run() # Verify the reimported items items_added_after = {item.path: item.added - for item in self.lib.items()} + for item in self.lib.items()} for item_path, added_after in items_added_after.items(): self.assertEqualTimes(items_added_before[item_path], added_after, "reimport modified Item.added for " + @@ -170,5 +170,6 @@ class ImportAddedTest(unittest.TestCase, ImportHelper): def suite(): return unittest.TestLoader().loadTestsFromName(__name__) + if __name__ == '__main__': unittest.main(defaultTest='suite') diff --git a/test/test_ipfs.py b/test/test_ipfs.py index c0b0b6854..8f72f5132 100644 --- a/test/test_ipfs.py +++ b/test/test_ipfs.py @@ -52,7 +52,7 @@ class IPFSPluginTest(unittest.TestCase, TestHelper): _fsencoding(), ) want_path = '/ipfs/{}/{}'.format(test_album.ipfs, - ipfs_item) + ipfs_item) want_path = bytestring_path(want_path) self.assertEqual(check_item.path, want_path) self.assertEqual(check_item.get('ipfs', with_album=False), @@ -95,5 +95,6 @@ class IPFSPluginTest(unittest.TestCase, TestHelper): def suite(): return unittest.TestLoader().loadTestsFromName(__name__) + if __name__ == '__main__': unittest.main(defaultTest='suite') diff --git a/test/test_lastgenre.py b/test/test_lastgenre.py index 07b12a73e..a7a939caa 100644 --- a/test/test_lastgenre.py +++ b/test/test_lastgenre.py @@ -23,7 +23,6 @@ from beetsplug import lastgenre from beets import config from test.helper import TestHelper -import six class LastGenrePluginTest(unittest.TestCase, TestHelper): diff --git a/test/test_library.py b/test/test_library.py index 6ce913602..8b04e50d0 100644 --- a/test/test_library.py +++ b/test/test_library.py @@ -35,7 +35,6 @@ from beets import config from mediafile import MediaFile, UnreadableFileError from beets.util import syspath, bytestring_path from test.helper import TestHelper -import six # Shortcut to path normalization. np = util.normpath diff --git a/test/test_logging.py b/test/test_logging.py index a5f4ffc84..76a73e931 100644 --- a/test/test_logging.py +++ b/test/test_logging.py @@ -12,7 +12,6 @@ import beetsplug from test import _common from test._common import TestCase from test import helper -import six class LoggingTest(TestCase): diff --git a/test/test_lyrics.py b/test/test_lyrics.py index 0f09af82e..cc4a907f1 100644 --- a/test/test_lyrics.py +++ b/test/test_lyrics.py @@ -18,7 +18,6 @@ import itertools import os import re -import six import sys import unittest diff --git a/test/test_playlist.py b/test/test_playlist.py index 3b5ac2660..74783fde8 100644 --- a/test/test_playlist.py +++ b/test/test_playlist.py @@ -12,13 +12,13 @@ # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. -from six.moves import shlex_quote import os import shutil import tempfile import unittest +from shlex import quote from test import _common from test import helper @@ -88,7 +88,7 @@ class PlaylistQueryTestHelper(PlaylistTestHelper): }) def test_path_query_with_absolute_paths_in_playlist(self): - q = 'playlist:{}'.format(shlex_quote(os.path.join( + q = 'playlist:{}'.format(quote(os.path.join( self.playlist_dir, 'absolute.m3u', ))) @@ -107,7 +107,7 @@ class PlaylistQueryTestHelper(PlaylistTestHelper): }) def test_path_query_with_relative_paths_in_playlist(self): - q = 'playlist:{}'.format(shlex_quote(os.path.join( + q = 'playlist:{}'.format(quote(os.path.join( self.playlist_dir, 'relative.m3u', ))) @@ -123,7 +123,7 @@ class PlaylistQueryTestHelper(PlaylistTestHelper): self.assertEqual(set(results), set()) def test_path_query_with_nonexisting_playlist(self): - q = 'playlist:{}'.format(shlex_quote(os.path.join( + q = 'playlist:{}'.format(quote(os.path.join( self.playlist_dir, self.playlist_dir, 'nonexisting.m3u', @@ -218,7 +218,7 @@ class PlaylistUpdateTestHelper(PlaylistTestHelper): class PlaylistTestItemMoved(PlaylistUpdateTestHelper, unittest.TestCase): def test_item_moved(self): # Emit item_moved event for an item that is in a playlist - results = self.lib.items('path:{}'.format(shlex_quote( + results = self.lib.items('path:{}'.format(quote( os.path.join(self.music_dir, 'd', 'e', 'f.mp3')))) item = results[0] beets.plugins.send( @@ -227,7 +227,7 @@ class PlaylistTestItemMoved(PlaylistUpdateTestHelper, unittest.TestCase): os.path.join(self.music_dir, 'g', 'h', 'i.mp3'))) # Emit item_moved event for an item that is not in a playlist - results = self.lib.items('path:{}'.format(shlex_quote( + results = self.lib.items('path:{}'.format(quote( os.path.join(self.music_dir, 'x', 'y', 'z.mp3')))) item = results[0] beets.plugins.send( @@ -264,13 +264,13 @@ class PlaylistTestItemMoved(PlaylistUpdateTestHelper, unittest.TestCase): class PlaylistTestItemRemoved(PlaylistUpdateTestHelper, unittest.TestCase): def test_item_removed(self): # Emit item_removed event for an item that is in a playlist - results = self.lib.items('path:{}'.format(shlex_quote( + results = self.lib.items('path:{}'.format(quote( os.path.join(self.music_dir, 'd', 'e', 'f.mp3')))) item = results[0] beets.plugins.send('item_removed', item=item) # Emit item_removed event for an item that is not in a playlist - results = self.lib.items('path:{}'.format(shlex_quote( + results = self.lib.items('path:{}'.format(quote( os.path.join(self.music_dir, 'x', 'y', 'z.mp3')))) item = results[0] beets.plugins.send('item_removed', item=item) @@ -302,5 +302,6 @@ class PlaylistTestItemRemoved(PlaylistUpdateTestHelper, unittest.TestCase): def suite(): return unittest.TestLoader().loadTestsFromName(__name__) + if __name__ == '__main__': unittest.main(defaultTest='suite') diff --git a/test/test_plugin_mediafield.py b/test/test_plugin_mediafield.py index e5d336b9a..6179ce646 100644 --- a/test/test_plugin_mediafield.py +++ b/test/test_plugin_mediafield.py @@ -16,7 +16,6 @@ """ import os -import six import shutil import unittest diff --git a/test/test_query.py b/test/test_query.py index 68fd40cc1..e8161c41c 100644 --- a/test/test_query.py +++ b/test/test_query.py @@ -32,7 +32,6 @@ from beets.dbcore.query import (NoneQuery, ParsingError, from beets.library import Library, Item from beets import util import platform -import six class TestHelper(helper.TestHelper): diff --git a/test/test_replaygain.py b/test/test_replaygain.py index a2fdf5dbd..b39a4e990 100644 --- a/test/test_replaygain.py +++ b/test/test_replaygain.py @@ -13,8 +13,6 @@ # included in all copies or substantial portions of the Software. - -import six import unittest from mediafile import MediaFile @@ -214,5 +212,6 @@ class ReplayGainFfmpegTest(ReplayGainCliTestBase, unittest.TestCase): def suite(): return unittest.TestLoader().loadTestsFromName(__name__) + if __name__ == '__main__': unittest.main(defaultTest='suite') diff --git a/test/test_smartplaylist.py b/test/test_smartplaylist.py index b1fc11108..0c0add4ab 100644 --- a/test/test_smartplaylist.py +++ b/test/test_smartplaylist.py @@ -83,7 +83,7 @@ class SmartPlaylistTest(unittest.TestCase): spl.build_queries() sorts = {name: sort - for name, (_, sort), _ in spl._unmatched_playlists} + for name, (_, sort), _ in spl._unmatched_playlists} asseq = self.assertEqual # less cluttered code sort = FixedFieldSort # short cut since we're only dealing with this diff --git a/test/test_subsonicupdate.py b/test/test_subsonicupdate.py index 70a37d09d..a516e3487 100644 --- a/test/test_subsonicupdate.py +++ b/test/test_subsonicupdate.py @@ -8,11 +8,12 @@ from test import _common from beets import config from beetsplug import subsonicupdate from test.helper import TestHelper -from six.moves.urllib.parse import parse_qs, urlparse +from urllib.parse import parse_qs, urlparse class ArgumentsMock: """Argument mocks for tests.""" + def __init__(self, mode, show_failures): """Constructs ArgumentsMock.""" self.mode = mode diff --git a/test/test_template.py b/test/test_template.py index efc6da1d8..adc9b60d1 100644 --- a/test/test_template.py +++ b/test/test_template.py @@ -16,7 +16,6 @@ """ import unittest -import six from beets.util import functemplate diff --git a/test/test_ui_importer.py b/test/test_ui_importer.py index 43b833669..88daa0ce1 100644 --- a/test/test_ui_importer.py +++ b/test/test_ui_importer.py @@ -25,7 +25,6 @@ from test import test_importer from beets.ui.commands import TerminalImportSession from beets import importer from beets import config -import six class TerminalImportSessionFixture(TerminalImportSession): diff --git a/test/test_util.py b/test/test_util.py index 230d28bd6..32614ab72 100644 --- a/test/test_util.py +++ b/test/test_util.py @@ -24,7 +24,6 @@ from unittest.mock import patch, Mock from test import _common from beets import util -import six class UtilTest(unittest.TestCase): diff --git a/test/test_web.py b/test/test_web.py index c9e8ce678..9a18b1dba 100644 --- a/test/test_web.py +++ b/test/test_web.py @@ -4,7 +4,6 @@ import json import unittest import os.path -from six import assertCountEqual import shutil from test import _common @@ -672,5 +671,6 @@ class WebPluginTest(_common.LibTestCase): def suite(): return unittest.TestLoader().loadTestsFromName(__name__) + if __name__ == '__main__': unittest.main(defaultTest='suite')