# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Morten Linderud <foxboron@archlinux.org>

pkgname=python-pydocstyle
pkgver=6.3.0
pkgrel=4
pkgdesc="Docstring style checker"
arch=(any)
url="http://www.pydocstyle.org/"
license=("MIT")
depends=("python-snowballstemmer")
makedepends=("python-build" "python-installer" "python-poetry-core")
checkdepends=("python-pytest" "python-pip" "python-snowballstemmer")
source=("$pkgname-$pkgver.tar.gz::https://github.com/PyCQA/pydocstyle/archive/${pkgver}.tar.gz"
         https://github.com/PyCQA/pydocstyle/commit/306c7c8f.patch)
sha256sums=('29ed0e8b1abe5f4590132f456b6f9cbf0866b89fabf836bc9474fde706e2e13e'
            '0f0f89026ef71ab9cca805ded0ad86dc152d7a1c388a43af5739455c0eb0f316')

prepare() {
    cd "pydocstyle-${pkgver}"
    # Fix version number in metadata
    sed -e "s|^version = .*|version = \"$pkgver\"|" -i pyproject.toml

    patch -p1 -i ../306c7c8f.patch # Fix tests with Python 3.12
}

build() {
    cd "pydocstyle-${pkgver}"
    python -m build --wheel --no-isolation
}

check() {
    cd "pydocstyle-${pkgver}"
    PYTHONPATH="$PWD"/src \
    pytest -k 'not test_integration'
}

package() {
    cd "pydocstyle-${pkgver}"
    python -m installer --destdir="${pkgdir}/" dist/*.whl
    install -Dm644 LICENSE-MIT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
