mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
Merge c472b0667b into e6c4580a31
This commit is contained in:
commit
aee3bf29aa
2 changed files with 28 additions and 11 deletions
12
.github/scripts/close_duplicate_issues.py
vendored
12
.github/scripts/close_duplicate_issues.py
vendored
|
|
@ -50,17 +50,7 @@ def fetch_open_issues(repo: str | None) -> list[dict]:
|
|||
cmd = ["api", "--paginate", endpoint]
|
||||
|
||||
raw = gh(*cmd)
|
||||
# gh --paginate concatenates JSON arrays, so we may get multiple arrays
|
||||
issues = []
|
||||
for line in raw.strip().splitlines():
|
||||
line = line.strip()
|
||||
if not line:
|
||||
continue
|
||||
parsed = json.loads(line)
|
||||
if isinstance(parsed, list):
|
||||
issues.extend(parsed)
|
||||
else:
|
||||
issues.append(parsed)
|
||||
issues = json.loads(raw)
|
||||
|
||||
# Filter out pull requests (they also appear in the issues endpoint)
|
||||
return [i for i in issues if "pull_request" not in i]
|
||||
|
|
|
|||
27
tests/test_litellm/test_close_duplicate_issues.py
Normal file
27
tests/test_litellm/test_close_duplicate_issues.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
"""Unit tests for `.github/scripts/close_duplicate_issues.py`."""
|
||||
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
SCRIPT_PATH = Path(__file__).resolve().parents[2] / ".github" / "scripts" / "close_duplicate_issues.py"
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def duplicate_issues_module():
|
||||
spec = importlib.util.spec_from_file_location("close_duplicate_issues", SCRIPT_PATH)
|
||||
assert spec and spec.loader
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
return module
|
||||
|
||||
|
||||
def test_fetch_open_issues_preserves_unicode_line_separators(duplicate_issues_module, monkeypatch):
|
||||
raw = '[{"number": 1, "body": "line\u2028separator"}, {"number": 2, "body": "paragraph\u2029separator"}]'
|
||||
monkeypatch.setattr(duplicate_issues_module, "gh", lambda *args: raw)
|
||||
|
||||
assert duplicate_issues_module.fetch_open_issues("BerriAI/litellm") == [
|
||||
{"number": 1, "body": "line\u2028separator"},
|
||||
{"number": 2, "body": "paragraph\u2029separator"},
|
||||
]
|
||||
Loading…
Add table
Reference in a new issue