Remove unused imports

Fix imports
Fix formatting
This commit is contained in:
Andrew Rogl 2021-08-26 20:59:48 +10:00
parent 0f48ccde78
commit ee4268dabb
63 changed files with 84 additions and 125 deletions

View file

@ -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'

View file

@ -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)

View file

@ -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

View file

@ -32,7 +32,7 @@ in place of any single coroutine.
"""
from six.moves import queue
import queue
from threading import Thread, Lock
import sys

View file

@ -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

View file

@ -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)

View file

@ -17,7 +17,6 @@
import json
import re
import six
from datetime import datetime, timedelta
from requests_oauthlib import OAuth1Session

View file

@ -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

View file

@ -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

View file

@ -17,7 +17,6 @@
import collections
import six
import unidecode
import requests

View file

@ -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)

View file

@ -16,7 +16,6 @@
"""
import shlex
import six
from beets.plugins import BeetsPlugin
from beets.ui import decargs, print_, Subcommand, UserError

View file

@ -26,7 +26,6 @@ import subprocess
import yaml
from tempfile import NamedTemporaryFile
import os
import six
import shlex

View file

@ -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

View file

@ -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'],

View file

@ -20,7 +20,6 @@ from beets import plugins
from beets.util import displayable_path
import os
import re
import six
# Filename field extraction patterns.

View file

@ -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__()

View file

@ -20,7 +20,6 @@ import itertools
from beets.plugins import BeetsPlugin
from beets import config
import six
FUNC_NAME = '__INLINE_FUNC__'

View file

@ -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):

View file

@ -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.

View file

@ -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

View file

@ -22,7 +22,6 @@ implemented by MusicBrainz yet.
"""
from beets.autotag import Recommendation
from beets.plugins import BeetsPlugin
from beets.ui.commands import PromptChoice

View file

@ -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'

View file

@ -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

View file

@ -14,9 +14,6 @@
import mpd
import socket
import select
import sys
import time
import os

View file

@ -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

View file

@ -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):

View file

@ -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

View file

@ -18,7 +18,6 @@ import enum
import math
import os
import signal
import six
import subprocess
import sys
import warnings

View file

@ -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

View file

@ -22,7 +22,6 @@ import base64
import webbrowser
import collections
import six
import unidecode
import requests
import confuse

View file

@ -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")

View file

@ -14,7 +14,6 @@
""" Clears tag fields in media files."""
import six
import re

View file

@ -85,7 +85,6 @@ setup(
},
install_requires=[
'six>=1.9',
'unidecode',
'musicbrainzngs>=0.4',
'pyyaml',

View file

@ -1,2 +1 @@
# Make python -m testall.py work.

View file

@ -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']

View file

@ -15,7 +15,6 @@
"""Tests for image resizing based on filesize."""
import unittest
import os

View file

@ -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

View file

@ -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):

View file

@ -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

View file

@ -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

View file

@ -170,5 +170,6 @@ class ImportAddedTest(unittest.TestCase, ImportHelper):
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == '__main__':
unittest.main(defaultTest='suite')

View file

@ -95,5 +95,6 @@ class IPFSPluginTest(unittest.TestCase, TestHelper):
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == '__main__':
unittest.main(defaultTest='suite')

View file

@ -23,7 +23,6 @@ from beetsplug import lastgenre
from beets import config
from test.helper import TestHelper
import six
class LastGenrePluginTest(unittest.TestCase, TestHelper):

View file

@ -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

View file

@ -12,7 +12,6 @@ import beetsplug
from test import _common
from test._common import TestCase
from test import helper
import six
class LoggingTest(TestCase):

View file

@ -18,7 +18,6 @@
import itertools
import os
import re
import six
import sys
import unittest

View file

@ -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')

View file

@ -16,7 +16,6 @@
"""
import os
import six
import shutil
import unittest

View file

@ -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):

View file

@ -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')

View file

@ -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

View file

@ -16,7 +16,6 @@
"""
import unittest
import six
from beets.util import functemplate

View file

@ -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):

View file

@ -24,7 +24,6 @@ from unittest.mock import patch, Mock
from test import _common
from beets import util
import six
class UtilTest(unittest.TestCase):

View file

@ -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')