Index | Thread | Search

From:
Laurent Cheylus <foxy@free.fr>
Subject:
[update] textproc/py-black 25.1.0
To:
ports <ports@openbsd.org>
Cc:
daniel@openbsd.org
Date:
Fri, 6 Jun 2025 15:43:41 +0200

Download raw body.

Thread
Hi ports@

[cc daniel@ as maintener]

update for textproc/py-black to the latest version 25.1.0
Changelog: https://github.com/psf/black/releases/tag/25.1.0

- update Makefile and distinfo for this version
- add a patch to fix tests with click >= 8.2.0

Build and tests OK on current/amd64 with Python 3.12.10

Tests welcome and please commit if OK.

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 10:32:55 -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 10:32:55 -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 10:32:55 -0000
@@ -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
+
+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."""