15
0

Accepting request 1318159 from devel:languages:python

OBS-URL: https://build.opensuse.org/request/show/1318159
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-docformatter?expand=0&rev=12
This commit is contained in:
2025-11-17 11:19:58 +00:00
committed by Git OBS Bridge
3 changed files with 40 additions and 1 deletions

32
ignore-utf16.patch Normal file
View File

@@ -0,0 +1,32 @@
From 412479e5d6b02f7dd7e20f870132a413dc83898a Mon Sep 17 00:00:00 2001
From: Doyle Rowland <doyle.rowland@reliaqual.com>
Date: Thu, 14 Aug 2025 17:58:02 -0400
Subject: [PATCH] fix: explicitly ignore utf_16 and utf_32 encoding
---
src/docformatter/encode.py | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/docformatter/encode.py b/src/docformatter/encode.py
index ac55ee9..c7e36f0 100644
--- a/src/docformatter/encode.py
+++ b/src/docformatter/encode.py
@@ -64,9 +64,15 @@ def do_detect_encoding(self, filename) -> None:
"""
try:
detection_result = from_path(filename).best()
- self.encoding = (
- detection_result.encoding if detection_result else self.DEFAULT_ENCODING
- )
+ if detection_result and detection_result.encoding in ["utf_16", "utf_32"]:
+ # Treat undetectable/binary encodings as failure
+ self.encoding = self.DEFAULT_ENCODING
+ else:
+ self.encoding = (
+ detection_result.encoding
+ if detection_result
+ else self.DEFAULT_ENCODING
+ )
# Check for correctness of encoding.
with self.do_open_with_encoding(filename) as check_file:

View File

@@ -1,3 +1,8 @@
-------------------------------------------------------------------
Fri Nov 14 13:51:14 UTC 2025 - Markéta Machová <mmachova@suse.com>
- Add upstream ignore-utf16.patch to fix test failure
-------------------------------------------------------------------
Mon May 19 10:01:24 UTC 2025 - John Paul Adrian Glaubitz <adrian.glaubitz@suse.com>

View File

@@ -1,7 +1,7 @@
#
# spec file for package python-docformatter
#
# Copyright (c) 2025 SUSE LLC
# Copyright (c) 2025 SUSE LLC and contributors
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -26,6 +26,8 @@ URL: https://github.com/myint/docformatter
Source: https://github.com/PyCQA/docformatter/archive/refs/tags/v%{version}.tar.gz#/docformatter-%{version}.tar.gz
# PATCH-FIX-OPENSUSE Do not require virtualenvs to run the tests
Patch0: do-not-require-venv.patch
# PATCH-FIX-UPSTREAM cherry-pick from https://github.com/PyCQA/docformatter/pull/323 fix: issue 321
Patch1: ignore-utf16.patch
BuildRequires: %{python_module base >= 3.7}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module poetry-core}