commit:     5e94a0f60ce9fb5ae3e1583954aa30be8d43a2f3
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon May 13 12:36:39 2024 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon May 13 12:37:58 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5e94a0f6

dev-python/tomlkit: Backport a py3.13 fix

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 .../tomlkit/files/tomlkit-0.12.5-py313.patch       | 71 ++++++++++++++++++++++
 dev-python/tomlkit/tomlkit-0.12.5-r1.ebuild        | 53 ++++++++++++++++
 2 files changed, 124 insertions(+)

diff --git a/dev-python/tomlkit/files/tomlkit-0.12.5-py313.patch 
b/dev-python/tomlkit/files/tomlkit-0.12.5-py313.patch
new file mode 100644
index 000000000000..bc6201d42101
--- /dev/null
+++ b/dev-python/tomlkit/files/tomlkit-0.12.5-py313.patch
@@ -0,0 +1,71 @@
+From 05d9be1c2b2a95a4eb3a53d999f1483dd7abae5a Mon Sep 17 00:00:00 2001
+From: Frost Ming <m...@frostming.com>
+Date: Mon, 13 May 2024 10:44:28 +0800
+Subject: [PATCH] fix: Test failures with Python 3.13.0a4:
+ test_dates_behave_like_dates and test_times_behave_like_times (#349)
+
+Fixes #333
+
+Signed-off-by: Frost Ming <m...@frostming.com>
+---
+ tests/test_items.py         |  4 ++--
+ tomlkit/items.py            | 15 ++++++++++-----
+ 4 files changed, 20 insertions(+), 8 deletions(-)
+
+diff --git a/tests/test_items.py b/tests/test_items.py
+index 1a71b04..3d2de68 100644
+--- a/tests/test_items.py
++++ b/tests/test_items.py
+@@ -689,7 +689,7 @@ def test_dates_behave_like_dates():
+     assert i.as_string() == "2018-07-22"
+ 
+     i += timedelta(days=1)
+-    assert i == datetime(2018, 7, 23)
++    assert i == date(2018, 7, 23)
+     assert i.as_string() == "2018-07-23"
+ 
+     i -= timedelta(days=2)
+@@ -697,7 +697,7 @@ def test_dates_behave_like_dates():
+     assert i.as_string() == "2018-07-21"
+ 
+     i = i.replace(year=2019)
+-    assert i == datetime(2019, 7, 21)
++    assert i == date(2019, 7, 21)
+     assert i.as_string() == "2019-07-21"
+ 
+     doc = parse("dt = 2018-07-22 # Comment")
+diff --git a/tomlkit/items.py b/tomlkit/items.py
+index ef40a15..661e09c 100644
+--- a/tomlkit/items.py
++++ b/tomlkit/items.py
+@@ -958,9 +958,14 @@ def __new__(cls, year: int, month: int, day: int, *_: 
Any) -> date:
+         return date.__new__(cls, year, month, day)
+ 
+     def __init__(
+-        self, year: int, month: int, day: int, trivia: Trivia, raw: str
++        self,
++        year: int,
++        month: int,
++        day: int,
++        trivia: Trivia | None = None,
++        raw: str = "",
+     ) -> None:
+-        super().__init__(trivia)
++        super().__init__(trivia or Trivia())
+ 
+         self._raw = raw
+ 
+@@ -1033,10 +1038,10 @@ def __init__(
+         second: int,
+         microsecond: int,
+         tzinfo: tzinfo | None,
+-        trivia: Trivia,
+-        raw: str,
++        trivia: Trivia | None = None,
++        raw: str = "",
+     ) -> None:
+-        super().__init__(trivia)
++        super().__init__(trivia or Trivia())
+ 
+         self._raw = raw
+ 

diff --git a/dev-python/tomlkit/tomlkit-0.12.5-r1.ebuild 
b/dev-python/tomlkit/tomlkit-0.12.5-r1.ebuild
new file mode 100644
index 000000000000..dfa4b710da13
--- /dev/null
+++ b/dev-python/tomlkit/tomlkit-0.12.5-r1.ebuild
@@ -0,0 +1,53 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DISTUTILS_USE_PEP517=flit
+PYTHON_COMPAT=( pypy3 python3_{10..13} )
+
+inherit distutils-r1 pypi
+
+DESCRIPTION="Style preserving TOML library"
+HOMEPAGE="
+       https://github.com/sdispater/tomlkit/
+       https://pypi.org/project/tomlkit/
+"
+
+LICENSE="MIT"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 
~riscv ~s390 ~sparc ~x86"
+
+BDEPEND="
+       test? (
+               dev-python/pyyaml[${PYTHON_USEDEP}]
+       )
+"
+
+distutils_enable_tests pytest
+
+PATCHES=(
+       # https://github.com/python-poetry/tomlkit/pull/349
+       "${FILESDIR}/${P}-py313.patch"
+)
+
+src_configure() {
+       grep -q 'build-backend = "poetry' pyproject.toml ||
+               die "Upstream changed build-backend, recheck"
+       # write a custom pyproject.toml to ease setuptools bootstrap
+       cat > pyproject.toml <<-EOF || die
+               [build-system]
+               requires = ["flit_core >=3.2,<4"]
+               build-backend = "flit_core.buildapi"
+
+               [project]
+               name = "tomlkit"
+               version = "${PV}"
+               description = "Style preserving TOML library"
+       EOF
+}
+
+python_test() {
+       local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
+       epytest
+}

Reply via email to