From 051a1582b809dc5793e0c4e131eb4f305e2096f7 Mon Sep 17 00:00:00 2001 From: Colton Myers Date: Tue, 11 Jan 2022 10:30:31 -0700 Subject: [PATCH 1/5] Remove python 2 support --- .ci/Jenkinsfile | 4 ++-- ecs_logging/_stdlib.py | 11 +++-------- noxfile.py | 6 +++--- pyproject.toml | 3 +-- tests/compat.py | 25 ------------------------- tests/conftest.py | 16 +++------------- tests/test_apm.py | 10 +++++----- tests/test_stdlib_formatter.py | 22 +++++++++------------- tests/test_structlog_formatter.py | 4 ++-- 9 files changed, 28 insertions(+), 73 deletions(-) delete mode 100644 tests/compat.py diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index d10eeaa..166c030 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -55,7 +55,7 @@ pipeline { axes { axis { name 'VERSION' - values '2.7', '3.6', '3.7', '3.8' + values '3.6', '3.7', '3.8', '3.9', '3.10' } } stages { @@ -88,7 +88,7 @@ pipeline { } def python(Map v = [:], body) { - def dockerImage = v.version.equals('2.7') ? 'python:3.7' : "python:${v.version}" + def dockerImage = "python:${v.version}" // If dockerhub got issues then let's retry twice retry(2) { sleep 5 diff --git a/ecs_logging/_stdlib.py b/ecs_logging/_stdlib.py index 5905e86..7f4001f 100644 --- a/ecs_logging/_stdlib.py +++ b/ecs_logging/_stdlib.py @@ -111,14 +111,9 @@ def __init__( if validate is not None: # validate was introduced in py3.8 so we need to only provide it if the user provided it _kwargs["validate"] = validate - if sys.version_info < (3, 0): # Different args in py2.7 - super(StdlibFormatter, self).__init__( # type: ignore[call-arg] - fmt=fmt, datefmt=datefmt - ) - else: - super(StdlibFormatter, self).__init__( # type: ignore[call-arg] - fmt=fmt, datefmt=datefmt, style=style, **_kwargs - ) + super(StdlibFormatter, self).__init__( # type: ignore[call-arg] + fmt=fmt, datefmt=datefmt, style=style, **_kwargs + ) if stack_trace_limit is not None: if not isinstance(stack_trace_limit, int): diff --git a/noxfile.py b/noxfile.py index e5e30a1..de3868c 100644 --- a/noxfile.py +++ b/noxfile.py @@ -36,7 +36,7 @@ def tests_impl(session): ) -@nox.session(python=["2.7", "3.6", "3.7", "3.8"]) +@nox.session(python=["3.6", "3.7", "3.8", "3.9", "3.10"]) def test(session): tests_impl(session) @@ -44,7 +44,7 @@ def test(session): @nox.session() def blacken(session): session.install("black") - session.run("black", "--target-version=py27", *SOURCE_FILES) + session.run("black", "--target-version=py36", *SOURCE_FILES) lint(session) @@ -52,7 +52,7 @@ def blacken(session): @nox.session def lint(session): session.install("flake8", "black", "mypy") - session.run("black", "--check", "--target-version=py27", *SOURCE_FILES) + session.run("black", "--check", "--target-version=py36", *SOURCE_FILES) session.run("flake8", "--ignore=E501,W503", *SOURCE_FILES) session.run( "mypy", diff --git a/pyproject.toml b/pyproject.toml index 4dd2450..4bac85d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,6 @@ classifiers = [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", @@ -26,7 +25,7 @@ classifiers = [ requires = [ "backports.functools-lru-cache; python_version < '3.3'" ] -requires-python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*" +requires-python = "!=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*" [tool.flit.metadata.requires-extra] develop = [ diff --git a/tests/compat.py b/tests/compat.py deleted file mode 100644 index 73e03e7..0000000 --- a/tests/compat.py +++ /dev/null @@ -1,25 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -import sys - -if sys.version_info >= (3,): - from io import StringIO -else: - from io import BytesIO as StringIO - -__all__ = ["StringIO"] diff --git a/tests/conftest.py b/tests/conftest.py index 45d6873..f9c7327 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -30,10 +30,6 @@ class ValidationError(Exception): pass -if sys.version_info[0] >= 3: - basestring = str - - @pytest.fixture def spec_validator(): with open( @@ -65,9 +61,7 @@ def validator(data_json): if not found: raise ValidationError("Missing required key {}".format(k)) if k in data: - if v["type"] == "string" and not ( - isinstance(data[k], str) or isinstance(data[k], basestring) - ): + if v["type"] == "string" and not isinstance(data[k], str): raise ValidationError( "Value {0} for key {1} should be string, is {2}".format( data[k], k, type(data[k]) @@ -92,12 +86,8 @@ def validator(data_json): @pytest.fixture def apm(): - if sys.version_info < (3, 6): - pytest.skip("elasticapm only supports python 3.6+") - if sys.version_info[0] >= 3: - record_factory = logging.getLogRecordFactory() + record_factory = logging.getLogRecordFactory() apm = elasticapm.Client({"SERVICE_NAME": "apm-service", "DISABLE_SEND": True}) yield apm apm.close() - if sys.version_info[0] >= 3: - logging.setLogRecordFactory(record_factory) + logging.setLogRecordFactory(record_factory) diff --git a/tests/test_apm.py b/tests/test_apm.py index 2d8c8b4..0af31e6 100644 --- a/tests/test_apm.py +++ b/tests/test_apm.py @@ -24,11 +24,11 @@ import logging import structlog import pytest -from .compat import StringIO +from io import BytesIO def test_elasticapm_structlog_log_correlation_ecs_fields(spec_validator, apm): - stream = StringIO() + stream = BytesIO() logger = structlog.PrintLogger(stream) logger = structlog.wrap_logger( logger, processors=[structlog_processor, ecs_logging.StructlogFormatter()] @@ -60,7 +60,7 @@ def test_elasticapm_structlog_log_correlation_ecs_fields(spec_validator, apm): def test_elastic_apm_stdlib_no_filter_log_correlation_ecs_fields(apm): - stream = StringIO() + stream = BytesIO() logger = logging.getLogger("apm-logger") handler = logging.StreamHandler(stream) handler.setFormatter( @@ -103,7 +103,7 @@ def test_elastic_apm_stdlib_no_filter_log_correlation_ecs_fields(apm): def test_elastic_apm_stdlib_with_filter_log_correlation_ecs_fields(apm): - stream = StringIO() + stream = BytesIO() logger = logging.getLogger("apm-logger") handler = logging.StreamHandler(stream) handler.setFormatter( @@ -147,7 +147,7 @@ def test_elastic_apm_stdlib_with_filter_log_correlation_ecs_fields(apm): def test_elastic_apm_stdlib_exclude_fields(apm): - stream = StringIO() + stream = BytesIO() logger = logging.getLogger("apm-logger") handler = logging.StreamHandler(stream) handler.setFormatter( diff --git a/tests/test_stdlib_formatter.py b/tests/test_stdlib_formatter.py index 2aca1b0..bf6267a 100644 --- a/tests/test_stdlib_formatter.py +++ b/tests/test_stdlib_formatter.py @@ -24,11 +24,7 @@ import random import sys import ecs_logging -from .compat import StringIO - -requires_py3 = pytest.mark.skipif( - sys.version_info[0] < 3, reason="Test requires Python 3.x+" -) +from io import BytesIO @pytest.fixture(scope="function") @@ -91,7 +87,7 @@ def format_to_ecs(self, record): def test_can_be_set_on_handler(): - stream = StringIO() + stream = BytesIO() handler = logging.StreamHandler(stream) handler.setFormatter(ecs_logging.StdlibFormatter(exclude_fields=["process"])) @@ -108,7 +104,7 @@ def test_can_be_set_on_handler(): def test_extra_is_merged(time, logger): time.return_value = 1584720997.187709 - stream = StringIO() + stream = BytesIO() handler = logging.StreamHandler(stream) handler.setFormatter( ecs_logging.StdlibFormatter(exclude_fields=["process", "tls.client"]) @@ -158,7 +154,7 @@ def g(): def h(): raise ValueError("error!") - stream = StringIO() + stream = BytesIO() handler = logging.StreamHandler(stream) handler.setFormatter(ecs_logging.StdlibFormatter(**kwargs)) logger.addHandler(handler) @@ -176,7 +172,7 @@ def h(): @pytest.mark.parametrize("stack_trace_limit", [0, False]) def test_stack_trace_limit_disabled(stack_trace_limit, logger): - stream = StringIO() + stream = BytesIO() handler = logging.StreamHandler(stream) handler.setFormatter( ecs_logging.StdlibFormatter(stack_trace_limit=stack_trace_limit) @@ -197,7 +193,7 @@ def test_stack_trace_limit_disabled(stack_trace_limit, logger): def test_exc_info_false_does_not_raise(logger): - stream = StringIO() + stream = BytesIO() handler = logging.StreamHandler(stream) handler.setFormatter(ecs_logging.StdlibFormatter()) logger.addHandler(handler) @@ -221,7 +217,7 @@ def g(): def h(): raise ValueError("error!") - stream = StringIO() + stream = BytesIO() handler = logging.StreamHandler(stream) handler.setFormatter(ecs_logging.StdlibFormatter(stack_trace_limit=2)) logger.addHandler(handler) @@ -313,7 +309,7 @@ def test_exclude_fields_type_and_values(): @requires_py3 def test_stack_info(logger): - stream = StringIO() + stream = BytesIO() handler = logging.StreamHandler(stream) handler.setFormatter(ecs_logging.StdlibFormatter()) logger.addHandler(handler) @@ -330,7 +326,7 @@ def test_stack_info(logger): @requires_py3 @pytest.mark.parametrize("exclude_fields", [["error"], ["error.stack_trace"]]) def test_stack_info_excluded(logger, exclude_fields): - stream = StringIO() + stream = BytesIO() handler = logging.StreamHandler(stream) handler.setFormatter(ecs_logging.StdlibFormatter(exclude_fields=exclude_fields)) logger.addHandler(handler) diff --git a/tests/test_structlog_formatter.py b/tests/test_structlog_formatter.py index 26ebcac..28d03b8 100644 --- a/tests/test_structlog_formatter.py +++ b/tests/test_structlog_formatter.py @@ -18,7 +18,7 @@ import ecs_logging import structlog import mock -from .compat import StringIO +from io import BytesIO import pytest @@ -64,7 +64,7 @@ def test_event_dict_formatted(time, spec_validator): def test_can_be_set_as_processor(time, spec_validator): time.return_value = 1584720997.187709 - stream = StringIO() + stream = BytesIO() structlog.configure( processors=[ecs_logging.StructlogFormatter()], wrapper_class=structlog.BoundLogger, From 63945eaf18810924e1cb3b98e7bf350cdc0da12e Mon Sep 17 00:00:00 2001 From: Colton Myers Date: Tue, 11 Jan 2022 10:50:25 -0700 Subject: [PATCH 2/5] Lint --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index de3868c..a0a7082 100644 --- a/noxfile.py +++ b/noxfile.py @@ -32,7 +32,7 @@ def tests_impl(session): "--junitxml=junit-test.xml", "--cov=ecs_logging", *(session.posargs or ("tests/",)), - env={"PYTHONWARNINGS": "always::DeprecationWarning"} + env={"PYTHONWARNINGS": "always::DeprecationWarning"}, ) From cb68bc37eb3f5c54ae520d189b75915652b961b8 Mon Sep 17 00:00:00 2001 From: Colton Myers Date: Tue, 11 Jan 2022 10:54:08 -0700 Subject: [PATCH 3/5] Simplify pyproject and remove requires_py3 refs --- pyproject.toml | 2 +- tests/test_stdlib_formatter.py | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4bac85d..5c97f24 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,7 @@ classifiers = [ requires = [ "backports.functools-lru-cache; python_version < '3.3'" ] -requires-python = "!=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*" +requires-python = ">=3.6" [tool.flit.metadata.requires-extra] develop = [ diff --git a/tests/test_stdlib_formatter.py b/tests/test_stdlib_formatter.py index bf6267a..af92e0a 100644 --- a/tests/test_stdlib_formatter.py +++ b/tests/test_stdlib_formatter.py @@ -307,7 +307,6 @@ def test_exclude_fields_type_and_values(): assert str(e.value) == "'exclude_fields' must be a sequence of strings" -@requires_py3 def test_stack_info(logger): stream = BytesIO() handler = logging.StreamHandler(stream) @@ -323,7 +322,6 @@ def test_stack_info(logger): assert "test_stack_info" in error_stack_trace and __file__ in error_stack_trace -@requires_py3 @pytest.mark.parametrize("exclude_fields", [["error"], ["error.stack_trace"]]) def test_stack_info_excluded(logger, exclude_fields): stream = BytesIO() From 20810e8114bdaa231169dcb29070c69c0a93b83c Mon Sep 17 00:00:00 2001 From: Colton Myers Date: Tue, 11 Jan 2022 10:56:24 -0700 Subject: [PATCH 4/5] Properly fix compat --- tests/test_apm.py | 10 +++++----- tests/test_stdlib_formatter.py | 18 +++++++++--------- tests/test_structlog_formatter.py | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/test_apm.py b/tests/test_apm.py index 0af31e6..493954d 100644 --- a/tests/test_apm.py +++ b/tests/test_apm.py @@ -24,11 +24,11 @@ import logging import structlog import pytest -from io import BytesIO +from io import StringIO def test_elasticapm_structlog_log_correlation_ecs_fields(spec_validator, apm): - stream = BytesIO() + stream = StringIO() logger = structlog.PrintLogger(stream) logger = structlog.wrap_logger( logger, processors=[structlog_processor, ecs_logging.StructlogFormatter()] @@ -60,7 +60,7 @@ def test_elasticapm_structlog_log_correlation_ecs_fields(spec_validator, apm): def test_elastic_apm_stdlib_no_filter_log_correlation_ecs_fields(apm): - stream = BytesIO() + stream = StringIO() logger = logging.getLogger("apm-logger") handler = logging.StreamHandler(stream) handler.setFormatter( @@ -103,7 +103,7 @@ def test_elastic_apm_stdlib_no_filter_log_correlation_ecs_fields(apm): def test_elastic_apm_stdlib_with_filter_log_correlation_ecs_fields(apm): - stream = BytesIO() + stream = StringIO() logger = logging.getLogger("apm-logger") handler = logging.StreamHandler(stream) handler.setFormatter( @@ -147,7 +147,7 @@ def test_elastic_apm_stdlib_with_filter_log_correlation_ecs_fields(apm): def test_elastic_apm_stdlib_exclude_fields(apm): - stream = BytesIO() + stream = StringIO() logger = logging.getLogger("apm-logger") handler = logging.StreamHandler(stream) handler.setFormatter( diff --git a/tests/test_stdlib_formatter.py b/tests/test_stdlib_formatter.py index af92e0a..c33d04b 100644 --- a/tests/test_stdlib_formatter.py +++ b/tests/test_stdlib_formatter.py @@ -24,7 +24,7 @@ import random import sys import ecs_logging -from io import BytesIO +from io import StringIO @pytest.fixture(scope="function") @@ -87,7 +87,7 @@ def format_to_ecs(self, record): def test_can_be_set_on_handler(): - stream = BytesIO() + stream = StringIO() handler = logging.StreamHandler(stream) handler.setFormatter(ecs_logging.StdlibFormatter(exclude_fields=["process"])) @@ -104,7 +104,7 @@ def test_can_be_set_on_handler(): def test_extra_is_merged(time, logger): time.return_value = 1584720997.187709 - stream = BytesIO() + stream = StringIO() handler = logging.StreamHandler(stream) handler.setFormatter( ecs_logging.StdlibFormatter(exclude_fields=["process", "tls.client"]) @@ -154,7 +154,7 @@ def g(): def h(): raise ValueError("error!") - stream = BytesIO() + stream = StringIO() handler = logging.StreamHandler(stream) handler.setFormatter(ecs_logging.StdlibFormatter(**kwargs)) logger.addHandler(handler) @@ -172,7 +172,7 @@ def h(): @pytest.mark.parametrize("stack_trace_limit", [0, False]) def test_stack_trace_limit_disabled(stack_trace_limit, logger): - stream = BytesIO() + stream = StringIO() handler = logging.StreamHandler(stream) handler.setFormatter( ecs_logging.StdlibFormatter(stack_trace_limit=stack_trace_limit) @@ -193,7 +193,7 @@ def test_stack_trace_limit_disabled(stack_trace_limit, logger): def test_exc_info_false_does_not_raise(logger): - stream = BytesIO() + stream = StringIO() handler = logging.StreamHandler(stream) handler.setFormatter(ecs_logging.StdlibFormatter()) logger.addHandler(handler) @@ -217,7 +217,7 @@ def g(): def h(): raise ValueError("error!") - stream = BytesIO() + stream = StringIO() handler = logging.StreamHandler(stream) handler.setFormatter(ecs_logging.StdlibFormatter(stack_trace_limit=2)) logger.addHandler(handler) @@ -308,7 +308,7 @@ def test_exclude_fields_type_and_values(): def test_stack_info(logger): - stream = BytesIO() + stream = StringIO() handler = logging.StreamHandler(stream) handler.setFormatter(ecs_logging.StdlibFormatter()) logger.addHandler(handler) @@ -324,7 +324,7 @@ def test_stack_info(logger): @pytest.mark.parametrize("exclude_fields", [["error"], ["error.stack_trace"]]) def test_stack_info_excluded(logger, exclude_fields): - stream = BytesIO() + stream = StringIO() handler = logging.StreamHandler(stream) handler.setFormatter(ecs_logging.StdlibFormatter(exclude_fields=exclude_fields)) logger.addHandler(handler) diff --git a/tests/test_structlog_formatter.py b/tests/test_structlog_formatter.py index 28d03b8..4d75138 100644 --- a/tests/test_structlog_formatter.py +++ b/tests/test_structlog_formatter.py @@ -18,7 +18,7 @@ import ecs_logging import structlog import mock -from io import BytesIO +from io import StringIO import pytest @@ -64,7 +64,7 @@ def test_event_dict_formatted(time, spec_validator): def test_can_be_set_as_processor(time, spec_validator): time.return_value = 1584720997.187709 - stream = BytesIO() + stream = StringIO() structlog.configure( processors=[ecs_logging.StructlogFormatter()], wrapper_class=structlog.BoundLogger, From b1749390def2bd6c1bb52f5c380250e0f7a196cc Mon Sep 17 00:00:00 2001 From: Colton Myers Date: Tue, 11 Jan 2022 11:09:10 -0700 Subject: [PATCH 5/5] flynt/pyupgrade changes --- ecs_logging/_stdlib.py | 2 +- ecs_logging/_utils.py | 19 +++++-------------- tests/conftest.py | 12 +++++------- tests/test_stdlib_formatter.py | 6 +++--- tests/test_structlog_formatter.py | 2 +- 5 files changed, 15 insertions(+), 26 deletions(-) diff --git a/ecs_logging/_stdlib.py b/ecs_logging/_stdlib.py index 7f4001f..c1254af 100644 --- a/ecs_logging/_stdlib.py +++ b/ecs_logging/_stdlib.py @@ -111,7 +111,7 @@ def __init__( if validate is not None: # validate was introduced in py3.8 so we need to only provide it if the user provided it _kwargs["validate"] = validate - super(StdlibFormatter, self).__init__( # type: ignore[call-arg] + super().__init__( # type: ignore[call-arg] fmt=fmt, datefmt=datefmt, style=style, **_kwargs ) diff --git a/ecs_logging/_utils.py b/ecs_logging/_utils.py index 244986f..be55e87 100644 --- a/ecs_logging/_utils.py +++ b/ecs_logging/_utils.py @@ -62,17 +62,15 @@ def flatten_dict(value): for key, val in value.items(): if not isinstance(val, collections_abc.Mapping): if key in top_level: - raise ValueError( - "Duplicate entry for '%s' with different nesting" % key - ) + raise ValueError(f"Duplicate entry for '{key}' with different nesting") top_level[key] = val else: val = flatten_dict(val) for vkey, vval in val.items(): - vkey = "%s.%s" % (key, vkey) + vkey = f"{key}.{vkey}" if vkey in top_level: raise ValueError( - "Duplicate entry for '%s' with different nesting" % vkey + f"Duplicate entry for '{vkey}' with different nesting" ) top_level[vkey] = vval @@ -163,16 +161,9 @@ def json_dumps(value): # Need to call json.dumps() on values just in # case the given values aren't strings (even though # they should be according to the spec) - ordered_json = ",".join( - '"%s":%s' - % ( - k, - json_dumps(v), - ) - for k, v in ordered_fields - ) + ordered_json = ",".join(f'"{k}":{json_dumps(v)}' for k, v in ordered_fields) if value: - return "{%s,%s" % ( + return "{{{},{}".format( ordered_json, json_dumps(value)[1:], ) diff --git a/tests/conftest.py b/tests/conftest.py index f9c7327..271668b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -32,9 +32,7 @@ class ValidationError(Exception): @pytest.fixture def spec_validator(): - with open( - os.path.join(os.path.dirname(__file__), "resources", "spec.json"), "r" - ) as fh: + with open(os.path.join(os.path.dirname(__file__), "resources", "spec.json")) as fh: spec = json.load(fh) def validator(data_json): @@ -59,11 +57,11 @@ def validator(data_json): if subval: found = True if not found: - raise ValidationError("Missing required key {}".format(k)) + raise ValidationError(f"Missing required key {k}") if k in data: if v["type"] == "string" and not isinstance(data[k], str): raise ValidationError( - "Value {0} for key {1} should be string, is {2}".format( + "Value {} for key {} should be string, is {}".format( data[k], k, type(data[k]) ) ) @@ -72,12 +70,12 @@ def validator(data_json): datetime.datetime.strptime(data[k], "%Y-%m-%dT%H:%M:%S.%fZ") except ValueError: raise ValidationError( - "Value {0} for key {1} doesn't parse as an ISO datetime".format( + "Value {} for key {} doesn't parse as an ISO datetime".format( data[k], k ) ) if v.get("index") and list(data.keys())[v.get("index")] != k: - raise ValidationError("Key {0} is not at index {1}".format(k, index)) + raise ValidationError(f"Key {k} is not at index {index}") return data_json diff --git a/tests/test_stdlib_formatter.py b/tests/test_stdlib_formatter.py index c33d04b..18cf555 100644 --- a/tests/test_stdlib_formatter.py +++ b/tests/test_stdlib_formatter.py @@ -17,7 +17,7 @@ import logging import logging.config -import mock +from unittest import mock import pytest import json import time @@ -29,7 +29,7 @@ @pytest.fixture(scope="function") def logger(): - return logging.getLogger("test-logger-%f-%f" % (time.time(), random.random())) + return logging.getLogger(f"test-logger-{time.time():f}-{random.random():f}") def make_record(): @@ -74,7 +74,7 @@ def test_extra_global_is_merged(spec_validator): def test_can_be_overridden(spec_validator): class CustomFormatter(ecs_logging.StdlibFormatter): def format_to_ecs(self, record): - ecs_dict = super(CustomFormatter, self).format_to_ecs(record) + ecs_dict = super().format_to_ecs(record) ecs_dict["custom"] = "field" return ecs_dict diff --git a/tests/test_structlog_formatter.py b/tests/test_structlog_formatter.py index 4d75138..75b6f22 100644 --- a/tests/test_structlog_formatter.py +++ b/tests/test_structlog_formatter.py @@ -17,7 +17,7 @@ import ecs_logging import structlog -import mock +from unittest import mock from io import StringIO import pytest