Skip to content

Commit 4cb28b6

Browse files
authored
Merge pull request #396 from grahamfindlay/bugfix/missing-context-manager
Fix unclosed file warnings in json.load() calls
2 parents bbeb144 + c925f26 commit 4cb28b6

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/probeinterface/neuropixels_tools.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def _load_np_probe_features():
2828
global _np_probe_features
2929
if _np_probe_features is None:
3030
probe_features_filepath = Path(__file__).absolute().parent / Path("resources/neuropixels_probe_features.json")
31-
_np_probe_features = json.load(open(probe_features_filepath, "r"))
31+
with open(probe_features_filepath, "r") as f:
32+
_np_probe_features = json.load(f)
3233
return _np_probe_features
3334

3435

src/probeinterface/testing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
from probeinterface import __version__ as version
55

66
json_schema_file = Path(__file__).absolute().parent / "schema" / "probe.json.schema"
7-
schema = json.load(open(json_schema_file, "r"))
7+
with open(json_schema_file, "r") as f:
8+
schema = json.load(f)
89

910

1011
def validate_probe_dict(probe_dict):

0 commit comments

Comments
 (0)