# Maintainer: Caleb Maclennan <caleb@alerque.com>
# Contributor: Angel Velasquez <angvp@archlinux.org>
# Contributor: Felix Yan <felixonmars@archlinux.org>
# Contributor: Stéphane Gaudreault <stephane@archlinux.org>
# Contributor: Alexander Fehr <pizzapunk gmail com>

_pyname=pylint
pkgname=python-$_pyname
pkgver=2.11.1
pkgrel=1
pkgdesc='Analyzes Python code looking for bugs and signs of poor quality'
arch=(any)
url=https://pylint.org
license=(GPL)
_pydeps=(astroid
         isort
         mccabe
         platformdirs
         toml
         typing_extensions) # for python<3.10
depends=(python
         "${_pydeps[@]/#/python-}")
makedepends=(python-setuptools
             python-sphinx)
checkdepends=(mpdecimal
              python-pytest)
optdepends=('graphviz: Enable output formats other than dot or vcg'
            'tk: Pylint GUI')
_archive="$_pyname-$pkgver"
source=("https://github.com/PyCQA/pylint/archive/v$pkgver/$_archive.tar.gz")
sha256sums=('b797b4906068c616db2aaf364e56506d42b130474e98a16a0e2b9eb72fa0b1b7')

prepare() {
	cd "$_archive"
	# Remove overly restrictive dependency pinning that ends up in runtime checks
	sed -i -e '/>=/{s/>.*//;p}' setup.cfg
}

build() {
	cd "$_archive"
	python setup.py build
	make PYTHONPATH="$PWD/build/lib" -C doc man
}

check() {
	cd "$_archive"
	PYTHONPATH="$PWD/build/lib" pytest \
		--deselect tests/benchmark/test_baseline_benchmarks.py
}

package() {
	cd "$_archive"
	python setup.py install --root="$pkgdir" --optimize=1 --skip-build
	install -Dm0644 -t "$pkgdir/usr/share/man/man1/" doc/_build/man/*
}
