Skip to content

STYLE: Fix type checking errors in volumeutils.rec2dict #1424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions nibabel/volumeutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from functools import reduce
from operator import getitem, mul
from os.path import exists, splitext
from typing import Any

import numpy as np

Expand Down Expand Up @@ -1365,7 +1366,7 @@
return aff


def rec2dict(rec: np.ndarray) -> dict[str, np.generic | np.ndarray]:
def rec2dict(rec: np.ndarray) -> dict[str, Any]:
"""Convert recarray to dictionary

Also converts scalar values to scalars
Expand All @@ -1387,7 +1388,9 @@
>>> d == {'x': 0, 's': b''}
True
"""
dct = {}
dct: dict[str, Any] = {}
if rec.dtype.fields is None:
return dct

Check warning on line 1393 in nibabel/volumeutils.py

View check run for this annotation

Codecov / codecov/patch

nibabel/volumeutils.py#L1393

Added line #L1393 was not covered by tests
for key in rec.dtype.fields:
val = rec[key]
try:
Expand Down
Loading