fix(ci): formatting and typing

This commit is contained in:
Barrett Ruth 2026-02-18 14:07:53 -05:00 committed by Barrett Ruth
parent e02a29bd40
commit b6f3398bbc
3 changed files with 16 additions and 17 deletions

View file

@ -44,7 +44,12 @@ local function run_scraper(platform, subcommand, args, opts)
local handle local handle
handle = uv.spawn( handle = uv.spawn(
cmd[1], cmd[1],
{ args = vim.list_slice(cmd, 2), stdio = { nil, stdout, stderr }, env = env, cwd = plugin_path }, {
args = vim.list_slice(cmd, 2),
stdio = { nil, stdout, stderr },
env = env,
cwd = plugin_path,
},
function(code, signal) function(code, signal)
if buf ~= '' and opts.on_event then if buf ~= '' and opts.on_event then
local ok_tail, ev_tail = pcall(vim.json.decode, buf) local ok_tail, ev_tail = pcall(vim.json.decode, buf)

View file

@ -78,7 +78,7 @@ def _extract_title(block: Tag) -> tuple[str, str]:
def _extract_samples(block: Tag) -> tuple[list[TestCase], bool]: def _extract_samples(block: Tag) -> tuple[list[TestCase], bool]:
st = block.find("div", class_="sample-test") st = block.find("div", class_="sample-test")
if not st: if not isinstance(st, Tag):
return [], False return [], False
input_pres: list[Tag] = [ input_pres: list[Tag] = [

View file

@ -6,11 +6,6 @@ from scrapers.models import (
TestsResult, TestsResult,
) )
MODEL_FOR_MODE = {
"metadata": MetadataResult,
"contests": ContestListResult,
}
MATRIX = { MATRIX = {
"cses": { "cses": {
"metadata": ("introductory_problems",), "metadata": ("introductory_problems",),
@ -43,17 +38,16 @@ def test_scraper_offline_fixture_matrix(run_scraper_offline, scraper, mode):
assert rc in (0, 1), f"Bad exit code {rc}" assert rc in (0, 1), f"Bad exit code {rc}"
assert objs, f"No JSON output for {scraper}:{mode}" assert objs, f"No JSON output for {scraper}:{mode}"
if mode in ("metadata", "contests"): if mode == "metadata":
Model = MODEL_FOR_MODE[mode] model = MetadataResult.model_validate(objs[-1])
model = Model.model_validate(objs[-1])
assert model is not None
assert model.success is True assert model.success is True
if mode == "metadata": assert model.url
assert model.url assert len(model.problems) >= 1
assert len(model.problems) >= 1 assert all(isinstance(p.id, str) and p.id for p in model.problems)
assert all(isinstance(p.id, str) and p.id for p in model.problems) elif mode == "contests":
else: model = ContestListResult.model_validate(objs[-1])
assert len(model.contests) >= 1 assert model.success is True
assert len(model.contests) >= 1
else: else:
assert len(objs) >= 1, "No test objects returned" assert len(objs) >= 1, "No test objects returned"
validated_any = False validated_any = False