Skip to content

Commit 43af996

Browse files
committed
changed signature of read_metadata to have collection instead of sequence
1 parent 5bc47fc commit 43af996

File tree

7 files changed

+10
-10
lines changed

7 files changed

+10
-10
lines changed

extras/fileformats/extras/application/medical.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
@extra_implementation(FileSet.read_metadata)
1111
def dicom_read_metadata(
12-
dicom: Dicom, selected_keys: ty.Optional[ty.Sequence[str]] = None
12+
dicom: Dicom, selected_keys: ty.Optional[ty.Collection[str]] = None
1313
) -> ty.Mapping[str, ty.Any]:
1414
dcm = pydicom.dcmread(
1515
dicom.fspath,

fileformats/core/fileset.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ class FileSet(DataType):
9292
# Member attributes
9393
fspaths: ty.FrozenSet[Path]
9494
_explicit_metadata: ty.Optional[ty.Mapping[str, ty.Any]]
95-
_metadata_keys: ty.Optional[ty.List[str]]
95+
_metadata_keys: ty.Optional[ty.Collection[str]]
9696

9797
def __init__(
9898
self,
9999
fspaths: FspathsInputType,
100100
metadata: ty.Optional[ty.Dict[str, ty.Any]] = None,
101-
metadata_keys: ty.Optional[ty.List[str]] = None,
101+
metadata_keys: ty.Optional[ty.Collection[str]] = None,
102102
):
103103
self._explicit_metadata = metadata
104104
self._metadata_keys = metadata_keys
@@ -263,7 +263,7 @@ def metadata(self) -> ty.Mapping[str, ty.Any]:
263263

264264
@extra
265265
def read_metadata(
266-
self, selected_keys: ty.Optional[ty.Sequence[str]] = None
266+
self, selected_keys: ty.Optional[ty.Collection[str]] = None
267267
) -> ty.Mapping[str, ty.Any]:
268268
"""Reads any metadata associated with the fileset and returns it as a dict
269269

fileformats/core/mixin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def header(self) -> "fileformats.core.FileSet":
183183
return self.header_type(self.select_by_ext(self.header_type)) # type: ignore[attr-defined]
184184

185185
def read_metadata(
186-
self, selected_keys: ty.Optional[ty.Sequence[str]] = None
186+
self, selected_keys: ty.Optional[ty.Collection[str]] = None
187187
) -> ty.Mapping[str, ty.Any]:
188188
header: ty.Dict[str, ty.Any] = self.header.load() # type: ignore[attr-defined]
189189
if selected_keys:
@@ -221,7 +221,7 @@ def side_cars(self) -> ty.Tuple["fileformats.core.FileSet", ...]:
221221
return tuple(tp(self.select_by_ext(tp)) for tp in self.side_car_types) # type: ignore[attr-defined]
222222

223223
def read_metadata(
224-
self, selected_keys: ty.Optional[ty.Sequence[str]] = None
224+
self, selected_keys: ty.Optional[ty.Collection[str]] = None
225225
) -> ty.Mapping[str, ty.Any]:
226226
metadata: ty.Dict[str, ty.Any] = dict(self.primary_type.read_metadata(self, selected_keys=selected_keys)) # type: ignore[arg-type]
227227
for side_car in self.side_cars:

fileformats/core/tests/test_general.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class ImageWithInlineHeader(File):
135135
header_separator = b"---END HEADER---"
136136

137137
def read_metadata(
138-
self, selected_keys: ty.Optional[ty.Sequence[str]] = None
138+
self, selected_keys: ty.Optional[ty.Collection[str]] = None
139139
) -> ty.Mapping[str, ty.Any]:
140140
hdr = self.contents.split(self.header_separator)[0].decode("utf-8")
141141
return {k: int(v) for k, v in (ln.split(":") for ln in hdr.splitlines())}

fileformats/core/tests/test_metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class FileWithMetadata(File):
1111

1212
@extra_implementation(FileSet.read_metadata)
1313
def aformat_read_metadata(
14-
mf: FileWithMetadata, selected_keys: ty.Optional[ty.Sequence[str]] = None
14+
mf: FileWithMetadata, selected_keys: ty.Optional[ty.Collection[str]] = None
1515
) -> ty.Mapping[str, ty.Any]:
1616
with open(mf) as f:
1717
metadata = f.read()

fileformats/core/tests/test_mixin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class ImageWithInlineHeader(File):
108108
header_separator = b"---END HEADER---"
109109

110110
def read_metadata(
111-
self, selected_keys: ty.Optional[ty.Sequence[str]] = None
111+
self, selected_keys: ty.Optional[ty.Collection[str]] = None
112112
) -> ty.Mapping[str, ty.Any]:
113113
hdr = self.contents.split(self.header_separator)[0].decode("utf-8")
114114
return dict(ln.split(":") for ln in hdr.splitlines())

fileformats/image/raster.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
DataArrayType: TypeAlias = (
1515
ty.Any
16-
) # "numpy.typing.NDArray[ty.Union[np.float_, np.int_]]"
16+
) # "numpy.typing.NDArray[ty.Union[np.floating, np.integer]]"
1717

1818

1919
class RasterImage(Image):

0 commit comments

Comments
 (0)