Skip to content

Commit 8a2a6e4

Browse files
committed
Fix type hints issues
1 parent dfbc2e5 commit 8a2a6e4

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

pygmt/datatypes/header.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
import ctypes as ctp
6-
from typing import ClassVar
6+
from typing import ClassVar, Any
77

88
import numpy as np
99

@@ -143,26 +143,21 @@ class _GMT_GRID_HEADER(ctp.Structure): # noqa: N801
143143
("hidden", ctp.c_void_p),
144144
]
145145

146-
def _parse_dimensions(self) -> dict[str, list]:
146+
def _parse_dimensions(self):
147147
"""
148148
Get dimension names and attributes from the grid header.
149149
150150
For a 2-D grid, the dimension names are set to "y" and "x" by default. The
151151
attributes for each dimension are parsed from the grid header following GMT
152152
source codes. See the GMT functions "gmtnc_put_units", "gmtnc_get_units" and
153153
"gmtnc_grd_info" for reference.
154-
155-
Returns
156-
-------
157-
dict
158-
Dictionary containing the list of dimension names and attributes.
159154
"""
160155
# Default dimension names.
161-
dims: tuple = ("y", "x")
156+
dims = ("y", "x")
162157
nameunits = (self.y_units, self.x_units)
163158

164159
# Dictionary for dimension attributes with the dimension name as the key.
165-
attrs: dict = {dim: {} for dim in dims}
160+
attrs = {dim: {} for dim in dims}
166161
# Dictionary for mapping the default dimension names to the actual names.
167162
newdims = {dim: dim for dim in dims}
168163
# Loop over dimensions and get the dimension name and attributes from header
@@ -214,16 +209,17 @@ def get_data_attrs(self) -> dict:
214209
attrs
215210
The attributes for the data variable.
216211
"""
217-
attrs = {"Conventions": "CF-1.7"}
212+
attrs : dict[str, Any] = {}
213+
attrs["Conventions"] = "CF-1.7"
214+
attrs["title"] = self.title
215+
attrs["history"] = self.command
216+
attrs["description"] = self.remark
218217
long_name, units = _parse_nameunits(self.z_units.decode())
219218
if long_name:
220219
attrs["long_name"] = long_name
221220
if units:
222221
attrs["units"] = units
223222
attrs["actual_range"] = np.array([self.z_min, self.z_max])
224-
attrs["title"] = self.title
225-
attrs["history"] = self.command
226-
attrs["description"] = self.remark
227223
return attrs
228224

229225
def get_dims(self):

0 commit comments

Comments
 (0)