aider-gitea/aider_gitea/models.py
Jon Michael Aanes 02de35e1b0
All checks were successful
Run Python tests (through Pytest) / Test (push) Successful in 25s
Verify Python project can be installed, loaded and have version checked / Test (push) Successful in 23s
Ruff after Claude Code
2025-06-09 18:27:06 +02:00

112 lines
3.3 KiB
Python

"""Data models for Gitea API responses.
This module contains dataclasses that represent the structure of data
returned from the Gitea API, providing type safety and better code organization.
"""
from dataclasses import dataclass
from typing import Any
@dataclass
class GiteaUser:
"""Represents a Gitea user."""
login: str # User's login name
id: int # User's ID
full_name: str # User's full name
email: str # User's email address
avatar_url: str # URL to user's avatar image
@dataclass
class GiteaLabel:
"""Represents a label in Gitea."""
id: int # Label ID
name: str # Label name
color: str # Label color (hex code)
description: str # Label description
@dataclass
class GiteaCommit:
"""Represents a commit in Gitea."""
sha: str # Commit SHA hash
url: str # API URL for the commit
message: str # Commit message
author: GiteaUser # Commit author
@dataclass
class GiteaBranch:
"""Represents a branch in Gitea."""
name: str # Branch name
commit: GiteaCommit # Latest commit on the branch
protected: bool # Whether the branch is protected
@dataclass
class GiteaRepository:
"""Represents a repository in Gitea."""
id: int # Repository ID
name: str # Repository name
full_name: str # Full repository name (owner/repo)
owner: GiteaUser # Repository owner
description: str # Repository description
clone_url: str # URL for cloning the repository
has_issues: bool # Whether issues are enabled
default_branch: str # Default branch name
@dataclass
class GiteaIssue:
"""Represents an issue in Gitea."""
id: int # Issue ID
number: int # Issue number
title: str # Issue title
body: str # Issue description/body
state: str # Issue state (open, closed, etc.)
labels: list[GiteaLabel] # List of labels attached to the issue
user: GiteaUser # User who created the issue
assignees: list[GiteaUser] # List of assigned users
html_url: str # Web URL for the issue
created_at: str # ISO datetime when issue was created
updated_at: str # ISO datetime when issue was last updated
@dataclass
class GiteaPullRequest:
"""Represents a pull request in Gitea."""
id: int # Pull request ID
number: int # Pull request number
title: str # Pull request title
body: str # Pull request description
state: str # Pull request state (open, closed, merged)
user: GiteaUser # User who created the pull request
head: dict[str, Any] # Head branch information
base: dict[str, Any] # Base branch information
html_url: str # Web URL for the pull request
created_at: str # ISO datetime when PR was created
updated_at: str # ISO datetime when PR was last updated
merged_at: str | None # ISO datetime when PR was merged (if applicable)
@dataclass
class GiteaWorkflowRun:
"""Represents a GitHub Actions workflow run in Gitea."""
id: int # Workflow run ID
name: str # Workflow name
status: str # Run status (queued, in_progress, completed)
conclusion: str | None # Run conclusion (success, failure, cancelled, etc.)
workflow_id: int # ID of the workflow
pull_requests: list[dict[str, Any]] # Associated pull requests
created_at: str # ISO datetime when run was created
updated_at: str # ISO datetime when run was last updated