From 2c0f8910c39b27ca0d2d263386b79ea28d0273ce Mon Sep 17 00:00:00 2001 From: Thomas Scholtes Date: Wed, 13 Dec 2023 16:29:55 +0100 Subject: [PATCH] Remove six Signed-off-by: Thomas Scholtes --- beetsplug/alternatives.py | 5 ++--- poetry.lock | 2 +- pyproject.toml | 1 - test/helper.py | 26 +++----------------------- 4 files changed, 6 insertions(+), 28 deletions(-) diff --git a/beetsplug/alternatives.py b/beetsplug/alternatives.py index 16c1c14..3c344fc 100644 --- a/beetsplug/alternatives.py +++ b/beetsplug/alternatives.py @@ -21,7 +21,6 @@ from typing import Iterator, List, Optional, Tuple import beets -import six from beets import art, util from beets.library import Item, parse_query_string from beets.plugins import BeetsPlugin @@ -297,8 +296,8 @@ def destination(self, item: Item) -> bytes: assert isinstance(path, bytes) return path - def set_path(self, item, path): - item[self.path_key] = six.text_type(path, "utf8") + def set_path(self, item, path: bytes): + item[self.path_key] = str(path, "utf8") @staticmethod def _get_path(item, path_key) -> Optional[bytes]: diff --git a/poetry.lock b/poetry.lock index 1d900f8..c7515a5 100644 --- a/poetry.lock +++ b/poetry.lock @@ -733,4 +733,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.8.1" -content-hash = "ac8aca3ccf08912fdd1642ada7f7265bf397856a09baca3cce10017b4d144c10" +content-hash = "0b23f18a75ee3e3f8bc21cfc08047c92cbad8a6d5107cd77c7ed1f23685adb67" diff --git a/pyproject.toml b/pyproject.toml index e633395..211922b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,6 @@ classifiers = [ [tool.poetry.dependencies] python = "^3.8.1" beets = "^1.6.0" -six = "^1.16.0" [tool.poetry.group.dev.dependencies] pytest = "^7.3.1" diff --git a/test/helper.py b/test/helper.py index 6fe4ff8..76fe74c 100644 --- a/test/helper.py +++ b/test/helper.py @@ -4,19 +4,18 @@ import tempfile from concurrent import futures from contextlib import contextmanager +from io import StringIO from typing import Optional from unittest import TestCase from zlib import crc32 import beets import beets.library -import six from beets import logging, plugins, ui, util from beets.library import Item from beets.util import MoveOperation, bytestring_path, displayable_path, syspath from mediafile import MediaFile from mock import patch -from six import StringIO import beetsplug.alternatives as alternatives import beetsplug.convert as convert @@ -30,7 +29,7 @@ def __init__(self): self.messages = [] def emit(self, record): - self.messages.append(six.text_type(record.msg)) + self.messages.append(str(record.msg)) @contextmanager @@ -56,8 +55,6 @@ def capture_stdout(): """ org = sys.stdout sys.stdout = capture = StringIO() - if six.PY2: # StringIO encoding attr isn't writable in python >= 3 - sys.stdout.encoding = "utf-8" try: yield sys.stdout finally: @@ -75,29 +72,12 @@ def control_stdin(input=None): """ org = sys.stdin sys.stdin = StringIO(input) - if six.PY2: # StringIO encoding attr isn't writable in python >= 3 - sys.stdin.encoding = "utf-8" try: yield sys.stdin finally: sys.stdin = org -def _convert_args(args): - """Convert args to bytestrings for Python 2 and convert them to strings - on Python 3. - """ - for i, elem in enumerate(args): - if six.PY2: - if isinstance(elem, six.text_type): - args[i] = elem.encode(util.arg_encoding()) - else: - if isinstance(elem, bytes): - args[i] = elem.decode(util.arg_encoding()) - - return args - - class Assertions(TestCase): def assertFileTag(self, path, tag): self.assertIsFile(path) @@ -278,7 +258,7 @@ def runcli(self, *args): # TODO mock stdin with capture_stdout() as out: try: - ui._raw_main(_convert_args(list(args)), self.lib) + ui._raw_main(list(args), self.lib) except ui.UserError as u: # TODO remove this and handle exceptions in tests print(u.args[0])