|
8 | 8 |
|
9 | 9 | import re |
10 | 10 | from dataclasses import dataclass |
11 | | -from typing import TYPE_CHECKING, Protocol |
| 11 | +from typing import TYPE_CHECKING |
12 | 12 |
|
13 | 13 | from greenlight import constants |
14 | 14 | from greenlight.pr_hash import HumanEvent, PRFingerprint, compute_pr_hash, is_bot |
|
21 | 21 |
|
22 | 22 | from github import Github |
23 | 23 |
|
24 | | - class _PRUser(Protocol): |
25 | | - @property |
26 | | - def login(self) -> str | None: ... |
27 | | - |
28 | | - class _Label(Protocol): |
29 | | - @property |
30 | | - def name(self) -> str: ... |
31 | | - |
32 | | - class _PullRequest(Protocol): |
33 | | - @property |
34 | | - def number(self) -> int: ... |
35 | | - @property |
36 | | - def user(self) -> _PRUser | None: ... |
37 | | - @property |
38 | | - def title(self) -> str: ... |
39 | | - @property |
40 | | - def html_url(self) -> str: ... |
41 | | - @property |
42 | | - def head(self) -> _PRBase: ... |
43 | | - @property |
44 | | - def updated_at(self) -> datetime | None: ... |
45 | | - @property |
46 | | - def labels(self) -> Iterable[_Label]: ... |
47 | | - @property |
48 | | - def draft(self) -> bool: ... |
49 | | - |
50 | | - class _Repo(Protocol): |
51 | | - def get_pulls(self, state: str) -> Iterable[_PullRequest]: ... |
52 | | - |
53 | | - class _RepoClient(Protocol): |
54 | | - def get_repo(self, full_name_or_id: str) -> _Repo: ... |
55 | | - |
56 | | - class _PRActor(Protocol): |
57 | | - @property |
58 | | - def login(self) -> str | None: ... |
59 | | - @property |
60 | | - def type(self) -> str: ... |
61 | | - |
62 | | - class _PRComment(Protocol): |
63 | | - @property |
64 | | - def id(self) -> int: ... |
65 | | - @property |
66 | | - def user(self) -> _PRActor | None: ... |
67 | | - @property |
68 | | - def body(self) -> str: ... |
69 | | - |
70 | | - class _PRReview(Protocol): |
71 | | - @property |
72 | | - def id(self) -> int: ... |
73 | | - @property |
74 | | - def user(self) -> _PRActor | None: ... |
75 | | - @property |
76 | | - def body(self) -> str: ... |
77 | | - @property |
78 | | - def state(self) -> str: ... |
79 | | - |
80 | | - class _PRBase(Protocol): |
81 | | - @property |
82 | | - def sha(self) -> str: ... |
83 | | - |
84 | | - class _FingerprintPR(Protocol): |
85 | | - @property |
86 | | - def head(self) -> _PRBase: ... |
87 | | - def get_issue_comments(self) -> Iterable[_PRComment]: ... |
88 | | - def get_review_comments(self) -> Iterable[_PRComment]: ... |
89 | | - def get_reviews(self) -> Iterable[_PRReview]: ... |
90 | | - |
91 | | - class _ScanRepo(Protocol): |
92 | | - def get_pull(self, number: int) -> _FingerprintPR: ... |
93 | | - |
94 | | - class _AuthorPR(Protocol): |
95 | | - @property |
96 | | - def user(self) -> _PRUser | None: ... |
97 | | - |
98 | | - class _AuthorRepo(Protocol): |
99 | | - def get_pull(self, number: int) -> _AuthorPR: ... |
100 | | - |
101 | | - class _AuthorClient(Protocol): |
102 | | - def get_repo(self, full_name_or_id: str) -> _AuthorRepo: ... |
103 | | - |
104 | | - class _VerdictReview(Protocol): |
105 | | - @property |
106 | | - def id(self) -> int: ... |
107 | | - @property |
108 | | - def user(self) -> _PRUser | None: ... |
109 | | - @property |
110 | | - def state(self) -> str: ... |
111 | | - def dismiss(self, message: str) -> None: ... |
112 | | - |
113 | | - class _VerdictComment(Protocol): |
114 | | - @property |
115 | | - def body(self) -> str: ... |
116 | | - @property |
117 | | - def user(self) -> _PRUser | None: ... |
118 | | - def edit(self, body: str) -> None: ... |
119 | | - |
120 | | - class VerdictPR(Protocol): |
121 | | - @property |
122 | | - def head(self) -> _PRBase: ... |
123 | | - def create_review(self, *, body: str, event: str) -> object: ... |
124 | | - def create_issue_comment(self, body: str) -> object: ... |
125 | | - def get_issue_comments(self) -> Iterable[_VerdictComment]: ... |
126 | | - def get_reviews(self) -> Iterable[_VerdictReview]: ... |
127 | | - |
128 | | - class _VerdictRepo(Protocol): |
129 | | - def get_pull(self, number: int) -> VerdictPR: ... |
130 | | - |
131 | | - |
132 | | -class VerdictClient(Protocol): |
133 | | - """Structural GitHub client for the verdict path; the real ``github.Github`` satisfies it.""" |
134 | | - |
135 | | - def get_repo(self, full_name_or_id: str) -> _VerdictRepo: ... |
136 | | - |
137 | | - |
138 | | -class ScanClient(Protocol): |
139 | | - """Structural GitHub client for the scan/fingerprint path; the real ``github.Github`` satisfies it.""" |
140 | | - |
141 | | - def get_repo(self, full_name_or_id: str) -> _ScanRepo: ... |
| 24 | + from greenlight.github_types import ( |
| 25 | + ScanClient, |
| 26 | + VerdictClient, |
| 27 | + VerdictPR, |
| 28 | + _AuthorClient, |
| 29 | + _FingerprintPR, |
| 30 | + _PRActor, |
| 31 | + _PRReview, |
| 32 | + _RepoClient, |
| 33 | + ) |
142 | 34 |
|
143 | 35 |
|
144 | 36 | @dataclass(frozen=True, slots=True) |
|
0 commit comments