Debian Codegraph @

debian/manpage2.rst

raw
1 :Version: 21.4b2-2
2 :Date: 2021-10-10
3 :Copyright: 2018 Łukasz Langa
4 :Title: black-primer
5 :Subtitle: CI tool to check a number of projects in parallel using black
6 :Manual group: uncompromising Python code formatter
7 :Manual section: "1"
8
9 Description
10 ###########
11
12 ``black-primer`` is a tool built for CI (and humans) to have ``black``
13 ``--check`` a number of Git accessible projects in parallel. Projects
14 are configured in ``primer.json``
15
16 Run flow
17 ########
18
19 - Ensure we have ``black`` + ``git`` installed
20 - Load projects from ``primer.json``
21 - Run projects in parallel with ``--worker`` workers (defaults to CPU count / 2)
22
23 - Checkout projects
24 - Run black and record result
25 - Clean up repository checkout _(can optionally be disabled via
26 ``--keep``)
27
28 - Display results summary to screen
29 - Default to cleaning up ``--work-dir`` (which defaults to tempfile schematics)
30 - Return
31 - 0 for successful run
32 - < 0 for environment / internal error
33 - \> 0 for each project with an error
34
35 Speed up runs
36 #############
37
38 If you're running locally yourself to test black on lots of code try:
39
40 - Using ``-k`` / ``--keep`` + ``-w`` / ``--work-dir`` so you don't have
41 to re-checkout the repo each run
42
43 CLI arguments
44 #############
45
46 .. code-block::
47
48 Usage: black-primer [OPTIONS]
49
50 primer - prime projects for blackening...
51
52 Options:
53 -c, --config PATH JSON config file path [default: /Users/cooper/repos/
54 black/src/black_primer/primer.json]
55
56 --debug Turn on debug logging [default: False]
57 -k, --keep Keep workdir + repos post run [default: False]
58 -L, --long-checkouts Pull big projects to test [default: False]
59 -R, --rebase Rebase project if already checked out [default:
60 False]
61
62 -w, --workdir PATH Directory path for repo checkouts [default: /var/fol
63 ders/tc/hbwxh76j1hn6gqjd2n2sjn4j9k1glp/T/primer.20200
64 517125229]
65
66 -W, --workers INTEGER Number of parallel worker coroutines [default: 2]
67 -h, --help Show this message and exit.
68
69 ## Primer config file
70
71 The config file is in JSON format. Its main element is the `"projects"` dictionary and
72 each parameter is explained below:
73
74 ::
75
76 {
77 "projects": {
78 "00_Example": {
79 "cli_arguments": "List of extra CLI arguments to pass Black for this project",
80 "expect_formatting_changes": "Boolean to indicate that the version of Black is expected to cause changes",
81 "git_clone_url": "URL you would pass `git clone` to check out this repo",
82 "long_checkout": "Boolean to have repo skipped by default unless `--long-checkouts` is specified",
83 "py_versions": "List of major Python versions to run this project with - all will do as you'd expect - run on ALL versions"
84 },
85 "aioexabgp": {
86 "cli_arguments": [],
87 "expect_formatting_changes": true,
88 "git_clone_url": "https://github.com/cooperlees/aioexabgp.git",
89 "long_checkout": false,
90 "py_versions": ["all", "3.8"]
91 }
92 }
93 }
94
95
96 An example primer config file is used by Black
97 [here](https://github.com/psf/black/blob/master/src/black_primer/primer.json)
98
99 Example run
100 ###########
101
102 ::
103
104 cooper-mbp:black cooper$ ~/venvs/b/bin/black-primer
105 [2020-05-17 13:06:40,830] INFO: 4 projects to run Black over (lib.py:270)
106 [2020-05-17 13:06:44,215] INFO: Analyzing results (lib.py:285)
107 -- primer results 📊 --
108
109 3 / 4 succeeded (75.0%) ✅
110 1 / 4 FAILED (25.0%) 💩
111 - 0 projects disabled by config
112 - 0 projects skipped due to Python version
113 - 0 skipped due to long checkout
114
115 Failed projects:
116
117 ## flake8-bugbear:
118 - Returned 1
119 - stdout:
120 --- tests/b303_b304.py 2020-05-17 20:04:09.991227 +0000
121 +++ tests/b303_b304.py 2020-05-17 20:06:42.753851 +0000
122 @@ -26,11 +26,11 @@
123 maxint = 5 # this is okay
124 # the following should not crash
125 (a, b, c) = list(range(3))
126 # it is different than this
127 a, b, c = list(range(3))
128 - a, b, c, = list(range(3))
129 + a, b, c = list(range(3))
130 # and different than this
131 (a, b), c = list(range(3))
132 a, *b, c = [1, 2, 3, 4, 5]
133 b[1:3] = [0, 0]
134
135 would reformat tests/b303_b304.py
136 Oh no! 💥 💔 💥
137 1 file would be reformatted, 22 files would be left unchanged.
138