# Maintainer: Caleb Maclennan <caleb@alerque.com>
# Contributor: Felix Yan <felixonmars@archlinux.org>
# Contributor: Karol "Kenji Takahashi" Woźniak <kenji.sx>

_pyname=mccabe
pkgname=python-$_pyname
pkgver=0.7.0
pkgrel=8
pkgdesc='McCabe complexity checker for Python'
arch=(any)
url="https://github.com/PyCQA/$_pyname"
license=(MIT)
depends=(python)
makedepends=(python-{build,installer,wheel}
             python-setuptools)
checkdepends=(python-hypothesis
              python-hypothesmith
              python-pytest)
_archive="$_pyname-$pkgver"
source=("$url/archive/$pkgver/$_archive.tar.gz")
sha256sums=('f4f7fa5ed8b7f77601fea3e748d6238928323a291fcde0fddbbe6cb2d0cb2da2')

build() {
	cd "$_archive"
	# Update deprecated syntax in test runner rather than skipping broken tests
	hypothesis codemod .
}

build() {
	cd "$_archive"
	python -m build -wn
}

check() {
	cd "$_archive"
	# Test fails on Python 3.12
	pytest --deselect test_mccabe.py::test_idempotent_any_syntatically_valid_python
}

package() {
	cd "$_archive"
	python -m installer -d "$pkgdir" dist/*.whl
	install -Dm0644 -t "$pkgdir/usr/share/licenses/$pkgname/" LICENSE
}
