Skip to content

Commit

Permalink
Alpine 3.20: add py3-pydocstyle backport (#959)
Browse files Browse the repository at this point in the history
* Add py3-pydocstyle backport
* Add patch file for f-string tests
  - Based on PyCQA/pydocstyle#656
  • Loading branch information
f-fl0 authored Jul 5, 2024
1 parent 918960e commit 51fbe64
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
47 changes: 47 additions & 0 deletions v3.20/backports/py3-pydocstyle/APKBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Contributor: Russ Webber <[email protected]>
# Maintainer: Russ Webber <[email protected]>
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"
34 changes: 34 additions & 0 deletions v3.20/backports/py3-pydocstyle/fix-fstring-tests.patch
Original file line number Diff line number Diff line change
@@ -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):

0 comments on commit 51fbe64

Please sign in to comment.