From 51fbe649199673a0309ba7aa53a2041475408757 Mon Sep 17 00:00:00 2001 From: f-fl0 <66578286+f-fl0@users.noreply.github.com> Date: Fri, 5 Jul 2024 16:11:31 +0900 Subject: [PATCH] Alpine 3.20: add py3-pydocstyle backport (#959) * Add py3-pydocstyle backport * Add patch file for f-string tests - Based on https://github.com/PyCQA/pydocstyle/pull/656 --- v3.20/backports/py3-pydocstyle/APKBUILD | 47 +++++++++++++++++++ .../py3-pydocstyle/fix-fstring-tests.patch | 34 ++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 v3.20/backports/py3-pydocstyle/APKBUILD create mode 100644 v3.20/backports/py3-pydocstyle/fix-fstring-tests.patch diff --git a/v3.20/backports/py3-pydocstyle/APKBUILD b/v3.20/backports/py3-pydocstyle/APKBUILD new file mode 100644 index 000000000..63e81d243 --- /dev/null +++ b/v3.20/backports/py3-pydocstyle/APKBUILD @@ -0,0 +1,47 @@ +# Contributor: Russ Webber +# Maintainer: Russ Webber +pkgname=py3-pydocstyle +pkgver=6.3.0 +pkgrel=1 +pkgdesc="Static analysis tool for checking compliance with Python docstring conventions" +url="https://www.pydocstyle.org/" +arch="noarch" +license="MIT" +depends="python3 py3-snowballstemmer" +makedepends=" + py3-gpep517 + py3-poetry-core + py3-setuptools_scm + " +checkdepends="py3-pytest py3-mock" +subpackages="$pkgname-pyc" +source="$pkgname-$pkgver.tar.gz::https://github.com/PyCQA/pydocstyle/archive/$pkgver.tar.gz + fix-fstring-tests.patch" +builddir="$srcdir/pydocstyle-$pkgver" + +prepare() { + default_prepare + + sed -i "s|0.0.0-dev|$pkgver|" pyproject.toml +} + +build() { + gpep517 build-wheel \ + --wheel-dir .dist \ + --output-fd 3 3>&1 >&2 +} + +check() { + python3 -m venv --clear --without-pip --system-site-packages .testenv + .testenv/bin/python3 -m installer .dist/*.whl + .testenv/bin/python3 -m pytest --deselect src/tests/test_integration.py +} + +package() { + python3 -m installer -d "$pkgdir" \ + .dist/*.whl +} + +sha512sums=" +f8473b19ab6ef0b61787875558f9dd6f9f7f1954e1baa0010942af6d4de8dbca30c8c08be6acbf24aadd1c0a601ba9467b747026a6cd22379f0c4b84a38b57c7 py3-pydocstyle-6.3.0.tar.gz +4c751edede0fcc39f929ac6c919452b9cd29ee32597c07abb1d4c31ce1c248b56a8dad55f3652864619a8840aaf300b55e1a351ae88de6814848d08febbafc93 fix-fstring-tests.patch" diff --git a/v3.20/backports/py3-pydocstyle/fix-fstring-tests.patch b/v3.20/backports/py3-pydocstyle/fix-fstring-tests.patch new file mode 100644 index 000000000..1bc93f612 --- /dev/null +++ b/v3.20/backports/py3-pydocstyle/fix-fstring-tests.patch @@ -0,0 +1,34 @@ +diff --git a/src/pydocstyle/parser.py b/src/pydocstyle/parser.py +index 95bd0a1..875f769 100644 +--- a/src/pydocstyle/parser.py ++++ b/src/pydocstyle/parser.py +@@ -479,6 +479,29 @@ class Parser: + ) + self.stream.move() + return docstring ++ if (sys.version_info.major, sys.version_info.minor) >= ( ++ 3, ++ 12, ++ ) and self.current.kind == tk.FSTRING_START: ++ ++ def fstring(string): ++ """Recursively parse fstring tokens to output it as one string.""" ++ while self.current.kind != tk.FSTRING_END: ++ self.stream.move() ++ string += self.current.value ++ if self.current.kind == tk.FSTRING_START: ++ string = fstring(string) ++ self.stream.move() ++ string += self.current.value ++ return string ++ ++ # Reattach fstring tokens together into a string to deal with PEP 701 in python3.12 ++ start = self.current.start[0] ++ string = fstring(self.current.value) ++ end = self.current.end[0] ++ docstring = Docstring(string, start, end) ++ self.stream.move() ++ return docstring + return None + + def parse_decorators(self):