plexus.linting.yaml_linter module

Core YAML DSL Linter Implementation

Provides the main YamlLinter class for validating YAML syntax and domain-specific rules.

class plexus.linting.yaml_linter.LintMessage(level: str, code: str, title: str, message: str, suggestion: str | None = None, line: int | None = None, column: int | None = None, doc_url: str | None = None, doc_section: str | None = None, context: ~typing.Dict[str, ~typing.Any] = <factory>)

Bases: object

Represents a single linting issue or success message.

__init__(level: str, code: str, title: str, message: str, suggestion: str | None = None, line: int | None = None, column: int | None = None, doc_url: str | None = None, doc_section: str | None = None, context: ~typing.Dict[str, ~typing.Any] = <factory>) None
code: str
column: int | None = None
context: Dict[str, Any]
doc_section: str | None = None
doc_url: str | None = None
level: str
line: int | None = None
message: str
suggestion: str | None = None
title: str
to_dict() Dict[str, Any]

Convert to dictionary for JSON serialization.

class plexus.linting.yaml_linter.LintResult(is_valid: bool, success_message: str | None = None, messages: ~typing.List[~plexus.linting.yaml_linter.LintMessage] = <factory>, error_count: int = 0, warning_count: int = 0, info_count: int = 0, parsed_content: ~typing.Dict[str, ~typing.Any] | None = None)

Bases: object

Complete linting results for a YAML document.

__init__(is_valid: bool, success_message: str | None = None, messages: ~typing.List[~plexus.linting.yaml_linter.LintMessage] = <factory>, error_count: int = 0, warning_count: int = 0, info_count: int = 0, parsed_content: ~typing.Dict[str, ~typing.Any] | None = None) None
add_message(message: LintMessage) None

Add a message and update counters.

error_count: int = 0
info_count: int = 0
is_valid: bool
messages: List[LintMessage]
parsed_content: Dict[str, Any] | None = None
success_message: str | None = None
to_dict() Dict[str, Any]

Convert to dictionary for JSON serialization.

to_json() str

Convert to JSON string.

warning_count: int = 0
class plexus.linting.yaml_linter.YamlLinter(domain_schema: Dict[str, Any] | None = None, custom_rules: List[Any] | None = None, doc_base_url: str = 'https://docs.plexus.ai/yaml-dsl')

Bases: object

Main YAML DSL linter that validates both syntax and domain-specific rules.

This class provides comprehensive linting for YAML-based configuration files, including syntax validation using ruamel.yaml and domain-specific rule validation.

Initialize the YAML linter.

Args:

domain_schema: JSON schema defining the domain-specific structure custom_rules: List of custom validation rules doc_base_url: Base URL for documentation links

__init__(domain_schema: Dict[str, Any] | None = None, custom_rules: List[Any] | None = None, doc_base_url: str = 'https://docs.plexus.ai/yaml-dsl')

Initialize the YAML linter.

Args:

domain_schema: JSON schema defining the domain-specific structure custom_rules: List of custom validation rules doc_base_url: Base URL for documentation links

lint(yaml_content: str, source_path: str | None = None) LintResult

Lint a YAML document for syntax and domain-specific issues.

Args:

yaml_content: The YAML content to lint source_path: Optional path to the source file (for better error messages)

Returns:

LintResult containing all validation results

lint_file(file_path: str | Path) LintResult

Lint a YAML file.

Args:

file_path: Path to the YAML file

Returns:

LintResult containing all validation results