Skip to content

Commit

Permalink
run pre-commit on new changes only
Browse files Browse the repository at this point in the history
  • Loading branch information
ocefpaf committed May 23, 2024
1 parent ec50124 commit 8f615c3
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 22 deletions.
38 changes: 28 additions & 10 deletions cc_plugin_glider/glider_dac.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,11 @@ def check_lat_lon_attributes(self, dataset):

check_vars = ["lat", "lon"]
for var in check_vars:
stat, num_checks, msgs = util._check_variable_attrs(dataset, var, options=self.options)
stat, num_checks, msgs = util._check_variable_attrs(
dataset,
var,
options=self.options,
)
score += int(stat)
out_of += num_checks
messages.extend(msgs)
Expand Down Expand Up @@ -238,7 +242,11 @@ def check_pressure_depth_attributes(self, dataset):

check_vars = ["pressure", "depth"]
for var in check_vars:
stat, num_checks, msgs = util._check_variable_attrs(dataset, var, options=self.options)
stat, num_checks, msgs = util._check_variable_attrs(
dataset,
var,
options=self.options,
)
score += int(stat)
out_of += num_checks
messages.extend(msgs)
Expand All @@ -263,7 +271,11 @@ def check_ctd_variable_attributes(self, dataset):

check_vars = ["temperature", "conductivity", "salinity", "density"]
for var in check_vars:
stat, num_checks, msgs = util._check_variable_attrs(dataset, var, options=self.options)
stat, num_checks, msgs = util._check_variable_attrs(
dataset,
var,
options=self.options,
)
score += int(stat)
out_of += num_checks
messages.extend(msgs)
Expand Down Expand Up @@ -291,7 +303,11 @@ def check_profile_variable_attributes_and_types(self, dataset):
"v",
]
for var in check_vars:
stat, num_checks, msgs = util._check_variable_attrs(dataset, var, options=self.options)
stat, num_checks, msgs = util._check_variable_attrs(
dataset,
var,
options=self.options,
)
score += int(stat)
out_of += num_checks
messages.extend(msgs)
Expand Down Expand Up @@ -598,7 +614,11 @@ def check_container_variables(self, dataset):
"instrument_ctd",
]
for var in check_vars:
stat, num_checks, msgs = util._check_variable_attrs(dataset, var, options=self.options)
stat, num_checks, msgs = util._check_variable_attrs(
dataset,
var,
options=self.options,
)
score += int(stat)
out_of += num_checks
messages.extend(msgs)
Expand Down Expand Up @@ -693,9 +713,7 @@ def check_ancillary_variables(self, dataset):
test = acv in dataset.variables
score += int(test)
if not test:
msg = (
f"Invalid ancillary_variables attribute for {var}, {acv} is not a variable"
)
msg = f"Invalid ancillary_variables attribute for {var}, {acv} is not a variable"
messages.append(msg)

return self.make_result(level, score, out_of, "Ancillary Variables", messages)
Expand Down Expand Up @@ -746,7 +764,7 @@ def check_valid_min_dtype(self, dataset):
if valid_min is not None:
test_ctx.assert_true(
util.compare_dtype(np.dtype(valid_min_dtype), ncvar.dtype),
f"{var_name}:valid_min has a different data type, {valid_min_dtype}, than variable {var_name}, {ncvar.dtype}"
f"{var_name}:valid_min has a different data type, {valid_min_dtype}, than variable {var_name}, {ncvar.dtype}",
)

return test_ctx.to_result()
Expand All @@ -773,7 +791,7 @@ def check_valid_max_dtype(self, dataset):
if valid_max is not None:
test_ctx.assert_true(
util.compare_dtype(np.dtype(valid_max_dtype), ncvar.dtype),
f"{var_name}:valid_max has a different data type, {valid_max_dtype}, than variable {ncvar.dtype} {var_name}"
f"{var_name}:valid_max has a different data type, {valid_max_dtype}, than variable {ncvar.dtype} {var_name}",
)

return test_ctx.to_result()
Expand Down
6 changes: 3 additions & 3 deletions cc_plugin_glider/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ def _check_variable_attrs(dataset, var_name, required_attributes=None, options=N
# Get the expected attrs to check
check_attrs = required_attributes or required_var_attrs.get(var_name, {})
if not options is None:
if 'ancillary_variables' in check_attrs and 'no_ancillary_variables' in options:
del check_attrs['ancillary_variables']
if "ancillary_variables" in check_attrs and "no_ancillary_variables" in options:
del check_attrs["ancillary_variables"]
var_attrs = set(var.ncattrs())
for attr in check_attrs:
if attr == "dtype":
Expand Down Expand Up @@ -112,7 +112,7 @@ def _check_variable_attrs(dataset, var_name, required_attributes=None, options=N
score -= 1
else:
messages.append(
f"Variable {var_name} attribute {attr} must be {check_attrs[attr]}"
f"Variable {var_name} attribute {attr} must be {check_attrs[attr]}",
)
score -= 1
else:
Expand Down
18 changes: 9 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@ write_to_template = "__version__ = '{version}'"
tag_regex = "^(?P<prefix>v)?(?P<version>[^\\+]+)(?P<suffix>.*)?$"

[tool.ruff]
lint.select = [
"A", # flake8-builtins
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"F", # flakes
"I", # import sorting
"T20", # flake8-print
"UP", # upgrade
]
target-version = "py38"
line-length = 79

lint.select = [
"A", # flake8-builtins
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"F", # flakes
"I", # import sorting
"T20", # flake8-print
"UP", # upgrade
]
select = [
"A", # flake8-builtins
"B", # flake8-bugbear
Expand Down

0 comments on commit 8f615c3

Please sign in to comment.