diff --git a/main.py b/main.py index 765043a..b32ee05 100644 --- a/main.py +++ b/main.py @@ -15,8 +15,6 @@ # CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -from __future__ import unicode_literals - import os # See if there is a `venv` directory next to our script, and use that if @@ -41,7 +39,6 @@ import logbook import json import OpenSSL.crypto as crypto -from future.utils import bytes_to_native_str as n from logbook import Logger, StreamHandler try: @@ -96,7 +93,7 @@ matrix_config_server_write_cb, matrix_timer_cb, send_cb, matrix_load_users_cb) from matrix.utf import utf8_decode -from matrix.utils import server_buffer_prnt, server_buffer_set_title +from matrix.utils import server_buffer_prnt, server_buffer_set_title, bytes_to_native_str as n from matrix.uploads import UploadsBuffer, upload_cb diff --git a/matrix/bar_items.py b/matrix/bar_items.py index 23e6fc9..b3b185c 100644 --- a/matrix/bar_items.py +++ b/matrix/bar_items.py @@ -14,8 +14,6 @@ # CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -from __future__ import unicode_literals - from . import globals as G from .globals import SERVERS, W from .utf import utf8_decode diff --git a/matrix/buffer.py b/matrix/buffer.py index ce981b1..7e20511 100644 --- a/matrix/buffer.py +++ b/matrix/buffer.py @@ -15,8 +15,6 @@ # CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -from __future__ import unicode_literals - import time import attr import pprint diff --git a/matrix/colors.py b/matrix/colors.py index c00bc0d..270b811 100644 --- a/matrix/colors.py +++ b/matrix/colors.py @@ -17,8 +17,6 @@ # CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -from __future__ import unicode_literals - import html import re import textwrap diff --git a/matrix/commands.py b/matrix/commands.py index 598f859..cabff4a 100644 --- a/matrix/commands.py +++ b/matrix/commands.py @@ -15,15 +15,14 @@ # CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -from __future__ import unicode_literals import argparse import os import re import shlex from builtins import str -from future.moves.itertools import zip_longest from collections import defaultdict from functools import partial +from itertools import zip_longest from nio import EncryptionError, LocalProtocolError from . import globals as G diff --git a/matrix/completion.py b/matrix/completion.py index a1ac559..9cea035 100644 --- a/matrix/completion.py +++ b/matrix/completion.py @@ -14,8 +14,6 @@ # CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -from __future__ import unicode_literals - from typing import List, Optional from matrix.globals import SERVERS, W, SCRIPT_NAME from matrix.utf import utf8_decode diff --git a/matrix/globals.py b/matrix/globals.py index c3e099e..fde8fe9 100644 --- a/matrix/globals.py +++ b/matrix/globals.py @@ -14,8 +14,6 @@ # CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -from __future__ import unicode_literals - import sys from typing import Any, Dict, Optional from logbook import Logger diff --git a/matrix/message_renderer.py b/matrix/message_renderer.py index 8a6f544..5a929d0 100644 --- a/matrix/message_renderer.py +++ b/matrix/message_renderer.py @@ -17,7 +17,6 @@ """Module for rendering matrix messages in Weechat.""" -from __future__ import unicode_literals from nio import Api from .globals import W from .colors import Formatted diff --git a/matrix/server.py b/matrix/server.py index 0f34c1e..72075a4 100644 --- a/matrix/server.py +++ b/matrix/server.py @@ -14,8 +14,6 @@ # CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -from __future__ import unicode_literals - import os import pprint import socket diff --git a/matrix/uploads.py b/matrix/uploads.py index 05beb1c..25cff88 100644 --- a/matrix/uploads.py +++ b/matrix/uploads.py @@ -16,8 +16,6 @@ """Module implementing upload functionality.""" -from __future__ import unicode_literals - import attr import time import json diff --git a/matrix/utf.py b/matrix/utf.py index 4d71987..45d63a1 100644 --- a/matrix/utf.py +++ b/matrix/utf.py @@ -22,8 +22,6 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -from __future__ import unicode_literals - import sys # pylint: disable=redefined-builtin diff --git a/matrix/utils.py b/matrix/utils.py index ce5f9d1..98db643 100644 --- a/matrix/utils.py +++ b/matrix/utils.py @@ -15,8 +15,7 @@ # CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -from __future__ import unicode_literals, division - +import sys import time from typing import Any, Dict, List @@ -26,6 +25,11 @@ from .server import MatrixServer +def bytes_to_native_str(b, encoding='utf-8' if sys.version_info[0] >= 3 else None): + return b.decode(encoding) if sys.version_info[0] >= 3 else ( + b.__native__() if hasattr(b, '__native__') else b) + + def key_from_value(dictionary, value): # type: (Dict[str, Any], Any) -> str return list(dictionary.keys())[list(dictionary.values()).index(value)] diff --git a/pyproject.toml b/pyproject.toml index 709adf1..18fb197 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,6 @@ python = "^3.6" pyOpenSSL = "^19.1.0" webcolors = "^1.11.1" atomicwrites = "^1.3.0" -future = { version = "^0.18.2", python = "<3.2" } attrs = "^19.3.0" logbook = "^1.5.3" pygments = "^2.6.1" diff --git a/requirements.txt b/requirements.txt index ca7ed5b..1b7d74e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,6 @@ pyOpenSSL typing ; python_version < "3.5" webcolors -future; python_version < "3.2" atomicwrites attrs logbook diff --git a/tests/buffer_test.py b/tests/buffer_test.py index 0ba5697..bbde553 100644 --- a/tests/buffer_test.py +++ b/tests/buffer_test.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals - from matrix.buffer import WeechatChannelBuffer from matrix.utils import parse_redact_args diff --git a/tests/color_test.py b/tests/color_test.py index 79b5a28..20df212 100644 --- a/tests/color_test.py +++ b/tests/color_test.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals - import webcolors from collections import OrderedDict from hypothesis import given