Skip to content

Commit e3f50bb

Browse files
style: Update to Black v20.8 formatting (#1048)
* Apply Black v20.8b1 formatting - Should be similar to format of first stable release of Black * Update Black pre-commit hook to use rev v20.8b1 - Using pinned revs is the recommended approach for pre-commit: psf/black#420 * Update development docs to advocate for and explain the use of pre-commit autoupdate
1 parent 8fa2cc3 commit e3f50bb

28 files changed

+118
-104
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/psf/black
3-
rev: stable
3+
rev: 20.8b1
44
hooks:
55
- id: black
66
language_version: python3

docs/development.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ Then setup the Git pre-commit hook for `Black <https://github.com/psf/black>`__
1919
2020
pre-commit install
2121
22+
as the ``rev`` gets updated through time to track changes of different hooks,
23+
simply run
24+
25+
.. code-block:: console
26+
27+
pre-commit autoupdate
28+
29+
to have pre-commit install the new version.
30+
2231
Testing
2332
-------
2433

src/pyhf/cli/patchset.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ def cli():
1818

1919
@cli.command()
2020
@click.argument('patchset', default='-')
21-
@click.option(
22-
'--name', help='The name of the patch to extract.', default=None,
23-
)
21+
@click.option('--name', help='The name of the patch to extract.', default=None)
2422
@click.option(
2523
'--output-file',
2624
help='The location of the output json file. If not specified, prints to screen.',
@@ -64,9 +62,7 @@ def extract(patchset, name, output_file, with_metadata):
6462
@cli.command()
6563
@click.argument('background-only', default='-')
6664
@click.argument('patchset', default='-')
67-
@click.option(
68-
'--name', help='The name of the patch to extract.', default=None,
69-
)
65+
@click.option('--name', help='The name of the patch to extract.', default=None)
7066
@click.option(
7167
'--output-file',
7268
help='The location of the output json file. If not specified, prints to screen.',

src/pyhf/cli/spec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ def digest(workspace, algorithm, output_json):
346346
}
347347

348348
if output_json:
349-
output = json.dumps(digests, indent=4, sort_keys=True,)
349+
output = json.dumps(digests, indent=4, sort_keys=True)
350350
else:
351351
output = '\n'.join(
352352
f"{hash_alg}:{digest}" for hash_alg, digest in digests.items()

src/pyhf/constraints.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ def _precompute(self):
8282
self.access_field = tensorlib.astensor(self._access_field, dtype='int')
8383

8484
def has_pdf(self):
85-
'''
85+
"""
8686
Returns:
8787
flag (`bool`): Whether the model has a Gaussian Constraint
88-
'''
88+
"""
8989
return bool(self.param_viewer.index_selection)
9090

9191
def make_pdf(self, pars):
@@ -213,10 +213,10 @@ def _precompute(self):
213213
self.batched_factors = tensorlib.astensor(self._batched_factors)
214214

215215
def has_pdf(self):
216-
'''
216+
"""
217217
Returns:
218218
flag (`bool`): Whether the model has a Gaussian Constraint
219-
'''
219+
"""
220220
return bool(self.param_viewer.index_selection)
221221

222222
def make_pdf(self, pars):

src/pyhf/modifiers/histosys.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ def _precompute(self):
8080
)
8181

8282
def apply(self, pars):
83-
'''
83+
"""
8484
Returns:
8585
modification tensor: Shape (n_modifiers, n_global_samples, n_alphas, n_global_bin)
86-
'''
86+
"""
8787
if not self.param_viewer.index_selection:
8888
return
8989

src/pyhf/modifiers/lumi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ def _precompute(self):
5757
self.lumi_default = tensorlib.ones(self.lumi_mask.shape)
5858

5959
def apply(self, pars):
60-
'''
60+
"""
6161
Returns:
6262
modification tensor: Shape (n_modifiers, n_global_samples, n_alphas, n_global_bin)
63-
'''
63+
"""
6464
if not self.param_viewer.index_selection:
6565
return
6666

src/pyhf/modifiers/normfactor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ def _precompute(self):
5858
self.normfactor_default = tensorlib.ones(self.normfactor_mask.shape)
5959

6060
def apply(self, pars):
61-
'''
61+
"""
6262
Returns:
6363
modification tensor: Shape (n_modifiers, n_global_samples, n_alphas, n_global_bin)
64-
'''
64+
"""
6565
if not self.param_viewer.index_selection:
6666
return
6767
tensorlib, _ = get_backend()

src/pyhf/modifiers/normsys.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ def _precompute(self):
8181
)
8282

8383
def apply(self, pars):
84-
'''
84+
"""
8585
Returns:
8686
modification tensor: Shape (n_modifiers, n_global_samples, n_alphas, n_global_bin)
87-
'''
87+
"""
8888
if not self.param_viewer.index_selection:
8989
return
9090

src/pyhf/modifiers/shapefactor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ def _precompute(self):
131131
self.sample_ones = tensorlib.ones(tensorlib.shape(self.shapefactor_mask)[1])
132132

133133
def apply(self, pars):
134-
'''
134+
"""
135135
Returns:
136136
modification tensor: Shape (n_modifiers, n_global_samples, n_alphas, n_global_bin)
137-
'''
137+
"""
138138
if not self.param_viewer.index_selection:
139139
return
140140

0 commit comments

Comments
 (0)