Skip to content

Commit

Permalink
Pass tests
Browse files Browse the repository at this point in the history
  • Loading branch information
znichollscr committed Dec 16, 2024
1 parent 06b4aee commit f414248
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/input4mips_validation/validation/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ def validate_comment(comment: str) -> None:
`comment`'s value is not a string
"""
if not isinstance(comment, str):
msg = f"The `comment` attribute must be a string, received {comment=!r}."
msg = ( # type: ignore[unreachable]
f"The `comment` attribute must be a string, received {comment=!r}."
)
raise TypeError(msg)
20 changes: 12 additions & 8 deletions src/input4mips_validation/validation/datasets_to_write_to_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,10 @@ def get_ds_to_write_to_disk_validation_result(
vrs = ValidationResultsStore()

# Metadata that can be validated standalone
verification_standalone_l = [
verification_standalone = (
("creation_date", validate_creation_date),
("tracking_id", validate_tracking_id),
]
# Optional attributes
for optional_attr, verification_func in (("comment", validate_comment),):
if optional_attr in ds.attrs:
verification_standalone_l.append((optional_attr, verification_func))

verification_standalone = tuple(verification_standalone_l)
)

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

# Optional attributes
for attribute_optional, validation_function_optional in (
("comment", validate_comment),
):
if attribute_optional in ds.attrs:
vrs.wrap(
validate_attribute,
func_description=f"Validate the {attribute_optional!r} attribute",
)(ds, attribute_optional, validation_function_optional)

# Metadata that is defined by the combination of other metadata and the CVs
verification_defined_by_cvs_and_other_metadata = (
(
Expand Down

0 comments on commit f414248

Please sign in to comment.