forked from pool/python-black
- Use libalternatives instead of update-alternatives
- Add upstream click-820.patch to make it work with latest python-click gh#psf/black#4577, gh#psf/black#4591, gh#psf/black#4666 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-black?expand=0&rev=70
This commit is contained in:
213
click-820.patch
Normal file
213
click-820.patch
Normal file
@@ -0,0 +1,213 @@
|
||||
From df50f6c30c696d4f9121e6cd8e885a05dce39360 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Mark=C3=A9ta=20Cal=C3=A1bkov=C3=A1?=
|
||||
<meggy.calabkova@gmail.com>
|
||||
Date: Fri, 7 Feb 2025 17:05:43 +0100
|
||||
Subject: [PATCH 1/4] mix_stderr parameter was removed from click 8.2.0
|
||||
|
||||
---
|
||||
tests/test_black.py | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/tests/test_black.py b/tests/test_black.py
|
||||
index 31bc34d4b89..8fa352e3d22 100644
|
||||
--- a/tests/test_black.py
|
||||
+++ b/tests/test_black.py
|
||||
@@ -114,7 +114,7 @@ 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)
|
||||
+ super().__init__()
|
||||
|
||||
|
||||
def invokeBlack(
|
||||
|
||||
From a65eb895e13263dc700cfbf60db0376e15957c4e Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Mark=C3=A9ta=20Cal=C3=A1bkov=C3=A1?=
|
||||
<meggy.calabkova@gmail.com>
|
||||
Date: Mon, 10 Feb 2025 11:12:17 +0100
|
||||
Subject: [PATCH 2/4] make the call conditional on click version
|
||||
|
||||
---
|
||||
tests/test_black.py | 7 ++++++-
|
||||
1 file changed, 6 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/tests/test_black.py b/tests/test_black.py
|
||||
index 8fa352e3d22..cbb5006d070 100644
|
||||
--- a/tests/test_black.py
|
||||
+++ b/tests/test_black.py
|
||||
@@ -14,6 +14,7 @@
|
||||
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
|
||||
@@ -26,6 +27,7 @@
|
||||
from click import unstyle
|
||||
from click.testing import CliRunner
|
||||
from pathspec import PathSpec
|
||||
+from packaging.version import Version
|
||||
|
||||
import black
|
||||
import black.files
|
||||
@@ -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__()
|
||||
+ if Version(imp_version('click')) >= Version('8.2.0'):
|
||||
+ super().__init__()
|
||||
+ else:
|
||||
+ super().__init__(mix_stderr=False)
|
||||
|
||||
|
||||
def invokeBlack(
|
||||
|
||||
From bdc188f550709e40b86f97777465e4068c61c261 Mon Sep 17 00:00:00 2001
|
||||
From: "pre-commit-ci[bot]"
|
||||
<66853113+pre-commit-ci[bot]@users.noreply.github.com>
|
||||
Date: Mon, 10 Feb 2025 11:02:28 +0000
|
||||
Subject: [PATCH 3/4] [pre-commit.ci] auto fixes from pre-commit.com hooks
|
||||
|
||||
for more information, see https://pre-commit.ci
|
||||
---
|
||||
tests/test_black.py | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/tests/test_black.py b/tests/test_black.py
|
||||
index cbb5006d070..9870cec4c26 100644
|
||||
--- a/tests/test_black.py
|
||||
+++ b/tests/test_black.py
|
||||
@@ -26,8 +26,8 @@
|
||||
import pytest
|
||||
from click import unstyle
|
||||
from click.testing import CliRunner
|
||||
-from pathspec import PathSpec
|
||||
from packaging.version import Version
|
||||
+from pathspec import PathSpec
|
||||
|
||||
import black
|
||||
import black.files
|
||||
|
||||
From 3dfacb5f34476b8c1ff28b5eb05cb85ff7418a66 Mon Sep 17 00:00:00 2001
|
||||
From: MeggyCal <MeggyCal@users.noreply.github.com>
|
||||
Date: Mon, 17 Feb 2025 12:01:26 +0100
|
||||
Subject: [PATCH 4/4] double quotes
|
||||
|
||||
---
|
||||
tests/test_black.py | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/tests/test_black.py b/tests/test_black.py
|
||||
index 9870cec4c26..4bdbdbba5cf 100644
|
||||
--- a/tests/test_black.py
|
||||
+++ b/tests/test_black.py
|
||||
@@ -116,7 +116,7 @@ class BlackRunner(CliRunner):
|
||||
"""Make sure STDOUT and STDERR are kept separate when testing Black via its CLI."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
- if Version(imp_version('click')) >= Version('8.2.0'):
|
||||
+ if Version(imp_version("click")) >= Version("8.2.0"):
|
||||
super().__init__()
|
||||
else:
|
||||
super().__init__(mix_stderr=False)
|
||||
|
||||
From 17101f151b407cb3346b0a472d9e32d7a56d5aca Mon Sep 17 00:00:00 2001
|
||||
From: "Michael R. Crusoe" <michael.crusoe@gmail.com>
|
||||
Date: Thu, 27 Feb 2025 15:17:21 +0100
|
||||
Subject: [PATCH] additional fix for click 8.2.0
|
||||
|
||||
---
|
||||
tests/test_black.py | 18 +++++++++---------
|
||||
1 file changed, 9 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/tests/test_black.py b/tests/test_black.py
|
||||
index 4bdbdbba5cf..ca19c17678b 100644
|
||||
--- a/tests/test_black.py
|
||||
+++ b/tests/test_black.py
|
||||
@@ -192,10 +192,10 @@ def test_piping(self) -> None:
|
||||
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(
|
||||
@@ -215,7 +215,7 @@ def test_piping_diff(self) -> None:
|
||||
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)
|
||||
|
||||
@@ -300,7 +300,7 @@ def test_expression_diff(self) -> None:
|
||||
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)
|
||||
@@ -409,7 +409,7 @@ def test_skip_magic_trailing_comma(self) -> None:
|
||||
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:
|
||||
@@ -1831,7 +1831,7 @@ def test_bpo_2142_workaround(self) -> None:
|
||||
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)
|
||||
|
||||
@@ -1841,7 +1841,7 @@ def compare_results(
|
||||
) -> 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."
|
||||
|
||||
|
||||
From 7cf419741ab55028519f43524c3414a759aaa984 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Garcia Moreno <daniel.garcia@suse.com>
|
||||
Date: Mon, 12 May 2025 13:49:11 +0200
|
||||
Subject: [PATCH] Update test_code_option_safe to work with click 8.2.0
|
||||
|
||||
---
|
||||
tests/test_black.py | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/tests/test_black.py b/tests/test_black.py
|
||||
index acafb521619..f5c950244ef 100644
|
||||
--- a/tests/test_black.py
|
||||
+++ b/tests/test_black.py
|
||||
@@ -1907,7 +1907,8 @@ def test_code_option_safe(self) -> None:
|
||||
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."""
|
||||
@@ -1,3 +1,11 @@
|
||||
-------------------------------------------------------------------
|
||||
Mon May 12 11:01:03 UTC 2025 - Daniel Garcia <daniel.garcia@suse.com>
|
||||
|
||||
- Use libalternatives instead of update-alternatives
|
||||
- Add upstream click-820.patch to make it work with latest
|
||||
python-click
|
||||
gh#psf/black#4577, gh#psf/black#4591, gh#psf/black#4666
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Feb 10 09:37:29 UTC 2025 - Nico Krapp <nico.krapp@suse.com>
|
||||
|
||||
|
||||
@@ -16,6 +16,12 @@
|
||||
#
|
||||
|
||||
|
||||
%if 0%{?suse_version} > 1500
|
||||
%bcond_without libalternatives
|
||||
%else
|
||||
%bcond_with libalternatives
|
||||
%endif
|
||||
|
||||
%{?sle15_python_module_pythons}
|
||||
Name: python-black
|
||||
Version: 25.1.0
|
||||
@@ -24,6 +30,8 @@ Summary: A code formatter written in, and written for Python
|
||||
License: MIT
|
||||
URL: https://github.com/psf/black
|
||||
Source: https://files.pythonhosted.org/packages/source/b/black/black-%{version}.tar.gz
|
||||
# PATCH-FIX-UPSTREAM click-820.patch gh#psf/black#4577, gh#psf/black#4591, gh#psf/black#4666
|
||||
Patch0: click-820.patch
|
||||
BuildRequires: %{python_module aiohttp >= 3.3.2}
|
||||
BuildRequires: %{python_module base >= 3.8}
|
||||
BuildRequires: %{python_module click >= 8.0.0}
|
||||
@@ -45,8 +53,14 @@ Requires: python-mypy_extensions >= 0.4.3
|
||||
Requires: python-packaging
|
||||
Requires: python-pathspec >= 0.9.0
|
||||
Requires: python-platformdirs >= 2
|
||||
|
||||
%if %{with libalternatives}
|
||||
BuildRequires: alts
|
||||
Requires: alts
|
||||
%else
|
||||
Requires(post): update-alternatives
|
||||
Requires(postun): update-alternatives
|
||||
%endif
|
||||
BuildArch: noarch
|
||||
%python_subpackages
|
||||
|
||||
@@ -75,7 +89,7 @@ also recognizes YAPF's block comments to the same effect.
|
||||
|
||||
%check
|
||||
# Copy one of the executable scripts into the PATH
|
||||
mkdir ~/bin
|
||||
mkdir -p ~/bin
|
||||
cp $(ls %{buildroot}%{_bindir}/black-* | head -1) ~/bin/black
|
||||
export PATH=$PATH:~/bin
|
||||
|
||||
@@ -84,6 +98,10 @@ export PATH=$PATH:~/bin
|
||||
skiptests="test_expression_diff or test_bpo_2142_workaround"
|
||||
%pytest -k "not ($skiptests)"
|
||||
|
||||
%pre
|
||||
# If libalternatives is used: Removing old update-alternatives entries.
|
||||
%python_libalternatives_reset_alternative black
|
||||
|
||||
%post
|
||||
%python_install_alternative black blackd
|
||||
|
||||
|
||||
Reference in New Issue
Block a user