Skip to content

Commit cb68aef

Browse files
committed
Pass tests
1 parent a6d6cc9 commit cb68aef

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

src/input4mips_validation/validation/comment.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,7 @@ def validate_comment(comment: str) -> None:
2020
`comment`'s value is not a string
2121
"""
2222
if not isinstance(comment, str):
23-
msg = f"The `comment` attribute must be a string, received {comment=!r}."
23+
msg = ( # type: ignore[unreachable]
24+
f"The `comment` attribute must be a string, received {comment=!r}."
25+
)
2426
raise TypeError(msg)

src/input4mips_validation/validation/datasets_to_write_to_disk.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,10 @@ def get_ds_to_write_to_disk_validation_result(
183183
vrs = ValidationResultsStore()
184184

185185
# Metadata that can be validated standalone
186-
verification_standalone_l = [
186+
verification_standalone = (
187187
("creation_date", validate_creation_date),
188188
("tracking_id", validate_tracking_id),
189-
]
190-
# Optional attributes
191-
for optional_attr, verification_func in (("comment", validate_comment),):
192-
if optional_attr in ds.attrs:
193-
verification_standalone_l.append((optional_attr, verification_func))
194-
195-
verification_standalone = tuple(verification_standalone_l)
189+
)
196190

197191
# Metadata that depends on the data
198192
ds_variables = xr_variable_processor.get_ds_variables(
@@ -227,6 +221,16 @@ def get_ds_to_write_to_disk_validation_result(
227221
func_description=f"Validate the {attribute!r} attribute",
228222
)(ds, attribute, validation_function)
229223

224+
# Optional attributes
225+
for attribute_optional, validation_function_optional in (
226+
("comment", validate_comment),
227+
):
228+
if attribute_optional in ds.attrs:
229+
vrs.wrap(
230+
validate_attribute,
231+
func_description=f"Validate the {attribute_optional!r} attribute",
232+
)(ds, attribute_optional, validation_function_optional)
233+
230234
# Metadata that is defined by the combination of other metadata and the CVs
231235
verification_defined_by_cvs_and_other_metadata = (
232236
(

0 commit comments

Comments
 (0)