-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Differentiate between a partial and full PR in types
- Loading branch information
Showing
6 changed files
with
77 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
from lazy_github.lib.github.client import GithubClient | ||
from lazy_github.lib.github.issues import list_all_issues | ||
from lazy_github.models.github import PullRequest, Repository | ||
from lazy_github.models.github import FullPullRequest, PartialPullRequest, Repository | ||
|
||
|
||
async def list_for_repo(client: GithubClient, repo: Repository) -> list[PullRequest]: | ||
async def list_for_repo(client: GithubClient, repo: Repository) -> list[PartialPullRequest]: | ||
issues = await list_all_issues(client, repo) | ||
return [i for i in issues if isinstance(i, PullRequest)] | ||
return [i for i in issues if isinstance(i, PartialPullRequest)] | ||
|
||
|
||
async def get_full_pull_request(client: GithubClient, partial_pr: PartialPullRequest) -> FullPullRequest: | ||
user = await client.user() | ||
url = f"/repos/{user.login}/{partial_pr.repo.name}/pulls/{partial_pr.number}" | ||
response = await client.get(url, headers=client.headers_with_auth_accept()) | ||
response.raise_for_status() | ||
return FullPullRequest(**response.json(), repo=partial_pr.repo) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters