Skip to content

Commit 81655fb

Browse files
Apply suggestions from code review
Co-authored-by: Chris Markiewicz <[email protected]>
1 parent ba70673 commit 81655fb

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

nibabel/loadsave.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def _signature_matches_extension(filename):
5353
try:
5454
with open(filename, "rb") as fh:
5555
found_signature = fh.read(len(expected_signature))
56-
except Exception:
56+
except OSError:
5757
return False, f"Could not read file: {filename}"
5858
if found_signature == expected_signature:
5959
return True, ""

nibabel/tests/test_loadsave.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ def test_load_empty_image():
7878

7979
@pytest.mark.parametrize("extension", [".gz", ".bz2"])
8080
def test_load_bad_compressed_extension(tmp_path, extension):
81-
file_path = tmp_path.joinpath(f"img.nii{extension}")
81+
file_path = tmp_path / f"img.nii{extension}"
8282
file_path.write_bytes(b"bad")
8383
with pytest.raises(ImageFileError, match=".*is not a .* file"):
8484
load(file_path)
8585

8686

8787
def test_load_file_that_cannot_be_read(tmp_path):
88-
subdir = tmp_path.joinpath("img.nii.gz")
88+
subdir = tmp_path / "img.nii.gz"
8989
subdir.mkdir()
9090
with pytest.raises(ImageFileError, match="Could not read"):
9191
load(subdir)

0 commit comments

Comments
 (0)