commit:     9c0fb575adfcff7bdb2f80c0bae77368d1a1d483
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 12 07:01:28 2024 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jul 12 07:33:00 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9c0fb575

dev-python/argh: Enable py3.13

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

 dev-python/argh/argh-0.31.2.ebuild            |   8 +-
 dev-python/argh/files/argh-0.31.2-py313.patch | 164 ++++++++++++++++++++++++++
 2 files changed, 170 insertions(+), 2 deletions(-)

diff --git a/dev-python/argh/argh-0.31.2.ebuild 
b/dev-python/argh/argh-0.31.2.ebuild
index fb61d011ee2d..0c53e95bef20 100644
--- a/dev-python/argh/argh-0.31.2.ebuild
+++ b/dev-python/argh/argh-0.31.2.ebuild
@@ -4,8 +4,7 @@
 EAPI=8
 
 DISTUTILS_USE_PEP517=flit
-# py3.13: https://github.com/neithere/argh/issues/228
-PYTHON_COMPAT=( python3_{10..12} pypy3 )
+PYTHON_COMPAT=( python3_{10..13} pypy3 )
 
 inherit distutils-r1 pypi
 
@@ -27,3 +26,8 @@ BDEPEND="
 "
 
 distutils_enable_tests pytest
+
+PATCHES=(
+       # 
https://github.com/neithere/argh/commit/cdb70d5ac7d8a5a5dff3c55100e5f67b68b26826
+       "${FILESDIR}/${P}-py313.patch"
+)

diff --git a/dev-python/argh/files/argh-0.31.2-py313.patch 
b/dev-python/argh/files/argh-0.31.2-py313.patch
new file mode 100644
index 000000000000..4049fedc0d0d
--- /dev/null
+++ b/dev-python/argh/files/argh-0.31.2-py313.patch
@@ -0,0 +1,164 @@
+From cdb70d5ac7d8a5a5dff3c55100e5f67b68b26826 Mon Sep 17 00:00:00 2001
+From: Andy Mikhaylenko <[email protected]>
+Date: Sun, 16 Jun 2024 22:38:21 +0200
+Subject: [PATCH] fix: tests under Python 3.13 (fixes #228)
+
+diff --git a/tests/test_integration.py b/tests/test_integration.py
+index f863386..258a148 100644
+--- a/tests/test_integration.py
++++ b/tests/test_integration.py
+@@ -724,18 +724,34 @@ def remind(
+     help_normalised = re.sub(r"\s+", " ", parser.format_help())
+ 
+     assert "name 'Basil'" in help_normalised
+-    assert "-t TASK, --task TASK 'hang the Moose'" in help_normalised
+-    assert (
+-        "-r REASON, --reason REASON 'there are creatures living in it'"
+-        in help_normalised
+-    )
+ 
+-    # explicit help message is not obscured by the implicit one
+-    # but is still present
+-    assert (
+-        "-n NOTE, --note NOTE why is it a remarkable animal? "
+-        "(default: 'it can speak English')"
+-    ) in help_normalised
++    # argh#228 — argparse in Python before 3.13 duplicated the placeholder in 
help
++    if sys.version_info < (3, 13):
++        assert "-t TASK, --task TASK 'hang the Moose'" in help_normalised
++        assert (
++            "-r REASON, --reason REASON 'there are creatures living in it'"
++            in help_normalised
++        )
++
++        # explicit help message is not obscured by the implicit one
++        # but is still present
++        assert (
++            "-n NOTE, --note NOTE why is it a remarkable animal? "
++            "(default: 'it can speak English')"
++        ) in help_normalised
++    else:
++        assert "-t, --task TASK 'hang the Moose'" in help_normalised
++        assert (
++            "-r, --reason REASON 'there are creatures living in it'"
++            in help_normalised
++        )
++
++        # explicit help message is not obscured by the implicit one
++        # but is still present
++        assert (
++            "-n, --note NOTE why is it a remarkable animal? "
++            "(default: 'it can speak English')"
++        ) in help_normalised
+ 
+ 
+ def test_default_arg_values_in_help__regression():
+@@ -750,9 +766,16 @@ def foo(*, bar=""):
+     # doesn't break
+     parser.format_help()
+ 
++    # argh#228 — argparse in Python before 3.13 duplicated the placeholder in 
help
++    if sys.version_info < (3, 13):
++        expected_line = "-b BAR, --bar BAR  ''"
++        # note the empty str repr         ^^^
++    else:
++        expected_line = "-b, --bar BAR  ''"
++        # note the empty str repr     ^^^
++
+     # now check details
+-    assert "-b BAR, --bar BAR  ''" in parser.format_help()
+-    # note the empty str repr ^^^
++    assert expected_line in parser.format_help()
+ 
+ 
+ def test_help_formatting_is_preserved():
+@@ -868,6 +891,19 @@ def second_func():
+ 
+     run(parser, "first-func --help", exit=True)
+     captured = capsys.readouterr()
++
++    # argh#228 — argparse in Python before 3.13 duplicated the placeholder in 
help
++    if sys.version_info < (3, 13):
++        arg_help_lines = (
++            "  -h, --help         show this help message and exit\n"
++            "  -f FOO, --foo FOO  123"
++        )
++    else:
++        arg_help_lines = (
++            "  -h, --help     show this help message and exit\n"
++            "  -f, --foo FOO  123"
++        )
++
+     assert (
+         captured.out
+         == unindent(
+@@ -877,8 +913,7 @@ def second_func():
+         Owl stretching time
+ 
+         {HELP_OPTIONS_LABEL}:
+-          -h, --help         show this help message and exit
+-          -f FOO, --foo FOO  123
++        {arg_help_lines}
+         """
+         )[1:]
+     )
+@@ -997,6 +1032,19 @@ def second_func():
+ 
+     run(parser, "my-group first-func --help", exit=True)
+     captured = capsys.readouterr()
++
++    # argh#228 — argparse in Python before 3.13 duplicated the placeholder in 
help
++    if sys.version_info < (3, 13):
++        arg_help_lines = (
++            "  -h, --help         show this help message and exit\n"
++            "  -f FOO, --foo FOO  123"
++        )
++    else:
++        arg_help_lines = (
++            "  -h, --help     show this help message and exit\n"
++            "  -f, --foo FOO  123"
++        )
++
+     assert (
+         captured.out
+         == unindent(
+@@ -1006,8 +1054,7 @@ def second_func():
+         Owl stretching time
+ 
+         {HELP_OPTIONS_LABEL}:
+-          -h, --help         show this help message and exit
+-          -f FOO, --foo FOO  123
++        {arg_help_lines}
+         """
+         )[1:]
+     )
+@@ -1079,6 +1126,19 @@ def second_func():
+ 
+     run(parser, "first-func --help", exit=True)
+     captured = capsys.readouterr()
++
++    # argh#228 — argparse in Python before 3.13 duplicated the placeholder in 
help
++    if sys.version_info < (3, 13):
++        arg_help_lines = (
++            "  -h, --help         show this help message and exit\n"
++            "  -f FOO, --foo FOO  123"
++        )
++    else:
++        arg_help_lines = (
++            "  -h, --help     show this help message and exit\n"
++            "  -f, --foo FOO  123"
++        )
++
+     assert (
+         captured.out
+         == unindent(
+@@ -1088,8 +1148,7 @@ def second_func():
+         func description override
+ 
+         {HELP_OPTIONS_LABEL}:
+-          -h, --help         show this help message and exit
+-          -f FOO, --foo FOO  123
++        {arg_help_lines}
+         """
+         )[1:]
+     )

Reply via email to