# Maintainer: Filipe Laíns (FFY00) <lains@archlinux.org>

pkgname=ufmt
pkgver=2.8.0
pkgrel=2
pkgdesc='Safe, atomic formatting with black and µsort'
arch=('any')
url='https://github.com/omnilib/ufmt'
license=('MIT')
depends=('python-black' 'python-click' 'python-libcst' 'python-moreorless'
         'python-tomlkit' 'python-trailrunner' 'python-typing_extensions' 'usort')
makedepends=('python-build' 'python-installer' 'python-flit-core' 'python-wheel')
checkdepends=('python-pygls' 'python-ruff-api')
optdepends=('python-pygls: for the LSP formatting server'
            'python-ruff-api: for Ruff formatter support')
source=("$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz"
        ufmt-make-tests-compatible-with-click-8.2.0.patch::https://github.com/omnilib/ufmt/commit/7980d7cd0a29fbd287e10d939248ef7c9d38a660.patch)
sha512sums=('6f1f9129865c92cc6cd7d75872b2bc50544d37a512138ac01ad442a2f50fb34d8c9385270ff13f682f8ea0639a9356d517ee5d65e0e2acb9b24cd8a4ec2946f5'
            'ea0e017c8358f6f34dcd757f3a52b9a05efb23858cc95c7ceb60d76c7568b2ae99a9d9eb0c882246a554eec0e15a6cd5e4da83688ea1a0e35fcaae5bcfcb9100')

prepare() {
  cd $pkgname-$pkgver

  patch --forward --strip=1 --input=../ufmt-make-tests-compatible-with-click-8.2.0.patch
}

build() {
  cd $pkgname-$pkgver

  python -m build -nwx
}

check() {
  cd $pkgname-$pkgver

  python -m ufmt.tests
}

package() {
  cd $pkgname-$pkgver

  python -m installer -d "$pkgdir" dist/*.whl

  install -Dm 644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

# vim:set ts=2 sw=2 et:
