herman.core

Core module for Herman analysis messages and rendering.

Submodules

Attributes

Classes

AnalysisMessage

Message produced during analysis.

Severity

Severity levels for analysis messages.

StoryConfig

Story configuration model.

StoryFileMetadata

Metadata for a story file.

Functions

render_messages(→ int)

Select a renderer and execute it.

Package Contents

class herman.core.AnalysisMessage[source]

Message produced during analysis.

sort_index: tuple[int, str, int, int, str, str][source]
file: pathlib.Path[source]
message: str[source]
code: str[source]
severity: Severity[source]
line: int | None = None[source]
column: int | None = None[source]
__post_init__() None[source]

Initialize the sort index for ordering messages.

property is_error: bool[source]

Check if the message is an error.

classmethod from_text(file: pathlib.Path, message: str, code: str, severity: Severity = Severity.ERROR) Self[source]

Create an AnalysisMessage from plain text inputs.

classmethod from_pydantic_error(file: pathlib.Path, err: pydantic.ValidationError) list[AnalysisMessage][source]

Convert a Pydantic ValidationError into AnalysisMessages.

Extracts line & column if possible.

to_dict() dict[str, str | int | None][source]

JSON-friendly format.

to_rich() rich.panel.Panel[source]

Rich panel for local console output.

to_github_annotation() str[source]

GitHub Actions annotation format.

class herman.core.Severity[source]

Bases: str, enum.Enum

Severity levels for analysis messages.

ERROR = 'error'[source]
WARNING = 'warning'[source]
NOTICE = 'notice'[source]
property order: int[source]

Order for sorting severities.

property icon: str[source]

Icon representing the severity level.

property color: str[source]

Color associated with the severity level.

__lt__(other: Severity) bool[source]

Compare severities based on their order.

herman.core.OutputFormat[source]
herman.core.render_messages(messages: list[herman.core.AnalysisMessage], *, output_format: OutputFormat | None) int[source]

Select a renderer and execute it.

  • If format is provided explicitly, use that.

  • Otherwise auto-detect:
    • If running in CI, use GitHub annotations.

    • Else fallback to Rich console renderer.

class herman.core.StoryConfig(/, **data: Any)[source]

Bases: herman.core.story._base.HermanBaseModel

Story configuration model.

characters: dict[str, Character][source]
class herman.core.StoryFileMetadata(/, **data: Any)[source]

Bases: herman.core.story._base.HermanBaseModel

Metadata for a story file.

title: str | None = None[source]
date_: datetime.date = None[source]
scene_dates: str | None = None[source]
perspective: str[source]
characters: list[str][source]