Switch to uv from poetry
Some checks failed
test / test (pull_request) Failing after 40s
build / build (pull_request) Successful in 1m50s

This commit is contained in:
2024-12-03 03:15:59 +01:00
parent b7e8383abb
commit bec4360df0
12 changed files with 644 additions and 896 deletions

View File

@@ -2,6 +2,8 @@ import requests
from pydantic import BaseModel
from rich.console import Console
from typing import Any
from nixprstatus.output import OutputFormat
DEFAULT_HEADERS = {
@@ -16,7 +18,7 @@ class PRStatus(BaseModel):
merged: bool
branches: dict[str, bool]
def print(self, format: OutputFormat = OutputFormat.CONSOLE):
def print(self, format: OutputFormat = OutputFormat.CONSOLE) -> None:
match format:
case OutputFormat.JSON:
print(self.model_dump_json())
@@ -53,15 +55,21 @@ def commits_since(first_ref: str, last_ref: str) -> int:
commit_response = requests.get(url, headers=DEFAULT_HEADERS)
commit_response.raise_for_status()
return commit_response.json()["behind_by"]
behind_by = commit_response.json()["behind_by"]
if not isinstance(behind_by, int):
raise TypeError("behind_by unexpected type")
return behind_by
def get_pr(pr: int) -> dict:
def get_pr(pr: int) -> dict[str, Any]:
url = f"https://api.github.com/repos/NixOS/nixpkgs/pulls/{pr}"
pr_response = requests.get(url, headers=DEFAULT_HEADERS)
pr_response.raise_for_status()
return pr_response.json()
resp = pr_response.json()
if not isinstance(resp, dict):
raise TypeError("PR response has unexpected type")
return resp
def pr_merge_status(