Bug#1092802: skorch: diff for NMU version 1.0.0-1.1
Control: tags 1092802 + patch
Control: tags 1092802 + pending
--
Dear maintainer,
I've prepared an NMU for skorch (versioned as 1.0.0-1.1) and
uploaded it to DELAYED/7. Please feel free to tell me if I
should delay it longer.
--
Regards
Sudip
diff -Nru skorch-1.0.0/debian/changelog skorch-1.0.0/debian/changelog
--- skorch-1.0.0/debian/changelog 2024-10-26 00:54:42.000000000 +0100
+++ skorch-1.0.0/debian/changelog 2025-01-25 12:34:20.000000000 +0000
@@ -1,3 +1,11 @@
+skorch (1.0.0-1.1) unstable; urgency=medium
+
+ * Non-maintainer upload.
+ * d/p/fix-docstring.patch: Apply upstream patch to fix autopkgtest
+ regression due to docstring parsing issue in Python 3.13. (Closes: #1092802)
+
+ -- Sudip Mukherjee <sudipm.mukherjee@gmail.com> Sat, 25 Jan 2025 12:34:20 +0000
+
skorch (1.0.0-1) unstable; urgency=medium
* New upstream version 1.0.0
diff -Nru skorch-1.0.0/debian/patches/fix-docstring.patch skorch-1.0.0/debian/patches/fix-docstring.patch
--- skorch-1.0.0/debian/patches/fix-docstring.patch 1970-01-01 01:00:00.000000000 +0100
+++ skorch-1.0.0/debian/patches/fix-docstring.patch 2025-01-25 12:34:20.000000000 +0000
@@ -0,0 +1,96 @@
+Description: Fix docstring parsing issue in Python 3.13
+ Python 3.13 auto dedents docstrings, breaking the parsing.
+ With this fix, parsing works the same as before.
+
+Origin: upstream, https://github.com/skorch-dev/skorch/commit/bb1bac4945ab7f50887f9f7e43f9b2515f9959a6
+Bug: https://github.com/skorch-dev/skorch/issues/1080
+Bug-Debian: https://bugs.debian.org/1092802
+Last-Update: 2025-01-25
+---
+
+--- skorch-1.0.0.orig/skorch/classifier.py
++++ skorch-1.0.0/skorch/classifier.py
+@@ -1,6 +1,7 @@
+ """NeuralNet subclasses for classification tasks."""
+
+ import re
++import textwrap
+
+ import numpy as np
+ from sklearn.base import ClassifierMixin
+@@ -35,21 +36,23 @@ neural_net_clf_additional_text = """
+ skorch behavior should be restored, i.e. raising an
+ ``AttributeError``, pass an empty list."""
+
+-neural_net_clf_additional_attribute = """classes_ : array, shape (n_classes, )
++neural_net_clf_additional_attribute = """ classes_ : array, shape (n_classes, )
+ A list of class labels known to the classifier.
+
+ """
+
+-
+ def get_neural_net_clf_doc(doc):
+- doc = neural_net_clf_doc_start + " " + doc.split("\n ", 4)[-1]
+- pattern = re.compile(r'(\n\s+)(criterion .*\n)(\s.+){1,99}')
++ indentation = " "
++ # dedent/indent roundtrip required for consistent indention in both
++ # Python <3.13 and Python >=3.13
++ # Because <3.13 => not automatic dedent, but it is the case in >=3.13
++ doc = neural_net_clf_doc_start + " " + textwrap.indent(textwrap.dedent(doc.split("\n", 5)[-1]), indentation)
++ pattern = re.compile(r'(\n\s+)(criterion .*\n)(\s.+|.){1,99}')
+ start, end = pattern.search(doc).span()
+ doc = doc[:start] + neural_net_clf_additional_text + doc[end:]
+ doc = doc + neural_net_clf_additional_attribute
+ return doc
+
+-
+ # pylint: disable=missing-docstring
+ class NeuralNetClassifier(NeuralNet, ClassifierMixin):
+ __doc__ = get_neural_net_clf_doc(NeuralNet.__doc__)
+@@ -251,8 +254,12 @@ neural_net_binary_clf_criterion_text = "
+
+
+ def get_neural_net_binary_clf_doc(doc):
+- doc = neural_net_binary_clf_doc_start + " " + doc.split("\n ", 4)[-1]
+- pattern = re.compile(r'(\n\s+)(criterion .*\n)(\s.+){1,99}')
++ indentation = " "
++ # dedent/indent roundtrip required for consistent indention in both
++ # Python <3.13 and Python >=3.13
++ # Because <3.13 => not automatic dedent, but it is the case in >=3.13
++ doc = neural_net_binary_clf_doc_start + " " + textwrap.indent(textwrap.dedent(doc.split("\n", 5)[-1]), indentation)
++ pattern = re.compile(r'(\n\s+)(criterion .*\n)(\s.+|.){1,99}')
+ start, end = pattern.search(doc).span()
+ doc = doc[:start] + neural_net_binary_clf_criterion_text + doc[end:]
+ return doc
+--- skorch-1.0.0.orig/skorch/regressor.py
++++ skorch-1.0.0/skorch/regressor.py
+@@ -1,6 +1,7 @@
+ """NeuralNet subclasses for regression tasks."""
+
+ import re
++import textwrap
+
+ from sklearn.base import RegressorMixin
+ import torch
+@@ -23,15 +24,17 @@ neural_net_reg_criterion_text = """
+ criterion : torch criterion (class, default=torch.nn.MSELoss)
+ Mean squared error loss."""
+
+-
+ def get_neural_net_reg_doc(doc):
+- doc = neural_net_reg_doc_start + " " + doc.split("\n ", 4)[-1]
+- pattern = re.compile(r'(\n\s+)(criterion .*\n)(\s.+){1,99}')
++ indentation = " "
++ # dedent/indent roundtrip required for consistent indention in both
++ # Python <3.13 and Python >=3.13
++ # Because <3.13 => not automatic dedent, but it is the case in >=3.13
++ doc = neural_net_reg_doc_start + " " + textwrap.indent(textwrap.dedent(doc.split("\n", 5)[-1]), indentation)
++ pattern = re.compile(r'(\n\s+)(criterion .*\n)(\s.+|.){1,99}')
+ start, end = pattern.search(doc).span()
+ doc = doc[:start] + neural_net_reg_criterion_text + doc[end:]
+ return doc
+
+-
+ # pylint: disable=missing-docstring
+ class NeuralNetRegressor(NeuralNet, RegressorMixin):
+ __doc__ = get_neural_net_reg_doc(NeuralNet.__doc__)
diff -Nru skorch-1.0.0/debian/patches/series skorch-1.0.0/debian/patches/series
--- skorch-1.0.0/debian/patches/series 2023-09-21 17:18:44.000000000 +0100
+++ skorch-1.0.0/debian/patches/series 2025-01-25 12:34:20.000000000 +0000
@@ -1 +1,2 @@
skip-test.patch
+fix-docstring.patch
Reply to: