# Maintainer: David Runge <dvzrv@archlinux.org>
# Maintainer: Christian Heusel <gromit@archlinux.org>

_name=pydantic-extra-types
pkgname=python-pydantic-extra-types
pkgver=2.10.6
pkgrel=1
pkgdesc="Extra pydantic types"
arch=(any)
url="https://github.com/pydantic/pydantic-extra-types"
license=(MIT)
depends=(
  python
  python-pydantic
  python-pydantic-core
)
makedepends=(
  python-build
  python-hatchling
  python-installer
)
checkdepends=(
  python-cron-converter
  python-dirty-equals
  python-pendulum
  python-phonenumbers
  python-pycountry
  python-pymongo
  python-pytest
  python-pytz
  python-semver
  python-ulid
)
optdepends=(
  'python-cron-converter: for cron support'
  'python-pendulum: for datetime support'
  'python-phonenumbers: for phone number support'
  'python-pycountry: for country code support'
  'python-pytz: for timezone support'
  'python-semver: for semantic versioning support'
  'python-tzdata: for timezone support'
  'python-ulid: for ULID support'
)
source=($_name-$pkgver.tar.gz::$url/archive/refs/tags/v$pkgver.tar.gz)
sha512sums=('f7d11af834166fd1f993f0c94e3c089230fa0a390b64224762a2d4d146083c2475dc5cfc20ccf23f6dc525e007fe749dcbe30c4fe9ce4776a0356a6f5992c1aa')
b2sums=('3ffef0a482b44395345af091c2279eaf378977c28c0d4d6e43b193683eef894e80cea4f363ba53b8aea5546777348cfe1cd0137883db34e4077f93d8fa0ba93d')

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

check() {
  local pytest_options=(
    -vv
    -W ignore::DeprecationWarning  # https://github.com/pydantic/pydantic-extra-types/issues/345
    # https://github.com/pydantic/pydantic-extra-types/issues/346
    --deselect tests/test_coordinate.py::test_json_schema
    --deselect 'tests/test_json_schema.py::test_json_schema[Coordinate-expected10]'
    --deselect 'tests/test_json_schema.py::test_json_schema[Latitude-expected8]'
    --deselect 'tests/test_json_schema.py::test_json_schema[Longitude-expected9]'
  )

  cd $_name-$pkgver
  export TZ=UTC
  pytest "${pytest_options[@]}"
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
  install -vDm 644 README.md -t "$pkgdir/usr/share/doc/$pkgname/"
}
