Skip to content

Commit 431ad7f

Browse files
Black reformat for lint (rayolab, navigators, util tests, BYOL diagnostic)
Reformats files added in this PR that fell out of conformance with the project's black config (line-length=100). Pure formatting; no behaviour change. Pairs with the earlier class_registry.py and users.py commits.
1 parent 4907104 commit 431ad7f

9 files changed

Lines changed: 40 additions & 101 deletions

File tree

src/ndi/file/navigator/rhd_series_epochdir.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,7 @@ def selectfilegroups_disk(self) -> list[list[str]]:
127127
epoch_path = os.path.join(base_path, name)
128128
if not os.path.isdir(epoch_path):
129129
continue
130-
groups = ndi_file_navigator_rhd_series._group_directory(
131-
epoch_path, patterns
132-
)
130+
groups = ndi_file_navigator_rhd_series._group_directory(epoch_path, patterns)
133131
for g in groups:
134132
epochfiles_disk.append(g)
135133

tests/symmetry/make_artifacts/file/test_rhd_series_navigator.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,7 @@
2828
from ndi.session.dir import ndi_session_dir
2929
from tests.symmetry.conftest import PYTHON_ARTIFACTS
3030

31-
ARTIFACT_DIR = (
32-
PYTHON_ARTIFACTS
33-
/ "file"
34-
/ "rhdSeriesNavigator"
35-
/ "testRhdSeriesNavigator"
36-
)
31+
ARTIFACT_DIR = PYTHON_ARTIFACTS / "file" / "rhdSeriesNavigator" / "testRhdSeriesNavigator"
3732

3833
# These patterns are identical to the matlab makeArtifacts pair so a
3934
# matlab-written rhd_series_navigator.json round-trips cleanly. The first
@@ -80,9 +75,9 @@ def test_rhd_series_navigator(self):
8075
nav = ndi_file_navigator_rhd_series(self.session, FILEPARAMETERS)
8176

8277
groups = nav.selectfilegroups_disk()
83-
assert len(groups) == 2, (
84-
f"Expected 2 epoch groups from rhd_series navigator, got {len(groups)}."
85-
)
78+
assert (
79+
len(groups) == 2
80+
), f"Expected 2 epoch groups from rhd_series navigator, got {len(groups)}."
8681

8782
epoch_info = []
8883
for i, files in enumerate(groups):

tests/symmetry/make_artifacts/session/test_blank_session_rayolab.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626
from ndi.util import sessionSummary
2727
from tests.symmetry.conftest import PYTHON_ARTIFACTS
2828

29-
ARTIFACT_DIR = (
30-
PYTHON_ARTIFACTS / "session" / "blankSessionRayolab" / "testBlankSessionRayolab"
31-
)
29+
ARTIFACT_DIR = PYTHON_ARTIFACTS / "session" / "blankSessionRayolab" / "testBlankSessionRayolab"
3230

3331

3432
class TestBlankSessionRayolab:

tests/symmetry/make_artifacts/session/test_rayolab_diagnostic.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ def _count(result) -> int:
3535

3636
def _looks_like_daqsystem(props: dict) -> bool:
3737
# The doc has a top-level "daqsystem" struct iff it is a daqsystem doc.
38-
return "daqsystem" in props and "ndi_daqsystem_class" in (
39-
props.get("daqsystem") or {}
40-
)
38+
return "daqsystem" in props and "ndi_daqsystem_class" in (props.get("daqsystem") or {})
4139

4240

4341
class TestRayolabDaqDiagnostic:

tests/symmetry/make_artifacts/util/test_profile.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ def test_profile(self):
4444
ndi_profile.use_backend("memory")
4545
ndi_profile.reset()
4646

47-
uid = ndi_profile.add(
48-
"SymmetryTest", "test@example.org", "not-a-real-secret"
49-
)
47+
uid = ndi_profile.add("SymmetryTest", "test@example.org", "not-a-real-secret")
5048
ndi_profile.set_stage(uid, "dev")
5149
ndi_profile.set_stage(uid, "prod")
5250

tests/symmetry/read_artifacts/file/test_rhd_series_navigator.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,7 @@ class TestRhdSeriesNavigatorReadArtifacts:
3434

3535
def _artifact_dir(self, source_type: str):
3636
return (
37-
SYMMETRY_BASE
38-
/ source_type
39-
/ "file"
40-
/ "rhdSeriesNavigator"
41-
/ "testRhdSeriesNavigator"
37+
SYMMETRY_BASE / source_type / "file" / "rhdSeriesNavigator" / "testRhdSeriesNavigator"
4238
)
4339

4440
def test_rhd_series_navigator(self, tmp_path, source_type):
@@ -50,9 +46,9 @@ def test_rhd_series_navigator(self, tmp_path, source_type):
5046
)
5147

5248
nav_json = artifact_dir / "rhd_series_navigator.json"
53-
assert nav_json.is_file(), (
54-
f"rhd_series_navigator.json missing in {source_type} artifact dir."
55-
)
49+
assert (
50+
nav_json.is_file()
51+
), f"rhd_series_navigator.json missing in {source_type} artifact dir."
5652

5753
expected = json.loads(nav_json.read_text(encoding="utf-8"))
5854
assert expected.get("navigator_class") == "ndi.file.navigator.rhd_series", (
@@ -61,9 +57,7 @@ def test_rhd_series_navigator(self, tmp_path, source_type):
6157
)
6258

6359
fixture_dir = artifact_dir / "fixture"
64-
assert fixture_dir.is_dir(), (
65-
f"fixture directory missing in {source_type}."
66-
)
60+
assert fixture_dir.is_dir(), f"fixture directory missing in {source_type}."
6761

6862
# Copy the fixture into a clean per-test session dir and re-walk
6963
# with a fresh navigator. This mirrors the matlab pair which
@@ -96,9 +90,7 @@ def test_rhd_series_navigator(self, tmp_path, source_type):
9690
f"actual={len(groups)} expected={len(expected_epochs)}."
9791
)
9892

99-
actual_ids = sorted(
100-
nav.epochid(i + 1, files) for i, files in enumerate(groups)
101-
)
93+
actual_ids = sorted(nav.epochid(i + 1, files) for i, files in enumerate(groups))
10294
expected_ids = sorted(str(e["epochid"]) for e in expected_epochs)
10395
assert actual_ids == expected_ids, (
10496
f"Epoch ids mismatch in {source_type}: "

tests/symmetry/read_artifacts/session/test_blank_session_rayolab.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ def test_blank_session_rayolab_daq_systems(self, source_type):
6969
daqs = [daqs]
7070

7171
assert len(daqs) == 2, (
72-
f"Expected 2 DAQ systems in {source_type} rayolab session, "
73-
f"got {len(daqs)}."
72+
f"Expected 2 DAQ systems in {source_type} rayolab session, " f"got {len(daqs)}."
7473
)
7574

7675
names = {getattr(d, "name", "") for d in daqs}
@@ -86,9 +85,7 @@ def test_blank_session_rayolab_daq_systems(self, source_type):
8685
# python-written session both pass this check.
8786
for d in daqs:
8887
nav = getattr(d, "filenavigator", None)
89-
assert nav is not None, (
90-
f"DAQ system {d.name!r} has no filenavigator in {source_type}."
91-
)
88+
assert nav is not None, f"DAQ system {d.name!r} has no filenavigator in {source_type}."
9289
nav_class = getattr(nav, "NDI_FILENAVIGATOR_CLASS", "")
9390
assert nav_class == RHD_SERIES_CLASS, (
9491
f"DAQ system {d.name!r} should use {RHD_SERIES_CLASS} in "

tests/symmetry/read_artifacts/util/test_preferences.py

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,7 @@ class TestPreferencesReadArtifacts:
3434
"""Mirror of ndi.symmetry.readArtifacts.util.preferences."""
3535

3636
def _artifact_dir(self, source_type: str):
37-
return (
38-
SYMMETRY_BASE
39-
/ source_type
40-
/ "util"
41-
/ "preferences"
42-
/ "testPreferences"
43-
)
37+
return SYMMETRY_BASE / source_type / "util" / "preferences" / "testPreferences"
4438

4539
def test_preferences(self, source_type):
4640
artifact_dir = self._artifact_dir(source_type)
@@ -51,14 +45,12 @@ def test_preferences(self, source_type):
5145
)
5246

5347
prefs_path = artifact_dir / "NDI_Preferences.json"
54-
assert prefs_path.is_file(), (
55-
f"NDI_Preferences.json missing in {source_type}."
56-
)
48+
assert prefs_path.is_file(), f"NDI_Preferences.json missing in {source_type}."
5749

5850
payload = json.loads(prefs_path.read_text(encoding="utf-8"))
59-
assert isinstance(payload, dict), (
60-
f"NDI_Preferences.json in {source_type} did not decode to a dict."
61-
)
51+
assert isinstance(
52+
payload, dict
53+
), f"NDI_Preferences.json in {source_type} did not decode to a dict."
6254
assert payload, f"No preference keys in {source_type}."
6355

6456
# Every key must use the Category__[Subcategory__]Name encoding
@@ -76,9 +68,7 @@ def test_preferences(self, source_type):
7668
overrides = json.loads(overrides_path.read_text(encoding="utf-8"))
7769
assert isinstance(overrides, dict)
7870
for okey, oval in overrides.items():
79-
assert okey in payload, (
80-
f"Override key {okey} missing from prefs in {source_type}."
81-
)
71+
assert okey in payload, f"Override key {okey} missing from prefs in {source_type}."
8272
assert payload[okey] == oval, (
8373
f"Override value mismatch for {okey} in {source_type}: "
8474
f"expected {oval!r}, got {payload[okey]!r}."
@@ -98,6 +88,5 @@ def test_preferences(self, source_type):
9888
else:
9989
key = f"{item['category']}__{item['name']}"
10090
assert key in payload, (
101-
f"Python-registered preference {key!r} missing from "
102-
f"{source_type} payload."
91+
f"Python-registered preference {key!r} missing from " f"{source_type} payload."
10392
)

tests/symmetry/read_artifacts/util/test_profile.py

Lines changed: 17 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,7 @@ class TestProfileReadArtifacts:
2626
"""Mirror of ndi.symmetry.readArtifacts.util.profile."""
2727

2828
def _artifact_dir(self, source_type: str):
29-
return (
30-
SYMMETRY_BASE
31-
/ source_type
32-
/ "util"
33-
/ "profile"
34-
/ "testProfile"
35-
)
29+
return SYMMETRY_BASE / source_type / "util" / "profile" / "testProfile"
3630

3731
def test_profile(self, source_type):
3832
artifact_dir = self._artifact_dir(source_type)
@@ -43,52 +37,32 @@ def test_profile(self, source_type):
4337
)
4438

4539
profiles_file = artifact_dir / "NDI_Cloud_Profiles.json"
46-
assert profiles_file.is_file(), (
47-
f"NDI_Cloud_Profiles.json missing in {source_type}."
48-
)
40+
assert profiles_file.is_file(), f"NDI_Cloud_Profiles.json missing in {source_type}."
4941

5042
payload = json.loads(profiles_file.read_text(encoding="utf-8"))
51-
assert isinstance(payload, dict), (
52-
f"Top-level payload should be a JSON object in {source_type}."
53-
)
54-
assert "Profiles" in payload, (
55-
f"Profiles field missing in {source_type}."
56-
)
57-
assert "DefaultUID" in payload, (
58-
f"DefaultUID field missing in {source_type}."
59-
)
43+
assert isinstance(
44+
payload, dict
45+
), f"Top-level payload should be a JSON object in {source_type}."
46+
assert "Profiles" in payload, f"Profiles field missing in {source_type}."
47+
assert "DefaultUID" in payload, f"DefaultUID field missing in {source_type}."
6048

6149
profiles = payload["Profiles"]
6250
if isinstance(profiles, dict):
6351
arr = [profiles]
6452
elif isinstance(profiles, list):
6553
arr = profiles
6654
else:
67-
pytest.fail(
68-
f"Unexpected Profiles type {type(profiles).__name__} in "
69-
f"{source_type}."
70-
)
55+
pytest.fail(f"Unexpected Profiles type {type(profiles).__name__} in " f"{source_type}.")
7156

7257
assert len(arr) == 1, (
73-
f"Expected exactly one profile entry in {source_type}, "
74-
f"got {len(arr)}."
58+
f"Expected exactly one profile entry in {source_type}, " f"got {len(arr)}."
7559
)
7660
p = arr[0]
77-
assert isinstance(p, dict), (
78-
f"Profile entry should be an object in {source_type}."
79-
)
80-
assert p.get("UID"), (
81-
f"UID missing in {source_type} profile."
82-
)
83-
assert p.get("Nickname") == "SymmetryTest", (
84-
f"Nickname mismatch in {source_type}."
85-
)
86-
assert p.get("Email") == "test@example.org", (
87-
f"Email mismatch in {source_type}."
88-
)
89-
assert p.get("Stage") == "test", (
90-
f"Stage should be 'test' in {source_type}."
91-
)
92-
assert "PasswordSecret" not in p, (
93-
f"PasswordSecret must not be persisted on disk in {source_type}."
94-
)
61+
assert isinstance(p, dict), f"Profile entry should be an object in {source_type}."
62+
assert p.get("UID"), f"UID missing in {source_type} profile."
63+
assert p.get("Nickname") == "SymmetryTest", f"Nickname mismatch in {source_type}."
64+
assert p.get("Email") == "test@example.org", f"Email mismatch in {source_type}."
65+
assert p.get("Stage") == "test", f"Stage should be 'test' in {source_type}."
66+
assert (
67+
"PasswordSecret" not in p
68+
), f"PasswordSecret must not be persisted on disk in {source_type}."

0 commit comments

Comments
 (0)