public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/python-lsp-black] rawhide: Fix compatibility with black≥26.5 (fixes RHBZ#2485891)
@ 2026-07-15 10:37 Benjamin A. Beasley
  0 siblings, 0 replies; only message in thread
From: Benjamin A. Beasley @ 2026-07-15 10:37 UTC (permalink / raw)
  To: git-commits

A new commit has been pushed.

Repo   : rpms/python-lsp-black
Branch : rawhide
Commit : 74751dc9abc5d2cef504a2fc57cf6c0693ef4348
Author : Benjamin A. Beasley <code@musicinmybrain.net>
Date   : 2026-07-14T14:32:03+01:00
Stats  : +58/-0 in 2 file(s)
URL    : https://src.fedoraproject.org/rpms/python-lsp-black/c/74751dc9abc5d2cef504a2fc57cf6c0693ef4348?branch=rawhide

Log:
Fix compatibility with black≥26.5 (fixes RHBZ#2485891)

---
diff --git a/65.patch b/65.patch
new file mode 100644
index 0000000..55d31ad
--- /dev/null
+++ b/65.patch
@@ -0,0 +1,55 @@
+From 35b5bc6f944bddac0c896127dc44a9404e95f482 Mon Sep 17 00:00:00 2001
+From: "Benjamin A. Beasley" <code@musicinmybrain.net>
+Date: Tue, 14 Jul 2026 11:17:27 +0100
+Subject: [PATCH] =?UTF-8?q?Fix=20compatibility=20with=20black=E2=89=A526.5?=
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+---
+ pylsp_black/plugin.py | 25 ++++++++++++++++---------
+ 1 file changed, 16 insertions(+), 9 deletions(-)
+
+diff --git a/pylsp_black/plugin.py b/pylsp_black/plugin.py
+index 5523896..a6751bb 100644
+--- a/pylsp_black/plugin.py
++++ b/pylsp_black/plugin.py
+@@ -100,6 +100,21 @@ def format_text(*, text, config, lines):
+         magic_trailing_comma=not config["skip_magic_trailing_comma"],
+         preview=config["preview"],
+     )
++    handled_errors = (
++        # raised when the file has syntax errors
++        ValueError,
++        # raised when the file being formatted has an indentation error
++        IndentationError,
++        # raised when black produces invalid Python code or formats the file
++        # differently on the second pass
++        black.parsing.ASTSafetyError,
++    )
++    # SourceASTParseError was split out from ASTSafetyError in black 26.5.0,
++    # https://github.com/psf/black/pull/5080; expect it if it exists.
++    try:
++        handled_errors += (black.parsing.SourceASTParseError,)
++    except AttributeError:
++        pass
+     try:
+         # Black's format_file_contents only works reliably when eols are '\n'. It gives
+         # an error for '\r' and produces wrong formatting for '\r\n'. So we replace
+@@ -120,15 +135,7 @@ def format_text(*, text, config, lines):
+             formatted_text = formatted_text.replace("\n", eol_chars)
+ 
+         return formatted_text
+-    except (
+-        # raised when the file has syntax errors
+-        ValueError,
+-        # raised when the file being formatted has an indentation error
+-        IndentationError,
+-        # raised when black produces invalid Python code or formats the file
+-        # differently on the second pass
+-        black.parsing.ASTSafetyError,
+-    ) as e:
++    except handled_errors as e:
+         # errors will show on lsp stderr stream
+         logger.error("Error formatting with black: %s", e)
+         raise black.NothingChanged from e

diff --git a/python-lsp-black.spec b/python-lsp-black.spec
index 6d6b5c1..a66f422 100644
--- a/python-lsp-black.spec
+++ b/python-lsp-black.spec
@@ -28,6 +28,9 @@ Patch:          %{forgeurl}/pull/56.patch
 # https://github.com/python-lsp/python-lsp-black/pull/64
 # Fixes compatibility with setuptools≥82.
 Patch:          %{forgeurl}/pull/64.patch
+# Fix compatibility with black≥26.5
+# https://github.com/python-lsp/python-lsp-black/pull/65
+Patch:          %{forgeurl}/pull/65.patch
 
 BuildArch:      noarch
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-07-15 10:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-15 10:37 [rpms/python-lsp-black] rawhide: Fix compatibility with black≥26.5 (fixes RHBZ#2485891) Benjamin A. Beasley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox