orchestrata_tools.reviewer.models
Reference › orchestrata_tools › reviewer › models
This module holds the result types shared by the two review engines, code_reviewer and test_reviewer. Severity is a string enum with critical, high, medium, low and info. Issue records a rule name, message, severity, a location such as module.class.method, and a suggestion. ReviewReport collects the issues for one target: add appends an issue and increments a per-rule count in summary, and by_severity groups issues into a dictionary keyed by severity value.
At a glance
| Source | src/orchestrata_tools/reviewer/models.py |
| Lines of code | 50 |
| Classes | 3 |
| Functions | 0 |
| Imports (internal) | none |
| Imported by | orchestrata_tools.reviewer.code_reviewer, orchestrata_tools.reviewer.test_reviewer |
| Tests that import it | tests/test_orchestrata_tools_reviewer_query_indexer.py |
Class diagram
Dependency diagram
API
Classes
Severity (enum)
Bases: StrEnum · Line 9
| Member | Value |
|---|---|
CRITICAL |
'critical' |
HIGH |
'high' |
MEDIUM |
'medium' |
LOW |
'low' |
INFO |
'info' |
Issue (dataclass)
Decorators: dataclass · Line 18
A single review issue.
| Attribute | Type | Default |
|---|---|---|
rule |
str |
|
message |
str |
|
severity |
Severity |
|
location |
str |
'' |
suggestion |
str |
'' |
ReviewReport (dataclass)
Decorators: dataclass · Line 29
Aggregate review report.
| Attribute | Type | Default |
|---|---|---|
target |
str |
'' |
issues |
list[Issue] |
field(default_factory=list) |
summary |
dict[str, int] |
field(default_factory=dict) |
| Method | Signature | Summary |
|---|---|---|
by_severity |
by_severity() -> dict[str, list[Issue]] |
|
add |
add(issue: Issue) -> None |
Source
"""Shared models for review engines."""
from __future__ import annotations
from dataclasses import dataclass, field
from enum import StrEnum
class Severity(StrEnum):
CRITICAL = "critical"
HIGH = "high"
MEDIUM = "medium"
LOW = "low"
INFO = "info"
@dataclass
class Issue:
"""A single review issue."""
rule: str
message: str
severity: Severity
location: str = "" # e.g. "module.class.method"
suggestion: str = ""
@dataclass
class ReviewReport:
"""Aggregate review report."""
target: str = ""
issues: list[Issue] = field(default_factory=list)
summary: dict[str, int] = field(default_factory=dict)
def by_severity(self) -> dict[str, list[Issue]]:
result: dict[str, list[Issue]] = {
"critical": [],
"high": [],
"medium": [],
"low": [],
"info": [],
}
for issue in self.issues:
result[issue.severity.value].append(issue)
return result
def add(self, issue: Issue) -> None:
self.issues.append(issue)
self.summary[issue.rule] = self.summary.get(issue.rule, 0) + 1