Skip to content

Commit 6c87165

Browse files
committed
Black reformating
1 parent 5e902c6 commit 6c87165

3 files changed

Lines changed: 19 additions & 9 deletions

File tree

pathways/pathways.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,7 @@ def _load_array(filepath):
8181
elif Path(filepath[0]).suffix == ".json":
8282
with open(filepath[0], encoding="utf-8") as f:
8383
payload = json.load(f)
84-
return {
85-
tuple(item["activity"]): int(item["index"])
86-
for item in payload
87-
}
84+
return {tuple(item["activity"]): int(item["index"]) for item in payload}
8885
elif Path(filepath[0]).suffix == ".pkl":
8986
if not ALLOW_UNSAFE_PICKLE:
9087
raise ValueError(

pathways/utils.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,9 @@ def load_units_conversion() -> dict:
239239
with open(UNITS_CONVERSION, "r") as f:
240240
data = yaml.safe_load(f)
241241
if not isinstance(data, dict):
242-
raise ValueError("Invalid units conversion mapping: expected a YAML dictionary.")
242+
raise ValueError(
243+
"Invalid units conversion mapping: expected a YAML dictionary."
244+
)
243245

244246
return data
245247

@@ -508,7 +510,9 @@ def clean_cache_directory():
508510
f"Expected: {allowed_dir}. Set PATHWAYS_ALLOW_UNSAFE_CACHE_DELETE=1 to override."
509511
)
510512
if not cache_dir.exists() or not cache_dir.is_dir():
511-
raise ValueError(f"Cache directory does not exist or is not a directory: {cache_dir}")
513+
raise ValueError(
514+
f"Cache directory does not exist or is not a directory: {cache_dir}"
515+
)
512516

513517
allowed_suffixes = {".npy", ".npz", ".json", ".pkl"}
514518
removed = 0
@@ -793,7 +797,9 @@ def csv_to_dict(filename: str) -> dict[int, tuple[str, ...]]:
793797
output_dict[int(value)] = key
794798
except ValueError:
795799
logging.warning(
796-
"Row %s has a non-integer index value '%s'; skipping.", row, value
800+
"Row %s has a non-integer index value '%s'; skipping.",
801+
row,
802+
value,
797803
)
798804
else:
799805
logging.warning(f"Row {row} has less than 5 items.")

tests/test_utilities.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,9 @@ def test_clean_cache_directory(tmp_path, monkeypatch):
186186

187187
clean_cache_directory()
188188

189-
assert not (cache_dir / "temp_cache_file.npy").exists(), "Cache file was not deleted"
189+
assert not (
190+
cache_dir / "temp_cache_file.npy"
191+
).exists(), "Cache file was not deleted"
190192
assert (
191193
non_cache_dir / "temp_non_cache_file"
192194
).exists(), "Non-cache file was incorrectly deleted"
@@ -205,7 +207,12 @@ def test_clean_cache_directory_rejects_unsafe_path(tmp_path, monkeypatch):
205207
def test_apply_filters_path_matching_is_not_character_based():
206208
technosphere = {("alpha plant", "prod", "EU", "kg"): 1}
207209
filters = {"name_fltr": [], "name_mask": [], "product_fltr": [], "product_mask": []}
208-
exceptions = {"name_fltr": [], "name_mask": [], "product_fltr": [], "product_mask": []}
210+
exceptions = {
211+
"name_fltr": [],
212+
"name_mask": [],
213+
"product_fltr": [],
214+
"product_mask": [],
215+
}
209216
paths = [["ab"]]
210217

211218
_, _, filtered_names, _ = apply_filters(technosphere, filters, exceptions, paths)

0 commit comments

Comments
 (0)