Module aiogithubapi.models.issue

GitHub issue data class.

Expand source code
"""GitHub issue data class."""
from __future__ import annotations

from typing import Any, Dict

from .base import GitHubDataModelBase
from .label import GitHubLabelModel
from .milestone import GitHubMilestoneModel
from .user import GitHubUserModel


class _PullRequest(GitHubDataModelBase):
    """GitHub pull_request data model."""

    url: str | None = None
    html_url: str | None = None
    diff_url: str | None = None
    patch_url: str | None = None


class GitHubIssueModel(GitHubDataModelBase):
    """GitHub issue data class."""

    active_lock_reason: str | None = None
    author_association: str | None = None
    body: str | None = None
    closed_at: str | None = None
    closed_by: GitHubUserModel | None = None
    comments_url: str | None = None
    comments: int | None = None
    created_at: str | None = None
    events_url: str | None = None
    html_url: str | None = None
    id: int | None = None
    labels_url: str | None = None
    locked: bool | None = None
    milestone: GitHubMilestoneModel | None = None
    number: int | None = None
    repository_url: str | None = None
    state: str | None = None
    title: str | None = None
    updated_at: str | None = None
    url: str | None = None
    pull_request: _PullRequest | None = None
    assignees: list[GitHubUserModel] | None = None
    assignee: GitHubUserModel | None = None
    user: GitHubUserModel | None = None
    labels: list[GitHubLabelModel] | None = None

    @property
    def is_pull_request(self) -> bool:
        """Return True if issue is a pull request."""
        return self.pull_request is not None

    def _generate_labels(self, data: list[Dict[str, Any]]) -> list[GitHubLabelModel]:
        """Generate GitHubLabelModel list from data."""
        return [GitHubLabelModel(label) for label in data or []]

    def _generate_assignees(self, data: list[Dict[str, Any]]) -> list[GitHubUserModel]:
        """Generate GitHubUserModel list from data."""
        return [GitHubUserModel(user) for user in data or []]

    def _generate_assignee(self, data: Dict[str, Any] | None) -> GitHubUserModel:
        """Generate GitHubUserModel from data."""
        return GitHubUserModel(data) if data else None

    def _generate_milestone(self, data: Dict[str, Any] | None) -> "GitHubMilestoneModel":
        """Generate GitHubMilestoneModel from data."""
        return GitHubMilestoneModel(data) if data else None

    def _generate_closed_by(self, data: Dict[str, Any] | None) -> GitHubUserModel:
        """Generate GitHubUserModel from data."""
        return GitHubUserModel(data) if data else None

    def _generate_pull_request(self, data: Dict[str, Any] | None) -> _PullRequest:
        """Generate GitHubPullRequestModel from data."""
        return _PullRequest(data) if data else None

Classes

class GitHubIssueModel (data: Dict[str, Any])

GitHub issue data class.

Init.

Expand source code
class GitHubIssueModel(GitHubDataModelBase):
    """GitHub issue data class."""

    active_lock_reason: str | None = None
    author_association: str | None = None
    body: str | None = None
    closed_at: str | None = None
    closed_by: GitHubUserModel | None = None
    comments_url: str | None = None
    comments: int | None = None
    created_at: str | None = None
    events_url: str | None = None
    html_url: str | None = None
    id: int | None = None
    labels_url: str | None = None
    locked: bool | None = None
    milestone: GitHubMilestoneModel | None = None
    number: int | None = None
    repository_url: str | None = None
    state: str | None = None
    title: str | None = None
    updated_at: str | None = None
    url: str | None = None
    pull_request: _PullRequest | None = None
    assignees: list[GitHubUserModel] | None = None
    assignee: GitHubUserModel | None = None
    user: GitHubUserModel | None = None
    labels: list[GitHubLabelModel] | None = None

    @property
    def is_pull_request(self) -> bool:
        """Return True if issue is a pull request."""
        return self.pull_request is not None

    def _generate_labels(self, data: list[Dict[str, Any]]) -> list[GitHubLabelModel]:
        """Generate GitHubLabelModel list from data."""
        return [GitHubLabelModel(label) for label in data or []]

    def _generate_assignees(self, data: list[Dict[str, Any]]) -> list[GitHubUserModel]:
        """Generate GitHubUserModel list from data."""
        return [GitHubUserModel(user) for user in data or []]

    def _generate_assignee(self, data: Dict[str, Any] | None) -> GitHubUserModel:
        """Generate GitHubUserModel from data."""
        return GitHubUserModel(data) if data else None

    def _generate_milestone(self, data: Dict[str, Any] | None) -> "GitHubMilestoneModel":
        """Generate GitHubMilestoneModel from data."""
        return GitHubMilestoneModel(data) if data else None

    def _generate_closed_by(self, data: Dict[str, Any] | None) -> GitHubUserModel:
        """Generate GitHubUserModel from data."""
        return GitHubUserModel(data) if data else None

    def _generate_pull_request(self, data: Dict[str, Any] | None) -> _PullRequest:
        """Generate GitHubPullRequestModel from data."""
        return _PullRequest(data) if data else None

Ancestors

Subclasses

Class variables

var active_lock_reason : str | None
var assignee : GitHubUserModel | None
var assignees : list[GitHubUserModel] | None
var author_association : str | None
var body : str | None
var closed_at : str | None
var closed_by : GitHubUserModel | None
var comments : int | None
var comments_url : str | None
var created_at : str | None
var events_url : str | None
var html_url : str | None
var id : int | None
var labels : list[GitHubLabelModel] | None
var labels_url : str | None
var locked : bool | None
var milestone : GitHubMilestoneModel | None
var number : int | None
var pull_request : _PullRequest | None
var repository_url : str | None
var state : str | None
var title : str | None
var updated_at : str | None
var url : str | None
var user : GitHubUserModel | None

Instance variables

var is_pull_request : bool

Return True if issue is a pull request.

Expand source code
@property
def is_pull_request(self) -> bool:
    """Return True if issue is a pull request."""
    return self.pull_request is not None

Inherited members