Skip to content

Commit

Permalink
fix: correct issue links
Browse files Browse the repository at this point in the history
  • Loading branch information
Olegt0rr committed Oct 30, 2023
1 parent 96f7efe commit d69b7e1
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 18 deletions.
21 changes: 3 additions & 18 deletions yatracker/tracker/categories/issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from yatracker.types import (
FullIssue,
Issue,
IssueLink,
IssueType,
Priority,
Transition,
Expand Down Expand Up @@ -350,26 +351,10 @@ async def find_issues(
)
return self._decode(list[_type], data) # type: ignore[valid-type]

@overload
async def get_issue_links(
self,
issue_id: str,
) -> list[FullIssue]:
...

@overload
async def get_issue_links(
self,
issue_id: str,
_type: type[IssueT_co | FullIssue] = ...,
) -> list[IssueT_co]:
...

async def get_issue_links(
self,
issue_id: str,
_type: type[IssueT_co | FullIssue] = FullIssue,
) -> list[IssueT_co] | list[FullIssue]:
) -> list[IssueLink]:
"""Get issue links.
Use this request to get information about links between issues.
Expand All @@ -379,7 +364,7 @@ async def get_issue_links(
method="GET",
uri=f"/issues/{issue_id}/links",
)
return self._decode(list[_type], data) # type: ignore[valid-type]
return self._decode(list[IssueLink], data)

async def get_transitions(self, issue_id: str) -> Transitions:
"""Get transitions.
Expand Down
2 changes: 2 additions & 0 deletions yatracker/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"FullIssue",
"FullQueue",
"Issue",
"IssueLink",
"IssueType",
"IssueTypeConfig",
"Priority",
Expand All @@ -28,6 +29,7 @@
from .full_issue import FullIssue
from .full_queue import FullQueue
from .issue import Issue
from .issue_link import IssueLink
from .issue_type import IssueType
from .issue_type_config import IssueTypeConfig
from .priority import Priority
Expand Down
43 changes: 43 additions & 0 deletions yatracker/types/issue_link.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from __future__ import annotations

__all__ = ["IssueLink", "LinkType", "LinkDirection"]

from datetime import datetime
from enum import StrEnum, auto

Check failure on line 6 in yatracker/types/issue_link.py

View workflow job for this annotation

GitHub Actions / mypy

Module "enum" has no attribute

from .base import Base, field
from .issue import Issue
from .status import Status
from .user import User


class LinkDirection(StrEnum):
"""Represents link direction."""

INWARD = auto()
OUTWARD = auto()


class LinkType(Base, kw_only=True):
"""Represents issue link type."""

url: str = field(name="self")
id: str
inward: str
outward: str


class IssueLink(Base, kw_only=True):
"""Represents issue link."""

url: str = field(name="self")
id: int
type: LinkType
direction: LinkDirection
object: Issue
created_by: User
updated_by: User | None = None
created_at: datetime
updated_at: datetime | None = None
assignee: User | None = None
status: Status

0 comments on commit d69b7e1

Please sign in to comment.