# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Maintainer: Daniel M. Capella <polyzen@archlinux.org>

pkgname=python-typeguard
pkgver=4.2.1
pkgrel=1
pkgdesc="Run-time type checker for Python"
url="https://github.com/agronholm/typeguard"
license=('MIT')
arch=('any')
depends=('python-typing_extensions')
makedepends=('git' 'python-build' 'python-installer' 'python-setuptools-scm' 'python-wheel')
checkdepends=('mypy' 'python-pytest')
source=("git+https://github.com/agronholm/typeguard.git#tag=$pkgver")
b2sums=('0cfc6b11e2106502f9d45ca49cf06c22e822d152949b4b1b7efec24f9c65d8aa3b8b7d91565c4a5f6fa41582543570053a182e98aef466ac27e8f81c9c989d20')

prepare() {
  cd typeguard
  # Utilize venv for mypy
  # sed -i 's|\["mypy"|["python", "-m", "mypy"|' tests/mypy/test_type_annotations.py
  # disabled, because mypy tests are still failing
}

build() {
  cd typeguard
  python -m build -nw
}

check() {
  cd typeguard
  python -m venv tmpenv --system-site-packages
  tmpenv/bin/python -m installer dist/*.whl
  tmpenv/bin/python -m pytest --deselect tests/mypy/test_type_annotations.py
}

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