summaryrefslogtreecommitdiff
path: root/dev-python/mccabe
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2022-06-29 12:04:12 +0100
committerV3n3RiX <venerix@koprulu.sector>2022-06-29 12:04:12 +0100
commit0f558761aa2dee1017b4751e4017205e015a9560 (patch)
tree037df795519468a25d9362b4e95cdaeb84eb1cf9 /dev-python/mccabe
parent752d6256e5204b958b0ef7905675a940b5e9172f (diff)
gentoo resync : 29.12.2022
Diffstat (limited to 'dev-python/mccabe')
-rw-r--r--dev-python/mccabe/Manifest3
-rw-r--r--dev-python/mccabe/files/mccabe-0.7.0-fix-tests-without-hypothesmith.patch74
-rw-r--r--dev-python/mccabe/mccabe-0.7.0.ebuild33
3 files changed, 110 insertions, 0 deletions
diff --git a/dev-python/mccabe/Manifest b/dev-python/mccabe/Manifest
index 2f4f8a8beaf1..ef21bf1db60f 100644
--- a/dev-python/mccabe/Manifest
+++ b/dev-python/mccabe/Manifest
@@ -1,3 +1,6 @@
+AUX mccabe-0.7.0-fix-tests-without-hypothesmith.patch 3585 BLAKE2B 928877eb6422450e410ff7a6721fc7dd0282c9d8ae4ba2be3542bf0b4c6e398f63b238fdacec979d55c86d440c463ddafcc757465dfe632ba2ce975b076ffa76 SHA512 590e7918f758873d6f14345345a5c4d3c31d098edd08252ac281bdf1ec547925620095f94a5937983136d040b4e6965207b05bd6ce7a069e6c67ace1f07493ef
DIST mccabe-0.6.1.tar.gz 8612 BLAKE2B 6828dfd852cf9b47de10bd889dd4c32dc1ee95910fbd27e0921cd7d9975a0831b1c2763eda5b2d77d7e4b44b5a9d0e89f0818cab71de655954cc87cacfe8d382 SHA512 d8fc251a29790887c14c5932c5172b4cd578cd37ccf14cb96e80f0b97f27023427ea032d14e1e2a99d72627b055eb285f60db69e679ecd79d90a34b0255703d8
+DIST mccabe-0.7.0.tar.gz 9658 BLAKE2B b4664a00d4760e2f662681875b548b67ad76d6b8a0ee46bf160e3232ad75172512ad7b4a99759dc13607cf06f3c772210b76a7051582d0bbd221091772543c07 SHA512 3e4141033c63434fad183f62dece872554302aeee8cb789586ac7d6d748d198799e2797df1d58458f4d431734f8899f11022d76666c848d43e6271304776346d
EBUILD mccabe-0.6.1-r2.ebuild 716 BLAKE2B 4884582ba4b135fbdb844b1d581c258044e78aaa4563bd9097ae78c5ef361882983ebc5e482ddb2a2f1573ece982215c734c060207af1077c918c424d5be2b17 SHA512 2bbb177f9c1865902fac9154d5525280e8eaedfdc8929df5a68d67eeb7b0cd47a7d1a23a8d7419f312e01d5df2da01031f36f9fd8991b0309c41a90ef2de8e61
+EBUILD mccabe-0.7.0.ebuild 879 BLAKE2B ee4438b6b36e42b4203e1d995e1502c6fc6b010543bc53059082f298c128aebf9d4f5a44e817f7c50cbb64057fec39c8a775211c7e390a1ac3eaa4e95b1be29f SHA512 f8c0d4595e899eb7cc7bb6544dd1dcb5c08d5043c4fc1bbf127e764b7d713146017fcee7622ed8c9f33fd7b734c314210e34389f1a768bb20ffeb616bcbca198
MISC metadata.xml 399 BLAKE2B 4abb33f734bea7c7f0e42b4840bf818ee190d83c264a623e4a3f45eb1578e4f49384976efd205234821d60d0982f5ab4abfa6885e958bc75bedc064a16d14f75 SHA512 52255fe16006844729a51af6ebd3501e1365cca9470e6cfa029c74ebd86252c4dcbf3f250876fdd0ea7b6380a51ec975370db464dfb42fbef8d4880cf5336322
diff --git a/dev-python/mccabe/files/mccabe-0.7.0-fix-tests-without-hypothesmith.patch b/dev-python/mccabe/files/mccabe-0.7.0-fix-tests-without-hypothesmith.patch
new file mode 100644
index 000000000000..18728fe59826
--- /dev/null
+++ b/dev-python/mccabe/files/mccabe-0.7.0-fix-tests-without-hypothesmith.patch
@@ -0,0 +1,74 @@
+diff --git a/test_mccabe.py b/test_mccabe.py
+index fe6e8d3..14d8012 100644
+--- a/test_mccabe.py
++++ b/test_mccabe.py
+@@ -241,37 +241,38 @@ class RegressionTests(unittest.TestCase):
+
+ # This test uses the Hypothesis and Hypothesmith libraries to generate random
+ # syntatically-valid Python source code and applies McCabe on it.
+-@settings(
+- max_examples=1000, # roughly 1k tests/minute, or half that under coverage
+- derandomize=False, # deterministic mode to avoid CI flakiness
+- deadline=None, # ignore Hypothesis' health checks; we already know that
+- suppress_health_check=HealthCheck.all(), # this is slow and filter-heavy.
+-)
+-@given(
+- # Note that while Hypothesmith might generate code unlike that written by
+- # humans, it's a general test that should pass for any *valid* source code.
+- # (so e.g. running it against code scraped of the internet might also help)
+- src_contents=hypothesmith.from_grammar() | hypothesmith.from_node(),
+- max_complexity=st.integers(min_value=1),
+-)
+-@pytest.mark.skipif(not hypothesmith, reason="hypothesmith could not be imported")
+-def test_idempotent_any_syntatically_valid_python(
+- src_contents: str, max_complexity: int
+-) -> None:
+- """Property-based tests for mccabe.
+-
+- This test case is based on a similar test for Black, the code formatter.
+- Black's test was written by Zac Hatfield-Dodds, the author of Hypothesis
+- and the Hypothesmith tool for source code generation. You can run this
+- file with `python`, `pytest`, or (soon) a coverage-guided fuzzer Zac is
+- working on.
+- """
+-
+- # Before starting, let's confirm that the input string is valid Python:
+- compile(src_contents, "<string>", "exec") # else bug is in hypothesmith
+-
+- # Then try to apply get_complexity_number to the code...
+- get_code_complexity(src_contents, max_complexity)
++if hypothesmith:
++ @settings(
++ max_examples=1000, # roughly 1k tests/minute, or half that under coverage
++ derandomize=False, # deterministic mode to avoid CI flakiness
++ deadline=None, # ignore Hypothesis' health checks; we already know that
++ suppress_health_check=HealthCheck.all(), # this is slow and filter-heavy.
++ )
++ @given(
++ # Note that while Hypothesmith might generate code unlike that written by
++ # humans, it's a general test that should pass for any *valid* source code.
++ # (so e.g. running it against code scraped of the internet might also help)
++ src_contents=hypothesmith.from_grammar() | hypothesmith.from_node(),
++ max_complexity=st.integers(min_value=1),
++ )
++ @pytest.mark.skipif(not hypothesmith, reason="hypothesmith could not be imported")
++ def test_idempotent_any_syntatically_valid_python(
++ src_contents: str, max_complexity: int
++ ) -> None:
++ """Property-based tests for mccabe.
++
++ This test case is based on a similar test for Black, the code formatter.
++ Black's test was written by Zac Hatfield-Dodds, the author of Hypothesis
++ and the Hypothesmith tool for source code generation. You can run this
++ file with `python`, `pytest`, or (soon) a coverage-guided fuzzer Zac is
++ working on.
++ """
++
++ # Before starting, let's confirm that the input string is valid Python:
++ compile(src_contents, "<string>", "exec") # else bug is in hypothesmith
++
++ # Then try to apply get_complexity_number to the code...
++ get_code_complexity(src_contents, max_complexity)
+
+
+ if __name__ == "__main__":
diff --git a/dev-python/mccabe/mccabe-0.7.0.ebuild b/dev-python/mccabe/mccabe-0.7.0.ebuild
new file mode 100644
index 000000000000..8713a242dc81
--- /dev/null
+++ b/dev-python/mccabe/mccabe-0.7.0.ebuild
@@ -0,0 +1,33 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( pypy3 python3_{8..11} )
+DISTUTILS_USE_PEP517=setuptools
+inherit distutils-r1
+
+DESCRIPTION="flake8 plugin: McCabe complexity checker"
+HOMEPAGE="https://github.com/PyCQA/mccabe"
+SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
+
+KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~amd64-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+LICENSE="MIT"
+SLOT="0"
+
+RDEPEND="dev-python/flake8[${PYTHON_USEDEP}]"
+
+BDEPEND="test? (
+ dev-python/hypothesis[${PYTHON_USEDEP}]
+)"
+
+PATCHES=(
+ "${FILESDIR}/${P}-fix-tests-without-hypothesmith.patch"
+)
+
+distutils_enable_tests pytest
+
+python_prepare_all() {
+ sed -i -e '/pytest-runner/d' setup.py || die
+ distutils-r1_python_prepare_all
+}