|
1 | 1 | import functools |
2 | 2 | import re |
| 3 | +import typing |
3 | 4 | from typing import Dict |
4 | 5 | from typing import List |
5 | 6 | from typing import Optional |
|
10 | 11 | from .connection import GiteaHTTPResponse |
11 | 12 | from .user import User |
12 | 13 |
|
13 | | - |
14 | | -class PullRequestReview(GiteaModel): |
15 | | - @property |
16 | | - def state(self) -> str: |
17 | | - return self._data["state"] |
18 | | - |
19 | | - @property |
20 | | - def user(self) -> Optional[str]: |
21 | | - if not self._data["user"]: |
22 | | - return None |
23 | | - return self._data["user"]["login"] |
24 | | - |
25 | | - @property |
26 | | - def team(self) -> Optional[str]: |
27 | | - if not self._data["team"]: |
28 | | - return None |
29 | | - return self._data["team"]["name"] |
30 | | - |
31 | | - @property |
32 | | - def who(self) -> str: |
33 | | - return self.user if self.user else f"@{self.team}" |
34 | | - |
35 | | - @property |
36 | | - def submitted_at(self) -> str: |
37 | | - return self._data["submitted_at"] |
38 | | - |
39 | | - @property |
40 | | - def updated_at(self) -> str: |
41 | | - return self._data["updated_at"] |
42 | | - |
43 | | - @property |
44 | | - def body(self) -> str: |
45 | | - return self._data["body"] |
46 | | - |
47 | | - @classmethod |
48 | | - def list( |
49 | | - cls, |
50 | | - conn: Connection, |
51 | | - owner: str, |
52 | | - repo: str, |
53 | | - number: int, |
54 | | - ) -> List["PullRequestReview"]: |
55 | | - """ |
56 | | - List reviews associated with a pull request. |
57 | | -
|
58 | | - :param conn: Gitea ``Connection`` instance. |
59 | | - :param owner: Owner of the repo. |
60 | | - :param repo: Name of the repo. |
61 | | - :param number: Number of the pull request in owner/repo. |
62 | | - """ |
63 | | - q = { |
64 | | - "limit": -1, |
65 | | - } |
66 | | - url = conn.makeurl("repos", owner, repo, "pulls", str(number), "reviews", query=q) |
67 | | - response = conn.request("GET", url) |
68 | | - obj_list = [cls(i, response=response) for i in response.json()] |
69 | | - return obj_list |
| 14 | +if typing.TYPE_CHECKING: |
| 15 | + from .pr_review import PullRequestReview |
70 | 16 |
|
71 | 17 |
|
72 | 18 | @functools.total_ordering |
@@ -545,7 +491,9 @@ def add_comment( |
545 | 491 | def get_reviews( |
546 | 492 | self, |
547 | 493 | conn: Connection, |
548 | | - ) -> List[PullRequestReview]: |
| 494 | + ) -> List["PullRequestReview"]: |
| 495 | + from .pr_review import PullRequestReview |
| 496 | + |
549 | 497 | return PullRequestReview.list(conn, self.base_owner, self.base_repo, self.number) |
550 | 498 |
|
551 | 499 | @classmethod |
|
0 commit comments