Skip to content

Domain

Change dataclass

Represents an immutable change object with diffs and description.

This class encapsulates a change, providing a structured representation for tracking differences (diffs) and the description from the change request ticket. The frozen nature ensures immutability once an instance is created.

Attributes:

Name Type Description
diffs Diffs

The code differences associated with this change.

change_description str

the description from the change request ticket.

ChatSession dataclass

Wrapper class for chat sessions.

ConfigLocationEnum

Bases: Enum

Enumeration for configuration file locations.

This class defines enumeration members representing different locations of configuration files. This enum is used by the ConfigRepository class to resolve the location

Attributes:

Name Type Description
CURRENT_DIR Path

Represents the current working directory where the configuration file review-assist.cfg is expected to reside.

USER_HOME Path

Represents the default user configuration directory. Specifically points to ~/.config/ra/review-assist.cfg.

Configuration dataclass

A frozen data class for immutable configuration management.

This class provides a container for storing configuration data with optional validation against a JSON schema.

Attributes:

Name Type Description
_data ConfigSource

The configuration data.

_source str

The source of the configuration data. Defaults to .config/ra/review-assist.cfg in the user's home directory.

Methods:

Name Description
data

str | None, key: str | None)

-> SensitiveConfigValue | str | SectionProxy | ConfigSource

Retrieves configuration data, optionally for a specific section or key.

source -> str

Returns the source of the configuration data.

Static Methods

build(data: ConfigSource) -> Configuration: Builds a Configuration instance from a dictionary or ConfigParser.

source property

Returns the source of the configuration data.

Returns:

Name Type Description
str str

The source of the configuration data.

build(data, source=None) staticmethod

Builds a Configuration instance using the provided data and optional source.

This method serves as a factory for creating instances of the Configuration class. The data parameter is required, while the source parameter is optional. If a source is provided, it will be associated with the resulting Configuration instance.

Parameters:

Name Type Description Default
data ConfigSource

ConfigSource The configuration data to initialise the Configuration instance.

required
source str | None

str | None, optional The optional source of the configuration data.

None

Returns:

Type Description
Configuration

Configuration An instance of the Configuration class initialised with the given data and optional source.

data(section=None, key=None)

Retrieves data from the internal configuration storage.

The data can be fetched for a specific section, a specific key within a section, or the entire data structure.

Parameters:

Name Type Description Default
section str | None

The name of the section to retrieve data from. Defaults to None.

None
key str | None

The specific key within the section to retrieve data for. Defaults to None.

None

Raises:

Type Description
RAConfigError

If a key is provided but no section is specified.

Returns:

Name Type Description
ConfigCollections ConfigCollections
ConfigCollections
  • A dictionary representing the data of a specific section
ConfigCollections

if only section is provided.

ConfigCollections
  • A specific value from the section
ConfigCollections

if both section and key are provided.

ConfigCollections
  • a SensitiveConfigValue wrapper if key is git_server.private_token.
ConfigCollections
  • The entire configuration data structure (with sensitive value redacted)
ConfigCollections

if neither section nor key is provided.

GitServers

Bases: Enum

Enum for the different types of git servers.

LLMResponse dataclass

Wrapper class for LLM responses.

content property

Gets the content extracted from the response based on the backend type.

This property retrieves the content attribute of the response associated with the specified LLM backend type. If the backend type is unsupported, a ValueError is raised.

Raises:

Type Description
ValueError

If the backend type is unsupported.

TypeError

If the actual response type doesn't match the expected type.

Returns:

Type Description
str | None

str or None: The content of the response if available.

Project dataclass

Project data class for storing project information.

Prompt dataclass

Prompt for the AI model.

engineer_prompt(work_type, project_data, changes) classmethod

Create a prompt for the AI model.

PromptEnum

Bases: Enum

Enum for the different types of prompts.

SensitiveConfigValue

Wrapper for sensitive configuration values.

SetEnv

Context manager for temporarily setting environment variables.