Skip to content

Commit f1a2efc

Browse files
github-actions[bot]greenc-FNAL
authored andcommitted
Apply Python linting fixes
1 parent 7b1f781 commit f1a2efc

File tree

8 files changed

+40
-54
lines changed

8 files changed

+40
-54
lines changed

.github/actions/generate-build-matrix/generate_matrix.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Generates a build matrix for CI based on the trigger event and user input."""
2+
23
import json
34
import os
45
import re

scripts/check_codeql_alerts.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ def _to_alert_api(raw: dict) -> Alert:
287287
instance = raw.get("most_recent_instance") or {}
288288
loc = instance.get("location") or {}
289289
location = "(location unavailable)"
290-
290+
291291
if loc:
292292
# Check for nested SARIF format (physicalLocation)
293293
phys = loc.get("physicalLocation")
@@ -297,15 +297,15 @@ def _to_alert_api(raw: dict) -> Alert:
297297
location = formatted
298298
# Check for flat API format (path, start_line, etc.)
299299
elif "path" in loc:
300-
path = loc.get("path")
301-
start_line = loc.get("start_line")
302-
start_col = loc.get("start_column")
303-
if start_line:
304-
location = f"{path}:{start_line}"
305-
if start_col:
306-
location = f"{location}:{start_col}"
307-
else:
308-
location = path
300+
path = loc.get("path")
301+
start_line = loc.get("start_line")
302+
start_col = loc.get("start_column")
303+
if start_line:
304+
location = f"{path}:{start_line}"
305+
if start_col:
306+
location = f"{location}:{start_col}"
307+
else:
308+
location = path
309309

310310
else:
311311
# If the API instance has no physical location, try to locate using other instances

scripts/sarif-alerts.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""A simple tool to print SARIF results from one or more SARIF files."""
2+
23
import argparse
34
import json
45
from pathlib import Path

test/python/adder.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
real. It serves as a "Hello, World" equivalent for running Python code.
55
"""
66

7+
78
def add(i: int, j: int) -> int:
89
"""Add the inputs together and return the sum total.
910
@@ -39,7 +40,4 @@ def PHLEX_REGISTER_ALGORITHMS(m, config):
3940
Returns:
4041
None
4142
"""
42-
m.transform(add,
43-
input_family = config["input"],
44-
output_products = config["output"])
45-
43+
m.transform(add, input_family=config["input"], output_products=config["output"])

test/python/all_config.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
to Python. The actual run is a noop.
66
"""
77

8+
89
class ConfigConsumer:
910
"""A callable class that "needs" every configuration type.
1011
1112
Attributes:
1213
__name__ (str): Identifier for Phlex.
1314
"""
1415

15-
__name__ = 'config_consumer'
16+
__name__ = "config_consumer"
1617

1718
def __init__(self, config):
1819
"""Create a config consumer object.
@@ -28,18 +29,18 @@ def __init__(self, config):
2829
None
2930
"""
3031
# builtin types
31-
assert config['a_bool'] == False # noqa: E712 # we really want to check False
32-
assert config['an_int'] == -37
33-
assert config['a_uint'] == 18446744073709551616
34-
assert config['a_float'] == 3.1415
35-
assert config['a_string'] == 'foo'
32+
assert config["a_bool"] == False # noqa: E712 # we really want to check False
33+
assert config["an_int"] == -37
34+
assert config["a_uint"] == 18446744073709551616
35+
assert config["a_float"] == 3.1415
36+
assert config["a_string"] == "foo"
3637

3738
# collection types
38-
assert config['some_bools'] == (False, True)
39-
assert config['some_ints'] == (-1, 42, -55)
40-
assert config['some_uints'] == (18446744073709551616, 29, 137)
41-
assert config['some_floats'] == (3.1415, 2.71828)
42-
assert config['some_strings'] == ('aap', 'noot', 'mies')
39+
assert config["some_bools"] == (False, True)
40+
assert config["some_ints"] == (-1, 42, -55)
41+
assert config["some_uints"] == (18446744073709551616, 29, 137)
42+
assert config["some_floats"] == (3.1415, 2.71828)
43+
assert config["some_strings"] == ("aap", "noot", "mies")
4344

4445
def __call__(self, i: int, j: int) -> None:
4546
"""Dummy routine to do something.
@@ -71,5 +72,4 @@ def PHLEX_REGISTER_ALGORITHMS(m, config):
7172
None
7273
"""
7374
config_consumer = ConfigConsumer(config)
74-
m.observe(config_consumer, input_family = config["input"])
75-
75+
m.observe(config_consumer, input_family=config["input"])

test/python/reducer.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
lifetime issues (if they are not).
1212
"""
1313

14+
1415
def add(i: int, j: int) -> int:
1516
"""Add the inputs together and return the sum total.
1617
@@ -49,24 +50,13 @@ def PHLEX_REGISTER_ALGORITHMS(m, config):
4950
"""
5051
# first recieve the same input x4 but return "different" output
5152
for i in range(4):
52-
m.transform(add,
53-
name = "reduce%d" % i,
54-
input_family = config["input"],
55-
output_products = ["sum%d" % i])
53+
m.transform(
54+
add, name="reduce%d" % i, input_family=config["input"], output_products=["sum%d" % i]
55+
)
5656

5757
# now reduce them pair-wise
58-
m.transform(add,
59-
name = "reduce01",
60-
input_family = ["sum0", "sum1"],
61-
output_products = ["sum01"])
62-
m.transform(add,
63-
name = "reduce23",
64-
input_family = ["sum2", "sum3"],
65-
output_products = ["sum23"])
58+
m.transform(add, name="reduce01", input_family=["sum0", "sum1"], output_products=["sum01"])
59+
m.transform(add, name="reduce23", input_family=["sum2", "sum3"], output_products=["sum23"])
6660

6761
# once more (and the configuration will add a verifier)
68-
m.transform(add,
69-
name = "reduce",
70-
input_family = ["sum01", "sum23"],
71-
output_products = ["sum"])
72-
62+
m.transform(add, name="reduce", input_family=["sum01", "sum23"], output_products=["sum"])

test/python/sumit.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def collectify(i: int, j: int) -> npt.NDArray[np.int32]:
2727
"""
2828
return np.array([i, j], dtype=np.int32)
2929

30+
3031
def sum_array(coll: npt.NDArray[np.int32]) -> int:
3132
"""Add the elements of the input collection and return the sum total.
3233
@@ -61,10 +62,5 @@ def PHLEX_REGISTER_ALGORITHMS(m, config):
6162
Returns:
6263
None
6364
"""
64-
m.transform(collectify,
65-
input_family = config["input"],
66-
output_products = ["my_pyarray"])
67-
m.transform(sum_array,
68-
input_family = ["my_pyarray"],
69-
output_products = config["output"])
70-
65+
m.transform(collectify, input_family=config["input"], output_products=["my_pyarray"])
66+
m.transform(sum_array, input_family=["my_pyarray"], output_products=config["output"])

test/python/verify.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
this observer verifies its result against the expected value.
55
"""
66

7+
78
class Verifier:
89
"""A callable class that can assert an expected value.
910
@@ -22,7 +23,7 @@ class Verifier:
2223
AssertionError
2324
"""
2425

25-
__name__ = 'verifier'
26+
__name__ = "verifier"
2627

2728
def __init__(self, sum_total: int):
2829
"""Create a verifier object.
@@ -68,5 +69,4 @@ def PHLEX_REGISTER_ALGORITHMS(m, config):
6869
None
6970
"""
7071
assert_sum = Verifier(config["sum_total"])
71-
m.observe(assert_sum, input_family = config["input"])
72-
72+
m.observe(assert_sum, input_family=config["input"])

0 commit comments

Comments
 (0)