Skip to content

gitea.config.model

model

Configuration model for GitHub accounts.

Classes

gitea.config.model.AccountConfig

Bases: BaseModel

Configuration for a GitHub account.

Attributes
gitea.config.model.AccountConfig.name class-attribute instance-attribute
name: str = Field(
    ...,
    description="Label of the Gitea account (e.g., 'my_account').",
)

Label of the Gitea account (e.g., 'my_account').

gitea.config.model.AccountConfig.token class-attribute instance-attribute
token: str = Field(
    ..., description="Authentication token for Gitea."
)

Authentication token for the account.

gitea.config.model.AccountConfig.base_url class-attribute instance-attribute
base_url: str = Field(
    default="https://gitea.com",
    description="Base URL for Gitea.",
)

Base URL for the GitHub platform.

Methods:
gitea.config.model.AccountConfig.validate_base_url classmethod
validate_base_url(v: str) -> str

Validate and normalize the base_url field.

Parameters:

Name Type Description Default
v str

The base URL to validate.

required

Returns:

Type Description
str

The normalized base URL.

Source code in src/gitea/config/model.py
@field_validator("base_url")
@classmethod
def validate_base_url(cls, v: str) -> str:
    """Validate and normalize the base_url field.

    Args:
        v: The base URL to validate.

    Returns:
        The normalized base URL.

    """
    if not v.startswith(("http://", "https://")):
        raise ValueError("base_url must start with http:// or https://")

    return v.rstrip("/")

gitea.config.model.Config

Bases: BaseModel

Main configuration model for gitea.

Attributes
gitea.config.model.Config.accounts class-attribute instance-attribute
accounts: dict[str, AccountConfig] = Field(
    default_factory=dict,
    description="Dictionary of account configurations.",
)

Dictionary of account configurations.

gitea.config.model.Config.default_account class-attribute instance-attribute
default_account: str | None = Field(
    default=None,
    description="Name of the default account to use.",
)

Name of the default account to use.