Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

### Adjustments and Enhancements

- Added support for validating Zarr and HDF-5 groups and their items.
Rules can now validate `xarray.DataTree` objects originating
from `xarray.open_datatree()` by implementing
rule operation method `RuleOp.validate_datatree(ctx, node)`. (#54)

- Added a new core rule `var-missing-data` that checks for the recommended
use of a variable's missing data.

Expand Down Expand Up @@ -48,6 +53,8 @@
- added class method `from_config()` to `ConfigList`.
- removed function `xrlint.config.merge_configs` as it was no longer used.

- Removed class method `Result.new()` as it was no longer used.

### Other changes

- XRLint now works with zarr >=2,<3 and zarr >=3.0.2
Expand Down
4 changes: 2 additions & 2 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This chapter provides a plain reference for the XRLint Python API.
- The `node` module defines the nodes passed to [RuleOp][xrlint.rule.RuleOp]:
base classes [None][xrlint.node.Node], [XarrayNode][xrlint.node.XarrayNode],
and the specific [DatasetNode][xrlint.node.DatasetNode],
[DataArray][xrlint.node.DataArrayNode], [AttrsNode][xrlint.node.AttrsNode],
[VariableNode][xrlint.node.VariableNode], [AttrsNode][xrlint.node.AttrsNode],
and [AttrNode][xrlint.node.AttrNode] nodes.
- The `processor` module provides processor related classes and functions:
[Processor][xrlint.processor.Processor] comprising processor metadata
Expand Down Expand Up @@ -84,7 +84,7 @@ Note:

::: xrlint.node.DatasetNode

::: xrlint.node.DataArrayNode
::: xrlint.node.VariableNode

::: xrlint.node.AttrsNode

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ authors = [
]
description = "A linter for xarray datasets."
keywords = [
"xarray"
"xarray", "data-science", "cf", "metadata"
]
license = {text = "MIT"}
requires-python = ">=3.10"
Expand Down
6 changes: 3 additions & 3 deletions tests/_linter/test_rulectx.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# noinspection PyProtectedMember
from xrlint._linter.rulectx import RuleContextImpl
from xrlint.config import ConfigObject
from xrlint.constants import NODE_ROOT_NAME
from xrlint.constants import DATASET_ROOT_NAME
from xrlint.result import Message, Suggestion


Expand Down Expand Up @@ -39,7 +39,7 @@ def test_report(self):
[
Message(
message="What the heck do you mean?",
node_path=NODE_ROOT_NAME,
node_path=DATASET_ROOT_NAME,
rule_id="no-xxx",
severity=2,
suggestions=[
Expand All @@ -48,7 +48,7 @@ def test_report(self):
),
Message(
message="You said it.",
node_path=NODE_ROOT_NAME,
node_path=DATASET_ROOT_NAME,
rule_id="no-xxx",
severity=2,
fatal=True,
Expand Down
3 changes: 3 additions & 0 deletions tests/cli/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ def xrlint(self, *args: tuple[str, ...]) -> click.testing.Result:
runner = CliRunner()
result = runner.invoke(main, args)
if not isinstance(result.exception, SystemExit):
import traceback

traceback.print_exception(result.exception)
self.assertIsNone(result.exception)
return result

Expand Down
8 changes: 4 additions & 4 deletions tests/formatters/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ class Rule2(RuleOp):
config_obj = ConfigObject(plugins={"test": plugin})

return [
Result.new(
config_object=config_obj,
Result(
file_path="test.nc",
config_object=config_obj,
messages=[
Message(
message="message-1",
Expand All @@ -64,9 +64,9 @@ class Rule2(RuleOp):
Message(message="message-3", fatal=True),
],
),
Result.new(
Result(
file_path="test.nc",
config_object=config_obj,
file_path="test-2.nc",
messages=[
Message(message="message-1", rule_id="test/rule-1", severity=1),
Message(message="message-2", rule_id="test/rule-2", severity=2),
Expand Down
8 changes: 4 additions & 4 deletions tests/formatters/test_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

class SimpleTest(TestCase):
errors_and_warnings = [
Result.new(
config_object=ConfigObject(),
Result(
file_path="test1.nc",
config_object=ConfigObject(),
messages=[
Message(message="what", rule_id="rule-1", severity=2),
Message(message="is", fatal=True),
Expand All @@ -24,9 +24,9 @@ class SimpleTest(TestCase):
]

warnings_only = [
Result.new(
ConfigObject(),
Result(
file_path="test2.nc",
config_object=ConfigObject(),
messages=[
Message(message="what", rule_id="rule-1", severity=1),
Message(message="happened?", rule_id="rule-2", severity=1),
Expand Down
8 changes: 5 additions & 3 deletions tests/plugins/core/rules/test_access_latency.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# noinspection PyProtectedMember
from xrlint._linter.rulectx import RuleContextImpl
from xrlint.config import ConfigObject
from xrlint.constants import DATASET_ROOT_NAME
from xrlint.node import DatasetNode
from xrlint.plugins.core.rules.access_latency import AccessLatency
from xrlint.result import Message
Expand All @@ -33,8 +34,9 @@ def invoke_op(
access_latency=access_latency,
)
node = DatasetNode(
path="dataset",
parent=None,
path=DATASET_ROOT_NAME,
name=DATASET_ROOT_NAME,
dataset=ctx.dataset,
)
rule_op = (
Expand All @@ -59,7 +61,7 @@ def test_invalid(self):
[
Message(
message="Access latency exceeds threshold: 3.2 > 2.5 seconds.",
node_path="dataset",
node_path=DATASET_ROOT_NAME,
severity=2,
)
],
Expand All @@ -71,7 +73,7 @@ def test_invalid(self):
[
Message(
message="Access latency exceeds threshold: 0.2 > 0.1 seconds.",
node_path="dataset",
node_path=DATASET_ROOT_NAME,
severity=2,
)
],
Expand Down
Loading