# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI="8"

DISTUTILS_USE_PEP517=poetry
PYTHON_COMPAT=( python3_{11..14} )
inherit distutils-r1

DESCRIPTION="Formats docstrings to follow PEP 257."
HOMEPAGE="https://github.com/PyCQA/docformatter"
SRC_URI="https://github.com/PyCQA/${PN}/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64 ~arm ~arm64 ~x86"
RESTRICT="mirror"

RDEPEND="
	>=dev-python/charset-normalizer-3.0.0[${PYTHON_USEDEP}]
	dev-python/untokenize[${PYTHON_USEDEP}]
"

distutils_enable_tests pytest

src_prepare() {
	eapply "${FILESDIR}/${PN}-${PV}-test-encoding-functions.patch"
	eapply_user
}

python_test() {
	# requires VIRTUAL_ENV set in os.environ
	rm -f tests/test_docformatter.py || die
	epytest
}