Gentoo Archives: gentoo-commits

From: Andrew Ammerlaan <andrewammerlaan@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/mccabe/, dev-python/mccabe/files/
Date: Mon, 16 May 2022 13:44:05
Message-Id: 1652708633.f41cd46242425955a12f9a5db779e09d32d893a2.andrewammerlaan@gentoo
1 commit: f41cd46242425955a12f9a5db779e09d32d893a2
2 Author: Andrew Ammerlaan <andrewammerlaan <AT> gentoo <DOT> org>
3 AuthorDate: Mon May 16 13:41:54 2022 +0000
4 Commit: Andrew Ammerlaan <andrewammerlaan <AT> gentoo <DOT> org>
5 CommitDate: Mon May 16 13:43:53 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f41cd462
7
8 dev-python/mccabe: add 0.7.0
9
10 Signed-off-by: Andrew Ammerlaan <andrewammerlaan <AT> gentoo.org>
11
12 dev-python/mccabe/Manifest | 1 +
13 ...cabe-0.7.0-fix-tests-without-hypothesmith.patch | 74 ++++++++++++++++++++++
14 dev-python/mccabe/mccabe-0.7.0.ebuild | 33 ++++++++++
15 3 files changed, 108 insertions(+)
16
17 diff --git a/dev-python/mccabe/Manifest b/dev-python/mccabe/Manifest
18 index 112a1e13f737..5ecec9341694 100644
19 --- a/dev-python/mccabe/Manifest
20 +++ b/dev-python/mccabe/Manifest
21 @@ -1 +1,2 @@
22 DIST mccabe-0.6.1.tar.gz 8612 BLAKE2B 6828dfd852cf9b47de10bd889dd4c32dc1ee95910fbd27e0921cd7d9975a0831b1c2763eda5b2d77d7e4b44b5a9d0e89f0818cab71de655954cc87cacfe8d382 SHA512 d8fc251a29790887c14c5932c5172b4cd578cd37ccf14cb96e80f0b97f27023427ea032d14e1e2a99d72627b055eb285f60db69e679ecd79d90a34b0255703d8
23 +DIST mccabe-0.7.0.tar.gz 9658 BLAKE2B b4664a00d4760e2f662681875b548b67ad76d6b8a0ee46bf160e3232ad75172512ad7b4a99759dc13607cf06f3c772210b76a7051582d0bbd221091772543c07 SHA512 3e4141033c63434fad183f62dece872554302aeee8cb789586ac7d6d748d198799e2797df1d58458f4d431734f8899f11022d76666c848d43e6271304776346d
24
25 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
26 new file mode 100644
27 index 000000000000..18728fe59826
28 --- /dev/null
29 +++ b/dev-python/mccabe/files/mccabe-0.7.0-fix-tests-without-hypothesmith.patch
30 @@ -0,0 +1,74 @@
31 +diff --git a/test_mccabe.py b/test_mccabe.py
32 +index fe6e8d3..14d8012 100644
33 +--- a/test_mccabe.py
34 ++++ b/test_mccabe.py
35 +@@ -241,37 +241,38 @@ class RegressionTests(unittest.TestCase):
36 +
37 + # This test uses the Hypothesis and Hypothesmith libraries to generate random
38 + # syntatically-valid Python source code and applies McCabe on it.
39 +-@settings(
40 +- max_examples=1000, # roughly 1k tests/minute, or half that under coverage
41 +- derandomize=False, # deterministic mode to avoid CI flakiness
42 +- deadline=None, # ignore Hypothesis' health checks; we already know that
43 +- suppress_health_check=HealthCheck.all(), # this is slow and filter-heavy.
44 +-)
45 +-@given(
46 +- # Note that while Hypothesmith might generate code unlike that written by
47 +- # humans, it's a general test that should pass for any *valid* source code.
48 +- # (so e.g. running it against code scraped of the internet might also help)
49 +- src_contents=hypothesmith.from_grammar() | hypothesmith.from_node(),
50 +- max_complexity=st.integers(min_value=1),
51 +-)
52 +-@×××××××××××.skipif(not hypothesmith, reason="hypothesmith could not be imported")
53 +-def test_idempotent_any_syntatically_valid_python(
54 +- src_contents: str, max_complexity: int
55 +-) -> None:
56 +- """Property-based tests for mccabe.
57 +-
58 +- This test case is based on a similar test for Black, the code formatter.
59 +- Black's test was written by Zac Hatfield-Dodds, the author of Hypothesis
60 +- and the Hypothesmith tool for source code generation. You can run this
61 +- file with `python`, `pytest`, or (soon) a coverage-guided fuzzer Zac is
62 +- working on.
63 +- """
64 +-
65 +- # Before starting, let's confirm that the input string is valid Python:
66 +- compile(src_contents, "<string>", "exec") # else bug is in hypothesmith
67 +-
68 +- # Then try to apply get_complexity_number to the code...
69 +- get_code_complexity(src_contents, max_complexity)
70 ++if hypothesmith:
71 ++ @settings(
72 ++ max_examples=1000, # roughly 1k tests/minute, or half that under coverage
73 ++ derandomize=False, # deterministic mode to avoid CI flakiness
74 ++ deadline=None, # ignore Hypothesis' health checks; we already know that
75 ++ suppress_health_check=HealthCheck.all(), # this is slow and filter-heavy.
76 ++ )
77 ++ @given(
78 ++ # Note that while Hypothesmith might generate code unlike that written by
79 ++ # humans, it's a general test that should pass for any *valid* source code.
80 ++ # (so e.g. running it against code scraped of the internet might also help)
81 ++ src_contents=hypothesmith.from_grammar() | hypothesmith.from_node(),
82 ++ max_complexity=st.integers(min_value=1),
83 ++ )
84 ++ @pytest.mark.skipif(not hypothesmith, reason="hypothesmith could not be imported")
85 ++ def test_idempotent_any_syntatically_valid_python(
86 ++ src_contents: str, max_complexity: int
87 ++ ) -> None:
88 ++ """Property-based tests for mccabe.
89 ++
90 ++ This test case is based on a similar test for Black, the code formatter.
91 ++ Black's test was written by Zac Hatfield-Dodds, the author of Hypothesis
92 ++ and the Hypothesmith tool for source code generation. You can run this
93 ++ file with `python`, `pytest`, or (soon) a coverage-guided fuzzer Zac is
94 ++ working on.
95 ++ """
96 ++
97 ++ # Before starting, let's confirm that the input string is valid Python:
98 ++ compile(src_contents, "<string>", "exec") # else bug is in hypothesmith
99 ++
100 ++ # Then try to apply get_complexity_number to the code...
101 ++ get_code_complexity(src_contents, max_complexity)
102 +
103 +
104 + if __name__ == "__main__":
105
106 diff --git a/dev-python/mccabe/mccabe-0.7.0.ebuild b/dev-python/mccabe/mccabe-0.7.0.ebuild
107 new file mode 100644
108 index 000000000000..59b61eaf1065
109 --- /dev/null
110 +++ b/dev-python/mccabe/mccabe-0.7.0.ebuild
111 @@ -0,0 +1,33 @@
112 +# Copyright 1999-2022 Gentoo Authors
113 +# Distributed under the terms of the GNU General Public License v2
114 +
115 +EAPI=8
116 +
117 +PYTHON_COMPAT=( pypy3 python3_{8..11} )
118 +DISTUTILS_USE_PEP517=setuptools
119 +inherit distutils-r1
120 +
121 +DESCRIPTION="flake8 plugin: McCabe complexity checker"
122 +HOMEPAGE="https://github.com/PyCQA/mccabe"
123 +SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
124 +
125 +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"
126 +LICENSE="MIT"
127 +SLOT="0"
128 +
129 +RDEPEND="dev-python/flake8[${PYTHON_USEDEP}]"
130 +
131 +BDEPEND="test? (
132 + dev-python/hypothesis[${PYTHON_USEDEP}]
133 +)"
134 +
135 +PATCHES=(
136 + "${FILESDIR}/${P}-fix-tests-without-hypothesmith.patch"
137 +)
138 +
139 +distutils_enable_tests pytest
140 +
141 +python_prepare_all() {
142 + sed -i -e '/pytest-runner/d' setup.py || die
143 + distutils-r1_python_prepare_all
144 +}