Skip to content

Commit a7e94b0

Browse files
cmacmackingithub-actions[bot]
authored andcommitted
Apply ruff changes
1 parent 843b676 commit a7e94b0

File tree

2 files changed

+30
-9
lines changed

2 files changed

+30
-9
lines changed

src/boutupgrader/bout_v5_input_file_upgrader.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,9 @@ def run_general(REPLACEMENTS, DELETED, args, *, additional_modifications=None):
326326
continue
327327

328328
try:
329-
modified = apply_fixes(REPLACEMENTS, DELETED, original, additional_modifications)
329+
modified = apply_fixes(
330+
REPLACEMENTS, DELETED, original, additional_modifications
331+
)
330332
except RuntimeError as e:
331333
print(e)
332334
continue

src/boutupgrader/hermes_collisions_input_file_upgrader.py

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
1+
import re
12
from itertools import chain
23
from typing import TypedDict
3-
import re
44

5-
from .bout_v5_input_file_upgrader import add_parser_general, run_general
65
from boutdata.data import BoutOptionsFile
76

7+
from .bout_v5_input_file_upgrader import add_parser_general, run_general
8+
9+
810
class Replacement(TypedDict):
911
old: str
1012
new: str
1113

14+
1215
REPLACEMENTS = []
1316
DELETED = []
1417

1518
NEW_NAMES = {
16-
"collisions": ["braginskii_collisions", "braginskii_friction", "braginskii_heat_exchange"],
19+
"collisions": [
20+
"braginskii_collisions",
21+
"braginskii_friction",
22+
"braginskii_heat_exchange",
23+
],
1724
"electron_viscosity": ["braginskii_electron_viscosity"],
1825
"ion_viscosity": ["braginskii_ion_viscosity"],
19-
"thermal_force": ["braginskii_thermal_force"]
26+
"thermal_force": ["braginskii_thermal_force"],
2027
}
2128

2229
COMPONENT_RE = re.compile(r"[+\-\w]+")
@@ -30,7 +37,11 @@ def update_component_names(options_file: BoutOptionsFile) -> None:
3037
for section_name in components:
3138
section = options_file.getSection(section_name)
3239
explicit_types = "type" in section
33-
types = [tname.strip() for tname in section["type"].split(",")] if explicit_types else [section_name]
40+
types = (
41+
[tname.strip() for tname in section["type"].split(",")]
42+
if explicit_types
43+
else [section_name]
44+
)
3445
open_paren = types[0][0] == "("
3546
close_paren = types[-1][-1] == ")"
3647
if open_paren:
@@ -42,7 +53,11 @@ def update_component_names(options_file: BoutOptionsFile) -> None:
4253
if "recycling" in new_types:
4354
recycling_component = section_name
4455
if new_types != types:
45-
section["type"] = ("(" if open_paren else "") + ", ".join(new_types) + (")" if close_paren else "")
56+
section["type"] = (
57+
("(" if open_paren else "")
58+
+ ", ".join(new_types)
59+
+ (")" if close_paren else "")
60+
)
4661
# Add braginskii_conduction to the end of the list of components
4762
if has_collisions:
4863
components.append("braginskii_conduction")
@@ -52,8 +67,12 @@ def update_component_names(options_file: BoutOptionsFile) -> None:
5267
components.append(recycling_component)
5368
options_file["hermes:components"] = "(" + ", ".join(components) + ")"
5469

70+
5571
def run(args) -> None:
56-
run_general(REPLACEMENTS, DELETED, args, additional_modifications=update_component_names)
57-
72+
run_general(
73+
REPLACEMENTS, DELETED, args, additional_modifications=update_component_names
74+
)
75+
76+
5877
def add_parser(subcommand, default_args, files_args):
5978
return add_parser_general(subcommand, default_args, files_args, run, "Hermes-3")

0 commit comments

Comments
 (0)