From: Laurent Cheylus Subject: Re: [update] textproc/py-black 25.1.0 To: Stuart Henderson Cc: ports , daniel@openbsd.org Date: Fri, 6 Jun 2025 16:09:40 +0200 Hi Stuart, ----- Mail original ----- > On 2025/06/06 15:43, Laurent Cheylus wrote: > > @@ -0,0 +1,106 @@ > > +Fix tests with click >= 8.2.0 > > +- https://github.com/psf/black/pull/4577 > > +- https://github.com/psf/black/pull/4591 > > +- https://github.com/psf/black/pull/4666 > > please refer to the upstream commits rather than PRs so that it's > clear whether they are likely to apply directly to a future update or not > (and also that will indicate whether upstream thought the PR was good to > merge). > > personally I would do it like this i.e. copy the header from the git > patches, but something else that ends up with similar info would work > too OK, new version of my diff with patch headers as you proposed (refs to commit instead of PR). regards, Laurent Index: Makefile =================================================================== RCS file: /cvs/ports/textproc/py-black/Makefile,v diff -u -p -r1.29 Makefile --- Makefile 21 Dec 2024 11:39:01 -0000 1.29 +++ Makefile 6 Jun 2025 14:08:39 -0000 @@ -1,9 +1,8 @@ COMMENT= Python code formatter -MODPY_DISTV= 24.4.2 +MODPY_DISTV= 25.1.0 DISTNAME= black-${MODPY_DISTV} PKGNAME= py-black-${MODPY_DISTV:S/b/beta/} -REVISION= 0 CATEGORIES= textproc devel Index: distinfo =================================================================== RCS file: /cvs/ports/textproc/py-black/distinfo,v diff -u -p -r1.11 distinfo --- distinfo 18 Jun 2024 00:24:20 -0000 1.11 +++ distinfo 6 Jun 2025 14:08:39 -0000 @@ -1,2 +1,2 @@ -SHA256 (black-24.4.2.tar.gz) = yHK1MFfwAAhdpmoZxV1o9vjdysJkI5KtOjVYeEBvvU0= -SIZE (black-24.4.2.tar.gz) = 642299 +SHA256 (black-25.1.0.tar.gz) = M0ltXNEiKtczkTUrSujaFSU8Xeibk6gLPiyNmhnsJmY= +SIZE (black-25.1.0.tar.gz) = 649449 Index: patches/patch-tests_test_black_py =================================================================== RCS file: patches/patch-tests_test_black_py diff -N patches/patch-tests_test_black_py --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-tests_test_black_py 6 Jun 2025 14:08:39 -0000 @@ -0,0 +1,120 @@ +Fix tests with click >= 8.2.0 + +3 commits from upstream: + +From 14e1de805a5d66744a08742cad32d1660bf7617a Mon Sep 17 00:00:00 2001 +From: MeggyCal +Date: Tue, 18 Feb 2025 16:30:11 +0100 +Subject: [PATCH] mix_stderr parameter was removed from click 8.2.0 (#4577) + +From ed64d89faa7c738c4ba0006710f7e387174478af Mon Sep 17 00:00:00 2001 +From: "Michael R. Crusoe" <1330696+mr-c@users.noreply.github.com> +Date: Thu, 27 Feb 2025 17:46:59 +0100 +Subject: [PATCH] additional fix for click 8.2.0 (#4591) + +From b0f36f5b4233ef4cf613daca0adc3896d5424159 Mon Sep 17 00:00:00 2001 +From: danigm +Date: Thu, 15 May 2025 14:04:00 +0200 +Subject: [PATCH] Update test_code_option_safe to work with click 8.2.0 (#4666) + +Index: tests/test_black.py +--- tests/test_black.py.orig ++++ tests/test_black.py +@@ -14,6 +14,7 @@ from collections.abc import Callable, Iterator, Sequen + from concurrent.futures import ThreadPoolExecutor + from contextlib import contextmanager, redirect_stderr + from dataclasses import fields, replace ++from importlib.metadata import version as imp_version + from io import BytesIO + from pathlib import Path, WindowsPath + from platform import system +@@ -25,6 +26,7 @@ import click + import pytest + from click import unstyle + from click.testing import CliRunner ++from packaging.version import Version + from pathspec import PathSpec + + import black +@@ -114,7 +116,10 @@ class BlackRunner(CliRunner): + """Make sure STDOUT and STDERR are kept separate when testing Black via its CLI.""" + + def __init__(self) -> None: +- super().__init__(mix_stderr=False) ++ if Version(imp_version("click")) >= Version("8.2.0"): ++ super().__init__() ++ else: ++ super().__init__(mix_stderr=False) + + + def invokeBlack( +@@ -187,10 +192,10 @@ class BlackTestCase(BlackBaseTestCase): + input=BytesIO(source.encode("utf-8")), + ) + self.assertEqual(result.exit_code, 0) +- self.assertFormatEqual(expected, result.output) +- if source != result.output: +- black.assert_equivalent(source, result.output) +- black.assert_stable(source, result.output, DEFAULT_MODE) ++ self.assertFormatEqual(expected, result.stdout) ++ if source != result.stdout: ++ black.assert_equivalent(source, result.stdout) ++ black.assert_stable(source, result.stdout, DEFAULT_MODE) + + def test_piping_diff(self) -> None: + diff_header = re.compile( +@@ -210,7 +215,7 @@ class BlackTestCase(BlackBaseTestCase): + black.main, args, input=BytesIO(source.encode("utf-8")) + ) + self.assertEqual(result.exit_code, 0) +- actual = diff_header.sub(DETERMINISTIC_HEADER, result.output) ++ actual = diff_header.sub(DETERMINISTIC_HEADER, result.stdout) + actual = actual.rstrip() + "\n" # the diff output has a trailing space + self.assertEqual(expected, actual) + +@@ -295,7 +300,7 @@ class BlackTestCase(BlackBaseTestCase): + self.assertEqual(result.exit_code, 0) + finally: + os.unlink(tmp_file) +- actual = result.output ++ actual = result.stdout + actual = diff_header.sub(DETERMINISTIC_HEADER, actual) + if expected != actual: + dump = black.dump_to_file(actual) +@@ -404,7 +409,7 @@ class BlackTestCase(BlackBaseTestCase): + self.assertEqual(result.exit_code, 0) + finally: + os.unlink(tmp_file) +- actual = result.output ++ actual = result.stdout + actual = diff_header.sub(DETERMINISTIC_HEADER, actual) + actual = actual.rstrip() + "\n" # the diff output has a trailing space + if expected != actual: +@@ -1826,7 +1831,7 @@ class BlackTestCase(BlackBaseTestCase): + self.assertEqual(result.exit_code, 0) + finally: + os.unlink(tmp_file) +- actual = result.output ++ actual = result.stdout + actual = diff_header.sub(DETERMINISTIC_HEADER, actual) + self.assertEqual(actual, expected) + +@@ -1836,7 +1841,7 @@ class BlackTestCase(BlackBaseTestCase): + ) -> None: + """Helper method to test the value and exit code of a click Result.""" + assert ( +- result.output == expected_value ++ result.stdout == expected_value + ), "The output did not match the expected value." + assert result.exit_code == expected_exit_code, "The exit code is incorrect." + +@@ -1913,7 +1918,8 @@ class BlackTestCase(BlackBaseTestCase): + args = ["--safe", "--code", code] + result = CliRunner().invoke(black.main, args) + +- self.compare_results(result, error_msg, 123) ++ assert error_msg == result.output ++ assert result.exit_code == 123 + + def test_code_option_fast(self) -> None: + """Test that the code option ignores errors when the sanity checks fail."""