From 37510db8de4dc711852304339ec883a37a4710ea Mon Sep 17 00:00:00 2001 From: Joel Capitao Date: Tue, 18 Jul 2023 11:48:28 +0200 Subject: [PATCH 1/4] Add support of Python 3.12 --- .github/workflows/ci.yaml | 3 ++- .mergify.yml | 2 ++ setup.cfg | 1 + tox.ini | 4 ++-- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b685da9..f446ac7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,7 +10,7 @@ jobs: test: strategy: matrix: - python: ["3.8", "3.9", "3.10", "3.11"] + python: ["3.8", "3.9", "3.10", "3.11", "3.12"] runs-on: ubuntu-22.04 steps: @@ -21,6 +21,7 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{ matrix.python }} + allow-prereleases: true - name: Install tox run: pip install tox diff --git a/.mergify.yml b/.mergify.yml index 8accd90..facbb84 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -20,9 +20,11 @@ queue_rules: - "check-success=test (3.9)" - "check-success=test (3.10)" - "check-success=test (3.11)" + - "check-success=test (3.12)" merge_conditions: - "check-success=pep8" - "check-success=test (3.8)" - "check-success=test (3.9)" - "check-success=test (3.10)" - "check-success=test (3.11)" + - "check-success=test (3.12)" diff --git a/setup.cfg b/setup.cfg index bad2ffa..176d6b6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -18,6 +18,7 @@ classifier = Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3.12 [options] install_requires = diff --git a/tox.ini b/tox.ini index c58cef7..e003101 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py38,py39,py310,py311,pep8,docs +envlist = py38,py39,py310,py311,py312,pep8,docs [testenv] allowlist_externals = sh @@ -10,7 +10,7 @@ commands = sh -c "rm errors.log everything.log" [testenv:pep8] -basepython = python3.10 +basepython = python3.11 deps = {[testenv]deps} black From 070fdb90b883aa83086bba1d8d06f1c6499d29d3 Mon Sep 17 00:00:00 2001 From: Joel Capitao Date: Tue, 18 Jul 2023 13:11:08 +0200 Subject: [PATCH 2/4] Adjust tests for taskName attribute added in Python 3.12 gh-91513: Added taskName attribute to logging module for use with asyncio tasks. python/cpython#91513 [1] credits to https://github.com/hrnciar [1] https://github.com/python/cpython/issues/91513 --- daiquiri/tests/test_daiquiri.py | 16 +++++--- daiquiri/tests/test_output.py | 68 ++++++++++++++++----------------- 2 files changed, 43 insertions(+), 41 deletions(-) diff --git a/daiquiri/tests/test_daiquiri.py b/daiquiri/tests/test_daiquiri.py index 3c4e850..62b6863 100644 --- a/daiquiri/tests/test_daiquiri.py +++ b/daiquiri/tests/test_daiquiri.py @@ -12,6 +12,8 @@ import io import json import logging +import sys +import typing import unittest import warnings @@ -39,7 +41,10 @@ def test_setup_json_formatter(self) -> None: ) ) daiquiri.getLogger(__name__).warning("foobar") - self.assertEqual({"message": "foobar"}, json.loads(stream.getvalue())) + expected: dict[str, typing.Any] = {"message": "foobar"} + if sys.version_info >= (3, 12): + expected.update({"taskName": None}) + self.assertEqual(expected, json.loads(stream.getvalue())) def test_setup_json_formatter_with_extras(self) -> None: stream = io.StringIO() @@ -51,9 +56,10 @@ def test_setup_json_formatter_with_extras(self) -> None: ) ) daiquiri.getLogger(__name__).warning("foobar", foo="bar") - self.assertEqual( - {"message": "foobar", "foo": "bar"}, json.loads(stream.getvalue()) - ) + expected: dict[str, typing.Any] = {"message": "foobar", "foo": "bar"} + if sys.version_info >= (3, 12): + expected.update({"taskName": None}) + self.assertEqual(expected, json.loads(stream.getvalue())) def test_get_logger_set_level(self) -> None: logger = daiquiri.getLogger(__name__) @@ -66,7 +72,7 @@ def test_capture_warnings(self) -> None: line = stream.getvalue() self.assertIn("WARNING py.warnings: ", line) self.assertIn( - "daiquiri/tests/test_daiquiri.py:65: " + "daiquiri/tests/test_daiquiri.py:71: " 'UserWarning: omg!\n warnings.warn("omg!")\n', line, ) diff --git a/daiquiri/tests/test_output.py b/daiquiri/tests/test_output.py index 1d75aef..8c76cfe 100644 --- a/daiquiri/tests/test_output.py +++ b/daiquiri/tests/test_output.py @@ -11,6 +11,7 @@ # under the License. import json import logging +import sys import syslog import typing import unittest @@ -100,6 +101,34 @@ def test_datadog(self) -> None: logger = daiquiri.getLogger() logger.error("foo", bar=1) logger.info("bar") + expected_error_1 = { + "status": "error", + "message": "foo", + "bar": 1, + "logger": {"name": "root"}, + "timestamp": mock.ANY, + } + expected_info_1 = { + "status": "info", + "message": "bar", + "logger": {"name": "root"}, + "timestamp": mock.ANY, + } + expected_error_2 = { + "status": "error", + "message": "backtrace", + "logger": {"name": "saymyname"}, + "timestamp": mock.ANY, + "error": { + "kind": "ZeroDivisionError", + "stack": None, + "message": mock.ANY, + }, + } + if sys.version_info >= (3, 12): + expected_error_1.update({"taskName": None}) + expected_info_1.update({"taskName": None}) + expected_error_2.update({"taskName": None}) try: 1 / 0 except ZeroDivisionError: @@ -108,41 +137,8 @@ def test_datadog(self) -> None: socket_instance.connect.assert_called_once_with(("127.0.0.1", 10518)) socket_instance.sendall.assert_has_calls( [ - mock.call( - DatadogMatcher( - { - "status": "error", - "message": "foo", - "bar": 1, - "logger": {"name": "root"}, - "timestamp": mock.ANY, - } - ) - ), - mock.call( - DatadogMatcher( - { - "status": "info", - "message": "bar", - "logger": {"name": "root"}, - "timestamp": mock.ANY, - } - ) - ), - mock.call( - DatadogMatcher( - { - "status": "error", - "message": "backtrace", - "logger": {"name": "saymyname"}, - "timestamp": mock.ANY, - "error": { - "kind": "ZeroDivisionError", - "stack": None, - "message": mock.ANY, - }, - } - ) - ), + mock.call(DatadogMatcher(expected_error_1)), + mock.call(DatadogMatcher(expected_info_1)), + mock.call(DatadogMatcher(expected_error_2)), ] ) From 66b7dea8810e15d6e2fd8138940fc3fefdb462c8 Mon Sep 17 00:00:00 2001 From: Mehdi ABAAKOUK Date: Thu, 19 Oct 2023 07:18:12 +0200 Subject: [PATCH 3/4] Update .github/workflows/ci.yaml --- .github/workflows/ci.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f446ac7..d8740b8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -21,7 +21,6 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{ matrix.python }} - allow-prereleases: true - name: Install tox run: pip install tox From 397ef7fdaad97f2551356d905ffe4676e0ee36ee Mon Sep 17 00:00:00 2001 From: Mehdi ABAAKOUK Date: Thu, 19 Oct 2023 07:21:36 +0200 Subject: [PATCH 4/4] Update tox.ini --- .github/workflows/ci.yaml | 2 +- tox.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d8740b8..792f190 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -37,7 +37,7 @@ jobs: - name: Setup Python 🔧 uses: actions/setup-python@v4 with: - python-version: "3.11" + python-version: "3.12" - name: Install tox run: pip install tox diff --git a/tox.ini b/tox.ini index e003101..fc7b108 100644 --- a/tox.ini +++ b/tox.ini @@ -10,7 +10,7 @@ commands = sh -c "rm errors.log everything.log" [testenv:pep8] -basepython = python3.11 +basepython = python3.12 deps = {[testenv]deps} black