Skip to content

Commit 583936b

Browse files
committed
typing
1 parent 01efbb8 commit 583936b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

parcels/field.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@
5252

5353
from parcels.fieldset import FieldSet
5454

55-
T_SanitizedFilenames = list[str] | dict[str, list[str]]
55+
T_Dimensions = Literal["lon", "lat", "depth", "data"]
56+
T_SanitizedFilenames = list[str] | dict[T_Dimensions, list[str]]
5657

5758
__all__ = ["Field", "NestedField", "VectorField"]
5859

@@ -580,10 +581,10 @@ def from_netcdf(
580581
)
581582
lonlat_filename = lonlat_filename_lst[0]
582583
if "depth" in dimensions:
583-
depth_filename = _get_dim_filenames(filenames, "depth")
584-
if isinstance(filenames, dict) and len(depth_filename) != 1:
584+
depth_filename_lst = _get_dim_filenames(filenames, "depth")
585+
if isinstance(filenames, dict) and len(depth_filename_lst) != 1:
585586
raise NotImplementedError("Vertically adaptive meshes not implemented for from_netcdf()")
586-
depth_filename = depth_filename[0]
587+
depth_filename = depth_filename_lst[0]
587588

588589
netcdf_engine = kwargs.pop("netcdf_engine", "netcdf4")
589590
gridindexingtype = kwargs.get("gridindexingtype", "nemo")
@@ -2553,7 +2554,7 @@ def __getitem__(self, key):
25532554
return val
25542555

25552556

2556-
def _get_dim_filenames(filenames: T_SanitizedFilenames, dim: str) -> list[str]:
2557+
def _get_dim_filenames(filenames: T_SanitizedFilenames, dim: T_Dimensions) -> list[str]:
25572558
"""Get's the relevant filenames for a given dimension."""
25582559
if isinstance(filenames, list):
25592560
return filenames

0 commit comments

Comments
 (0)