|
19 | 19 | "Awaiting changes" -> "Approved" [label="Review approves", color=green] |
20 | 20 | } |
21 | 21 | """ |
| 22 | + |
| 23 | +from __future__ import annotations |
| 24 | + |
22 | 25 | import asyncio |
23 | 26 | import logging |
24 | 27 | import re |
25 | | -from typing import Any, Optional |
| 28 | +from typing import TYPE_CHECKING, Any |
26 | 29 |
|
27 | 30 | from gidgethub import routing |
28 | | -from gidgethub.sansio import Event |
29 | 31 |
|
30 | 32 | from algorithms_keeper import utils |
31 | | -from algorithms_keeper.api import GitHubAPI |
32 | 33 | from algorithms_keeper.constants import ( |
33 | 34 | CHECKBOX_NOT_TICKED_COMMENT, |
34 | 35 | EMPTY_PR_BODY_COMMENT, |
|
37 | 38 | PR_REVIEW_COMMENT, |
38 | 39 | Label, |
39 | 40 | ) |
| 41 | +from algorithms_keeper.event.check_run import check_ci_status_and_label |
40 | 42 | from algorithms_keeper.parser import PythonParser |
41 | 43 |
|
| 44 | +if TYPE_CHECKING: |
| 45 | + from gidgethub.sansio import Event |
| 46 | + |
| 47 | + from algorithms_keeper.api import GitHubAPI |
| 48 | + |
42 | 49 | # To disable this check, set the constant to 0. |
43 | 50 | MAX_PR_PER_USER = 3 |
44 | 51 | STAGE_PREFIX = "awaiting" |
|
50 | 57 |
|
51 | 58 |
|
52 | 59 | async def update_stage_label( |
53 | | - gh: GitHubAPI, *, pull_request: dict[str, Any], next_label: Optional[str] = None |
| 60 | + gh: GitHubAPI, *, pull_request: dict[str, Any], next_label: str | None = None |
54 | 61 | ) -> None: |
55 | 62 | """Update the stage label of the given pull request. |
56 | 63 |
|
@@ -266,8 +273,6 @@ async def check_ci_ready_for_review_pr( |
266 | 273 | removed if the checks are passing or failing. Thus, we need to manually check it |
267 | 274 | with respect to the latest commit on head. |
268 | 275 | """ |
269 | | - from algorithms_keeper.event.check_run import check_ci_status_and_label |
270 | | - |
271 | 276 | await check_ci_status_and_label(event, gh, *args, **kwargs) |
272 | 277 |
|
273 | 278 |
|
@@ -343,7 +348,7 @@ async def check_merge_status( |
343 | 348 | pull_request = event.data["pull_request"] |
344 | 349 |
|
345 | 350 | for retry_interval in range(MAX_RETRIES): |
346 | | - mergeable: Optional[bool] = pull_request["mergeable"] |
| 351 | + mergeable: bool | None = pull_request["mergeable"] |
347 | 352 | if mergeable is None: |
348 | 353 | # We will use the iter value we get as our sleep period between the polls. |
349 | 354 | # In the webhook payload, the mergeable status will always be ``None``, so |
|
0 commit comments