fix: resolve lua typecheck warnings in race and scraper

Problem: luals flagged undefined-field on uv timer methods because
race_state.timer was untyped, and undefined-field on env_extra/stdin
because they were missing from the run_scraper opts annotation.

Solution: hoist race_state.timer into a typed local before the nil
check so luals can narrow through it; add env_extra and stdin to the
opts inline type in run_scraper.
This commit is contained in:
Barrett Ruth 2026-03-03 15:08:51 -05:00 committed by Barrett Ruth
parent de5a20c567
commit e79f992e0b
2 changed files with 5 additions and 4 deletions

View file

@ -114,12 +114,13 @@ function M.start(platform, contest_id, language)
end
function M.stop()
if not race_state.timer then
local timer = race_state.timer
if not timer then
logger.log('No active race', vim.log.levels.WARN)
return
end
race_state.timer:stop()
race_state.timer:close()
timer:stop()
timer:close()
race_state.timer = nil
race_state.platform = nil
race_state.contest_id = nil

View file

@ -33,7 +33,7 @@ end
---@param platform string
---@param subcommand string
---@param args string[]
---@param opts { sync?: boolean, ndjson?: boolean, on_event?: fun(ev: table), on_exit?: fun(result: table) }
---@param opts { sync?: boolean, ndjson?: boolean, on_event?: fun(ev: table), on_exit?: fun(result: table), env_extra?: table<string, string>, stdin?: string }
local function run_scraper(platform, subcommand, args, opts)
if not utils.setup_python_env() then
local msg = 'no Python environment available (install uv or nix)'