diff --git a/benchmarks/serialization.py b/benchmarks/serialization.py index 87cf56c..831031a 100644 --- a/benchmarks/serialization.py +++ b/benchmarks/serialization.py @@ -6,7 +6,6 @@ small number of fields. """ -from __future__ import unicode_literals import time diff --git a/docs/source/development.rst b/docs/source/development.rst index b07ad4f..bd16543 100644 --- a/docs/source/development.rst +++ b/docs/source/development.rst @@ -3,8 +3,6 @@ Contributing to Eliot To run the full test suite, the Daemontools package should be installed. -All modules should have the ``from __future__ import unicode_literals`` statement, to ensure Unicode is used by default. - Coding standard is PEP8, with the only exception being camel case methods for the Twisted-related modules. Some camel case methods remain for backwards compatibility reasons with the old coding standard. diff --git a/eliot/__init__.py b/eliot/__init__.py index aa4820d..ac4ee44 100644 --- a/eliot/__init__.py +++ b/eliot/__init__.py @@ -1,6 +1,7 @@ """ Eliot: Logging for Complex & Distributed Systems. """ + from warnings import warn # Expose the public API: diff --git a/eliot/_action.py b/eliot/_action.py index 7ecbd11..782648c 100644 --- a/eliot/_action.py +++ b/eliot/_action.py @@ -5,8 +5,6 @@ top-level actions. """ -from __future__ import unicode_literals, absolute_import - import threading from uuid import uuid4 from contextlib import contextmanager @@ -16,7 +14,6 @@ from pyrsistent import field, PClass, optional, pmap_field, pvector from boltons.funcutils import wraps -from six import text_type as unicode, PY3 from ._message import ( WrittenMessage, @@ -114,9 +111,9 @@ def toString(self): """ Convert to a Unicode string, for serialization purposes. - @return: L{unicode} representation of the L{TaskLevel}. + @return: L{str} representation of the L{TaskLevel}. """ - return "/" + "/".join(map(unicode, self._level)) + return "/" + "/".join(map(str, self._level)) def next_sibling(self): """ @@ -569,7 +566,7 @@ class WrittenAction(PClass): start_message = field(type=optional(WrittenMessage), mandatory=True, initial=None) end_message = field(type=optional(WrittenMessage), mandatory=True, initial=None) task_level = field(type=TaskLevel, mandatory=True) - task_uuid = field(type=unicode, mandatory=True, factory=unicode) + task_uuid = field(type=str, mandatory=True, factory=str) # Pyrsistent doesn't support pmap_field with recursive types. _children = pmap_field(TaskLevel, object) @@ -838,7 +835,7 @@ def startTask(logger=None, action_type="", _serializers=None, **fields): @return: A new L{Action}. """ action = Action( - logger, unicode(uuid4()), TaskLevel(level=[]), action_type, _serializers + logger, str(uuid4()), TaskLevel(level=[]), action_type, _serializers ) action._start(fields) return action @@ -909,14 +906,11 @@ def log_call( ) if action_type is None: - if PY3: - action_type = "{}.{}".format( - wrapped_function.__module__, wrapped_function.__qualname__ - ) - else: - action_type = wrapped_function.__name__ + action_type = "{}.{}".format( + wrapped_function.__module__, wrapped_function.__qualname__ + ) - if PY3 and include_args is not None: + if include_args is not None: from inspect import signature sig = signature(wrapped_function) diff --git a/eliot/_errors.py b/eliot/_errors.py index 7c03e06..c62bf27 100644 --- a/eliot/_errors.py +++ b/eliot/_errors.py @@ -2,8 +2,6 @@ Error-handling utility code. """ -from __future__ import unicode_literals - from inspect import getmro diff --git a/eliot/_generators.py b/eliot/_generators.py index 1a7b0a1..3527e46 100644 --- a/eliot/_generators.py +++ b/eliot/_generators.py @@ -2,8 +2,6 @@ Support for maintaining an action context across generator suspension. """ -from __future__ import unicode_literals, absolute_import - from sys import exc_info from functools import wraps from contextlib import contextmanager diff --git a/eliot/_message.py b/eliot/_message.py index ca4aa52..be5f9f2 100644 --- a/eliot/_message.py +++ b/eliot/_message.py @@ -2,11 +2,8 @@ Log messages and related utilities. """ -from __future__ import unicode_literals - import time from warnings import warn -from six import text_type as unicode from pyrsistent import PClass, pmap_field @@ -74,7 +71,7 @@ def __init__(self, contents, serializer=None): You can also use L{Message.new} to create L{Message} objects. @param contents: The contents of this L{Message}, a C{dict} whose keys - must be C{unicode}, or text that has been UTF-8 encoded to + must be C{str}, or text that has been UTF-8 encoded to C{bytes}. @param serializer: Either C{None}, or @@ -141,7 +138,7 @@ class WrittenMessage(PClass): @ivar _logged_dict: The originally logged dictionary. """ - _logged_dict = pmap_field((str, unicode), object) + _logged_dict = pmap_field((str, str), object) @property def timestamp(self): diff --git a/eliot/_output.py b/eliot/_output.py index 8007bbf..af8644d 100644 --- a/eliot/_output.py +++ b/eliot/_output.py @@ -182,7 +182,7 @@ def _safe_unicode_dictionary(dictionary): @param dictionary: A L{dict} to serialize. - @return: A L{unicode} string representing the input dictionary as + @return: A L{str} string representing the input dictionary as faithfully as can be done without putting in too much effort. """ try: diff --git a/eliot/_traceback.py b/eliot/_traceback.py index 08e90a5..a737ab4 100644 --- a/eliot/_traceback.py +++ b/eliot/_traceback.py @@ -3,8 +3,6 @@ as well as common utilities for handling exception logging. """ -from __future__ import unicode_literals - import traceback import sys diff --git a/eliot/_util.py b/eliot/_util.py index 38768c4..a964dcb 100644 --- a/eliot/_util.py +++ b/eliot/_util.py @@ -2,44 +2,39 @@ Utilities that don't go anywhere else. """ -from __future__ import unicode_literals - -import sys from types import ModuleType -from six import exec_, text_type as unicode, PY3 - def safeunicode(o): """ - Like C{unicode()}, but catches and swallows any raised exceptions. + Like C{str()}, but catches and swallows any raised exceptions. @param o: An object of some sort. - @return: C{unicode(o)}, or an error message if that failed. - @rtype: C{unicode} + @return: C{str(o)}, or an error message if that failed. + @rtype: C{str} """ try: - return unicode(o) + return str(o) except: # Not much we can do about this... - return "eliot: unknown, unicode() raised exception" + return "eliot: unknown, str() raised exception" def saferepr(o): """ - Like C{unicode(repr())}, but catches and swallows any raised exceptions. + Like C{str(repr())}, but catches and swallows any raised exceptions. @param o: An object of some sort. - @return: C{unicode(repr(o))}, or an error message if that failed. - @rtype: C{unicode} + @return: C{str(repr(o))}, or an error message if that failed. + @rtype: C{str} """ try: - return unicode(repr(o)) + return str(repr(o)) except: # Not much we can do about this... - return "eliot: unknown, unicode() raised exception" + return "eliot: unknown, str() raised exception" def load_module(name, original_module): @@ -52,19 +47,10 @@ def load_module(name, original_module): @return: A new, distinct module. """ - module = ModuleType(name) - if PY3: - import importlib.util + import importlib.util - spec = importlib.util.find_spec(original_module.__name__) - source = spec.loader.get_code(original_module.__name__) - else: - if getattr(sys, "frozen", False): - raise NotImplementedError("Can't load modules on Python 2 with PyInstaller") - path = original_module.__file__ - if path.endswith(".pyc") or path.endswith(".pyo"): - path = path[:-1] - with open(path) as f: - source = f.read() - exec_(source, module.__dict__, module.__dict__) + module = ModuleType(name) + spec = importlib.util.find_spec(original_module.__name__) + source = spec.loader.get_code(original_module.__name__) + exec(source, module.__dict__, module.__dict__) return module diff --git a/eliot/_validation.py b/eliot/_validation.py index c69dc43..f198034 100644 --- a/eliot/_validation.py +++ b/eliot/_validation.py @@ -5,14 +5,8 @@ although in theory it could be done then as well. """ -from __future__ import unicode_literals - from warnings import warn -import six - -unicode = six.text_type - from pyrsistent import PClass, field as pyrsistent_field from ._message import ( @@ -42,8 +36,8 @@ class ValidationError(Exception): # Types that can be encoded to JSON: -_JSON_TYPES = {type(None), int, float, unicode, list, dict, bytes, bool} -_JSON_TYPES |= set(six.integer_types) +_JSON_TYPES = {type(None), int, float, str, list, dict, bytes, bool} +_JSON_TYPES |= set((int,)) RESERVED_FIELDS = (TASK_LEVEL_FIELD, TASK_UUID_FIELD, TIMESTAMP_FIELD) @@ -60,7 +54,7 @@ class Field(object): e.g. C{"path"}. @ivar description: A description of what this field contains. - @type description: C{unicode} + @type description: C{str} """ def __init__(self, key, serializer, description="", extraValidator=None): @@ -116,7 +110,7 @@ def forValue(klass, key, value, description): @param value: The allowed value for the field. @param description: A description of what this field contains. - @type description: C{unicode} + @type description: C{str} @return: A L{Field}. """ @@ -139,12 +133,12 @@ def forTypes(klass, key, classes, description, extraValidator=None): e.g. C{"path"}. @ivar classes: A C{list} of allowed Python classes for this field's - values. Supported classes are C{unicode}, C{int}, C{float}, + values. Supported classes are C{str}, C{int}, C{float}, C{bool}, C{long}, C{list} and C{dict} and C{None} (the latter isn't strictly a class, but will be converted appropriately). @param description: A description of what this field contains. - @type description: C{unicode} + @type description: C{str} @param extraValidator: See description in L{Field.__init__}. @@ -189,16 +183,16 @@ def fields(*fields, **keys): ] -REASON = Field.forTypes(REASON_FIELD, [unicode], "The reason for an event.") -TRACEBACK = Field.forTypes("traceback", [unicode], "The traceback for an exception.") -EXCEPTION = Field.forTypes("exception", [unicode], "The FQPN of an exception class.") +REASON = Field.forTypes(REASON_FIELD, [str], "The reason for an event.") +TRACEBACK = Field.forTypes("traceback", [str], "The traceback for an exception.") +EXCEPTION = Field.forTypes("exception", [str], "The FQPN of an exception class.") class _MessageSerializer(object): """ A serializer and validator for messages. - @ivar fields: A C{dict} mapping a C{unicode} field name to the respective + @ivar fields: A C{dict} mapping a C{str} field name to the respective L{Field}. @ivar allow_additional_fields: If true, additional fields don't cause validation failure. @@ -300,7 +294,7 @@ def setstatus(key, status): e.g. C{"yourapp:subsystem:yourtype"}. @ivar description: A description of what this message means. - @type description: C{unicode} + @type description: C{str} """ def __init__(self, message_type, fields, description=""): @@ -312,7 +306,7 @@ def __init__(self, message_type, fields, description=""): type. @param description: A description of what this message means. - @type description: C{unicode} + @type description: C{str} """ self.message_type = message_type self.description = description @@ -395,7 +389,7 @@ def dosomething(key): C{"exception"} and C{"reason"} fields). @ivar description: A description of what this action's messages mean. - @type description: C{unicode} + @type description: C{str} """ # Overrideable hook for testing; need staticmethod() so functions don't diff --git a/eliot/parse.py b/eliot/parse.py index 6226eec..0e618b4 100644 --- a/eliot/parse.py +++ b/eliot/parse.py @@ -3,10 +3,6 @@ ``WrittenAction`` and ``WrittenMessage`` objects. """ -from __future__ import unicode_literals - -from six import text_type as unicode - from pyrsistent import PClass, pmap_field, pset_field, discard from ._message import WrittenMessage, TASK_UUID_FIELD @@ -141,7 +137,7 @@ class Parser(PClass): @ivar _tasks: Map from UUID to corresponding L{Task}. """ - _tasks = pmap_field(unicode, Task) + _tasks = pmap_field(str, Task) def add(self, message_dict): """ diff --git a/eliot/serializers.py b/eliot/serializers.py index 9834154..eee5c58 100644 --- a/eliot/serializers.py +++ b/eliot/serializers.py @@ -2,8 +2,6 @@ Standardized serialization code. """ -from __future__ import unicode_literals - from hashlib import md5 _TIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%fZ" diff --git a/eliot/tai64n.py b/eliot/tai64n.py index 7b94883..3ae437f 100644 --- a/eliot/tai64n.py +++ b/eliot/tai64n.py @@ -6,8 +6,6 @@ @see: U{http://cr.yp.to/libtai/tai64.html}. """ -from __future__ import unicode_literals - import struct from binascii import b2a_hex, a2b_hex diff --git a/eliot/testing.py b/eliot/testing.py index 7fdcba4..5d93cd4 100644 --- a/eliot/testing.py +++ b/eliot/testing.py @@ -2,13 +2,10 @@ Utilities to aid unit testing L{eliot} and code that uses it. """ -from __future__ import unicode_literals - from unittest import SkipTest from functools import wraps from pyrsistent import PClass, field -from six import text_type from ._action import ( ACTION_STATUS_FIELD, @@ -167,7 +164,7 @@ def of_type(klass, messages, actionType): @return: A C{list} of L{LoggedAction}. """ - if not isinstance(actionType, text_type): + if not isinstance(actionType, str): actionType = actionType.action_type result = [] for message in messages: @@ -250,7 +247,7 @@ def of_type(klass, messages, messageType): @return: A C{list} of L{LoggedMessage}. """ result = [] - if not isinstance(messageType, text_type): + if not isinstance(messageType, str): messageType = messageType.message_type for message in messages: if message.get(MESSAGE_TYPE_FIELD) == messageType: diff --git a/eliot/tests/strategies.py b/eliot/tests/strategies.py index ec27226..7474405 100644 --- a/eliot/tests/strategies.py +++ b/eliot/tests/strategies.py @@ -2,10 +2,7 @@ Hypothesis strategies for eliot. """ -from __future__ import unicode_literals - from functools import partial -from six import text_type as unicode from hypothesis.strategies import ( builds, @@ -58,7 +55,7 @@ message_core_dicts = fixed_dictionaries( dict( task_level=task_level_lists.map(pvector), - task_uuid=uuids().map(unicode), + task_uuid=uuids().map(str), timestamp=timestamps, ) ).map(pmap) diff --git a/eliot/tests/test_action.py b/eliot/tests/test_action.py index 7f15aa1..ec1e4d1 100644 --- a/eliot/tests/test_action.py +++ b/eliot/tests/test_action.py @@ -2,19 +2,12 @@ Tests for L{eliot._action}. """ -from __future__ import unicode_literals - import pickle import time -from unittest import TestCase, skipIf +from unittest import TestCase from unittest.mock import patch from threading import Thread -import six - -if six.PY3: - unicode = six.text_type - from hypothesis import assume, given, settings, HealthCheck from hypothesis.strategies import integers, lists, just, text @@ -388,7 +381,7 @@ def test_startFieldsNotInFinish(self): def test_finishWithBadException(self): """ L{Action.finish} still logs a message if the given exception raises - another exception when called with C{unicode()}. + another exception when called with C{str()}. """ logger = MemoryLogger() action = Action(logger, "unique", TaskLevel(level=[]), "sys:thename") @@ -399,7 +392,7 @@ def __str__(self): action.finish(BadException()) self.assertEqual( - logger.messages[0]["reason"], "eliot: unknown, unicode() raised exception" + logger.messages[0]["reason"], "eliot: unknown, str() raised exception" ) def test_withLogsSuccessfulFinishMessage(self): @@ -756,7 +749,7 @@ def test_continueTaskUnicode(self): L{Action.continue_task} can take a Unicode task identifier. """ original_action = Action(None, "uniq790", TaskLevel(level=[3, 4]), "mytype") - task_id = unicode(original_action.serialize_task_id(), "utf-8") + task_id = str(original_action.serialize_task_id(), "utf-8") new_action = Action.continue_task(MemoryLogger(), task_id) self.assertEqual(new_action._identification["task_uuid"], "uniq790") @@ -1553,9 +1546,6 @@ class LogCallTests(TestCase): def assert_logged(self, logger, action_type, expected_params, expected_result): """Assert that an action of given structure was logged.""" - if six.PY2: - # On Python 2 we don't include the module or class: - action_type = action_type.split(".")[-1] [tree] = Parser.parse_stream(logger.messages) root = tree.root() self.assertEqual(root.action_type, action_type) @@ -1656,7 +1646,6 @@ def myfunc(x, y, z): myfunc(2, 3, 4) self.assert_logged(logger, self.id() + "..myfunc", {"x": 2, "z": 4}, 6) - @skipIf(six.PY2, "Didn't bother implementing safety check on Python 2") def test_wrong_whitelist_args(self): """If C{include_args} doesn't match function, raise an exception.""" with self.assertRaises(ValueError): diff --git a/eliot/tests/test_api.py b/eliot/tests/test_api.py index e99798b..3e9c3b0 100644 --- a/eliot/tests/test_api.py +++ b/eliot/tests/test_api.py @@ -2,8 +2,6 @@ Tests for the public API exposed by L{eliot}. """ -from __future__ import unicode_literals - from unittest import TestCase from .._output import Logger diff --git a/eliot/tests/test_filter.py b/eliot/tests/test_filter.py index 87e5493..113901c 100644 --- a/eliot/tests/test_filter.py +++ b/eliot/tests/test_filter.py @@ -1,7 +1,6 @@ """ Tests for L{eliot.filter}. """ -from __future__ import unicode_literals import sys diff --git a/eliot/tests/test_generators.py b/eliot/tests/test_generators.py index a92cff3..e6ae863 100644 --- a/eliot/tests/test_generators.py +++ b/eliot/tests/test_generators.py @@ -2,8 +2,6 @@ Tests for L{eliot._generators}. """ -from __future__ import unicode_literals, absolute_import - from pprint import pformat from unittest import TestCase diff --git a/eliot/tests/test_journald.py b/eliot/tests/test_journald.py index 4063d78..b29f0e0 100644 --- a/eliot/tests/test_journald.py +++ b/eliot/tests/test_journald.py @@ -1,6 +1,7 @@ """ Tests for L{eliot.journald}. """ + from os import getpid, strerror from unittest import skipUnless, TestCase from subprocess import check_output, CalledProcessError, STDOUT @@ -8,8 +9,6 @@ from sys import argv from uuid import uuid4 from time import sleep - -from six import text_type as unicode from json import loads from .._output import MemoryLogger @@ -43,7 +42,7 @@ def last_journald_message(): # It may take a little for messages to actually reach journald, so we # write out marker message and wait until it arrives. We can then be # sure the message right before it is the one we want. - marker = unicode(uuid4()) + marker = str(uuid4()) sd_journal_send(MESSAGE=marker.encode("ascii")) for i in range(500): messages = check_output( diff --git a/eliot/tests/test_message.py b/eliot/tests/test_message.py index 69bb2ea..1b561f3 100644 --- a/eliot/tests/test_message.py +++ b/eliot/tests/test_message.py @@ -2,8 +2,6 @@ Tests for L{eliot._message}. """ -from __future__ import unicode_literals - from unittest import TestCase from uuid import UUID import time diff --git a/eliot/tests/test_output.py b/eliot/tests/test_output.py index 847c655..c94414b 100644 --- a/eliot/tests/test_output.py +++ b/eliot/tests/test_output.py @@ -575,7 +575,7 @@ def __repr__(self): raise TypeError() dictionary = {badobject(): 123, 123: badobject()} - badMessage = "eliot: unknown, unicode() raised exception" + badMessage = "eliot: unknown, str() raised exception" self.assertEqual( eval(_safe_unicode_dictionary(dictionary)), {badMessage: "123", "123": badMessage}, @@ -599,7 +599,7 @@ def __repr__(self): self.assertEqual( _safe_unicode_dictionary(badobject()), - "eliot: unknown, unicode() raised exception", + "eliot: unknown, str() raised exception", ) def test_serializationErrorTraceback(self): diff --git a/eliot/tests/test_parse.py b/eliot/tests/test_parse.py index fec5bc6..e9bf2da 100644 --- a/eliot/tests/test_parse.py +++ b/eliot/tests/test_parse.py @@ -2,13 +2,8 @@ Tests for L{eliot._parse}. """ -from __future__ import unicode_literals - from unittest import TestCase -from itertools import chain - -from six import text_type as unicode, assertCountEqual -from six.moves import zip_longest +from itertools import chain, zip_longest from hypothesis import strategies as st, given, assume @@ -35,14 +30,14 @@ class ActionStructure(PClass): encoded as a L{ActionStructure} instance. """ - type = field(type=(unicode, None.__class__)) + type = field(type=(str, None.__class__)) children = pvector_field(object) # XXX ("StubAction", unicode)) failed = field(type=bool) @classmethod def from_written(cls, written): """ - Create an L{ActionStructure} or L{unicode} from a L{WrittenAction} or + Create an L{ActionStructure} or L{str} from a L{WrittenAction} or L{WrittenMessage}. """ if isinstance(written, WrittenMessage): @@ -61,7 +56,7 @@ def from_written(cls, written): @classmethod def to_eliot(cls, structure_or_message, logger): """ - Given a L{ActionStructure} or L{unicode}, generate appropriate + Given a L{ActionStructure} or L{str}, generate appropriate structured Eliot log mesages to given L{MemoryLogger}. """ if isinstance(structure_or_message, cls): @@ -83,7 +78,7 @@ def to_eliot(cls, structure_or_message, logger): def action_structures(draw): """ A Hypothesis strategy that creates a tree of L{ActionStructure} and - L{unicode}. + L{str}. """ tree = draw(st.recursive(labels, st.lists, max_leaves=20)) @@ -137,7 +132,7 @@ def test_missing_action(self, structure_and_messages): remaining messages. """ action_structure, messages = structure_and_messages - assume(not isinstance(action_structure, unicode)) + assume(not isinstance(action_structure, str)) # Remove first start message we encounter; since messages are # shuffled the location removed will differ over Hypothesis test @@ -240,9 +235,7 @@ def test_parse_into_tasks( completed_tasks, parser = parser.add(message) all_tasks.extend(completed_tasks) - assertCountEqual( - self, all_tasks, [parse_to_task(msgs) for msgs in all_messages] - ) + self.assertCountEqual(all_tasks, [parse_to_task(msgs) for msgs in all_messages]) @given(structure_and_messages=STRUCTURES_WITH_MESSAGES) def test_incomplete_tasks(self, structure_and_messages): @@ -300,9 +293,7 @@ def test_parse_stream( [m for m in chain(*zip_longest(*all_messages)) if m is not None] ) ) - assertCountEqual( - self, all_tasks, [parse_to_task(msgs) for msgs in all_messages] - ) + self.assertCountEqual(all_tasks, [parse_to_task(msgs) for msgs in all_messages]) class BackwardsCompatibility(TestCase): diff --git a/eliot/tests/test_pyinstaller.py b/eliot/tests/test_pyinstaller.py index 1b07c92..21387ea 100644 --- a/eliot/tests/test_pyinstaller.py +++ b/eliot/tests/test_pyinstaller.py @@ -1,17 +1,10 @@ """Test for pyinstaller compatibility.""" -from __future__ import absolute_import - from unittest import TestCase, SkipTest from tempfile import mkdtemp, NamedTemporaryFile from subprocess import check_call, CalledProcessError import os -from six import PY2 - -if PY2: - FileNotFoundError = OSError - class PyInstallerTests(TestCase): """Make sure PyInstaller doesn't break Eliot.""" diff --git a/eliot/tests/test_serializers.py b/eliot/tests/test_serializers.py index fac24bc..e356bc2 100644 --- a/eliot/tests/test_serializers.py +++ b/eliot/tests/test_serializers.py @@ -2,8 +2,6 @@ Tests for L{eliot.serializers}. """ -from __future__ import unicode_literals - from unittest import TestCase from datetime import datetime from hashlib import md5 diff --git a/eliot/tests/test_tai64n.py b/eliot/tests/test_tai64n.py index 16529be..4c391ba 100644 --- a/eliot/tests/test_tai64n.py +++ b/eliot/tests/test_tai64n.py @@ -2,8 +2,6 @@ Tests for L{eliot.tai64n}. """ -from __future__ import unicode_literals - import errno import time import subprocess diff --git a/eliot/tests/test_testing.py b/eliot/tests/test_testing.py index 8df9874..9c024b0 100644 --- a/eliot/tests/test_testing.py +++ b/eliot/tests/test_testing.py @@ -2,8 +2,6 @@ Tests for L{eliot.testing}. """ -from __future__ import unicode_literals - from unittest import SkipTest, TestResult, TestCase, skipUnless try: diff --git a/eliot/tests/test_traceback.py b/eliot/tests/test_traceback.py index 37a3f75..eaef20c 100644 --- a/eliot/tests/test_traceback.py +++ b/eliot/tests/test_traceback.py @@ -2,8 +2,6 @@ Tests for L{eliot._traceback}. """ -from __future__ import unicode_literals - from unittest import TestCase, SkipTest import traceback import sys @@ -204,7 +202,7 @@ def __str__(self): _writeTracebackMessage(logger, *exc_info) self.assertEqual( logger.serialize()[0]["reason"], - "eliot: unknown, unicode() raised exception", + "eliot: unknown, str() raised exception", ) logger.flushTracebacks(BadException) diff --git a/eliot/tests/test_twisted.py b/eliot/tests/test_twisted.py index 46bbbd0..fa96bfc 100644 --- a/eliot/tests/test_twisted.py +++ b/eliot/tests/test_twisted.py @@ -2,8 +2,6 @@ Tests for L{eliot.twisted}. """ -from __future__ import absolute_import, unicode_literals, print_function - import sys from functools import wraps diff --git a/eliot/tests/test_util.py b/eliot/tests/test_util.py index 88d53e5..6640dda 100644 --- a/eliot/tests/test_util.py +++ b/eliot/tests/test_util.py @@ -2,8 +2,6 @@ Tests for L{eliot._util}. """ -from __future__ import unicode_literals - from unittest import TestCase import pprint diff --git a/eliot/tests/test_validation.py b/eliot/tests/test_validation.py index 753d922..097e731 100644 --- a/eliot/tests/test_validation.py +++ b/eliot/tests/test_validation.py @@ -2,12 +2,8 @@ Tests for L{eliot._validation}. """ -from __future__ import unicode_literals - from unittest import TestCase -from six import text_type as unicode - from .._validation import ( Field, MessageType, @@ -32,7 +28,7 @@ def test_validateCorrectType(self): L{Field.validate} will not raise an exception if the given value is in the list of supported classes. """ - field = Field.forTypes("path", [unicode, int], "A path!") + field = Field.forTypes("path", [str, int], "A path!") field.validate(123) field.validate("hello") @@ -879,7 +875,7 @@ class EndToEndValidationTests(TestCase): ACTION = ActionType( "myapp:myaction", [Field.forTypes("key", [int], "The key")], - [Field.forTypes("result", [unicode], "The result")], + [Field.forTypes("result", [str], "The result")], "An action for testing.", ) diff --git a/eliot/twisted.py b/eliot/twisted.py index 5f83094..5ce7952 100644 --- a/eliot/twisted.py +++ b/eliot/twisted.py @@ -2,8 +2,6 @@ APIs for using Eliot from Twisted. """ -from __future__ import absolute_import, unicode_literals - import os import sys diff --git a/examples/cross_process_client.py b/examples/cross_process_client.py index 1295449..c41b3e2 100644 --- a/examples/cross_process_client.py +++ b/examples/cross_process_client.py @@ -1,7 +1,6 @@ """ Cross-process log tracing: HTTP client. """ -from __future__ import unicode_literals import sys import requests diff --git a/examples/cross_process_server.py b/examples/cross_process_server.py index 746ff7a..6d232d4 100644 --- a/examples/cross_process_server.py +++ b/examples/cross_process_server.py @@ -1,7 +1,6 @@ """ Cross-process log tracing: HTTP server. """ -from __future__ import unicode_literals import sys from flask import Flask, request diff --git a/examples/cross_thread.py b/examples/cross_thread.py index f625bd5..69e1ca9 100644 --- a/examples/cross_thread.py +++ b/examples/cross_thread.py @@ -4,7 +4,6 @@ Example of an Eliot action context spanning multiple threads. """ -from __future__ import unicode_literals from threading import Thread from sys import stdout diff --git a/examples/journald.py b/examples/journald.py index 4baf40e..3c6000d 100644 --- a/examples/journald.py +++ b/examples/journald.py @@ -2,7 +2,6 @@ Write some logs to journald. """ -from __future__ import print_function from eliot import log_message, start_action, add_destinations from eliot.journald import JournaldDestination diff --git a/examples/logfile.py b/examples/logfile.py index e4b58d5..20fc682 100644 --- a/examples/logfile.py +++ b/examples/logfile.py @@ -1,7 +1,6 @@ """ Output an Eliot message to a log file using the threaded log writer. """ -from __future__ import unicode_literals, print_function from twisted.internet.task import react diff --git a/examples/stdout.py b/examples/stdout.py index 8c28e03..9332e0d 100644 --- a/examples/stdout.py +++ b/examples/stdout.py @@ -1,7 +1,6 @@ """ Output a few Eliot message to standard out. """ -from __future__ import unicode_literals import sys import time diff --git a/setup.py b/setup.py index 0cabd6e..2e9696a 100644 --- a/setup.py +++ b/setup.py @@ -33,8 +33,6 @@ def read(path): description="Logging library that tells you why it happened", python_requires=">=3.8.0", install_requires=[ - # Python 3 compatibility: - "six", # Internal code documentation: "zope.interface", # Persistent objects for Python: