From 2a373b72dd9b604b4594df8d73a04dfe98c2c897 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Thu, 5 Mar 2026 14:22:25 -0500 Subject: [PATCH] ci: format --- lua/cp/commands/cache.lua | 10 ++++++++-- lua/cp/credentials.lua | 10 ++++++++-- lua/cp/pickers/init.lua | 10 ++++++++-- lua/cp/race.lua | 5 ++++- lua/cp/setup.lua | 29 ++++++++++++++++++++++++----- lua/cp/submit.lua | 5 ++++- lua/cp/ui/edit.lua | 10 ++++++++-- lua/cp/ui/views.lua | 20 ++++++++++++++++---- lua/cp/utils.lua | 10 ++++++++-- scrapers/atcoder.py | 3 ++- scrapers/timeouts.py | 4 +++- 11 files changed, 93 insertions(+), 23 deletions(-) diff --git a/lua/cp/commands/cache.lua b/lua/cp/commands/cache.lua index f91aa75..cec3eba 100644 --- a/lua/cp/commands/cache.lua +++ b/lua/cp/commands/cache.lua @@ -50,7 +50,10 @@ function M.handle_cache_command(cmd) { level = vim.log.levels.INFO, override = true } ) else - logger.log(("Unknown platform '%s'."):format(cmd.platform), { level = vim.log.levels.ERROR }) + logger.log( + ("Unknown platform '%s'."):format(cmd.platform), + { level = vim.log.levels.ERROR } + ) end elseif cmd.platform then if vim.tbl_contains(platforms, cmd.platform) then @@ -60,7 +63,10 @@ function M.handle_cache_command(cmd) { level = vim.log.levels.INFO, override = true } ) else - logger.log(("Unknown platform '%s'."):format(cmd.platform), { level = vim.log.levels.ERROR }) + logger.log( + ("Unknown platform '%s'."):format(cmd.platform), + { level = vim.log.levels.ERROR } + ) end else cache.clear_all() diff --git a/lua/cp/credentials.lua b/lua/cp/credentials.lua index 497e544..76945b6 100644 --- a/lua/cp/credentials.lua +++ b/lua/cp/credentials.lua @@ -7,7 +7,10 @@ local state = require('cp.state') function M.login(platform) platform = platform or state.get_platform() if not platform then - logger.log('No platform specified. Usage: :CP login ', { level = vim.log.levels.ERROR }) + logger.log( + 'No platform specified. Usage: :CP login ', + { level = vim.log.levels.ERROR } + ) return end @@ -32,7 +35,10 @@ end function M.logout(platform) platform = platform or state.get_platform() if not platform then - logger.log('No platform specified. Usage: :CP logout ', { level = vim.log.levels.ERROR }) + logger.log( + 'No platform specified. Usage: :CP logout ', + { level = vim.log.levels.ERROR } + ) return end cache.load() diff --git a/lua/cp/pickers/init.lua b/lua/cp/pickers/init.lua index 70d191b..562c274 100644 --- a/lua/cp/pickers/init.lua +++ b/lua/cp/pickers/init.lua @@ -43,13 +43,19 @@ function M.get_platform_contests(platform, refresh) if refresh or vim.tbl_isempty(picker_contests) then local display_name = constants.PLATFORM_DISPLAY_NAMES[platform] - logger.log(('Fetching %s contests...'):format(display_name), { level = vim.log.levels.INFO, override = true, sync = true }) + logger.log( + ('Fetching %s contests...'):format(display_name), + { level = vim.log.levels.INFO, override = true, sync = true } + ) local contests = scraper.scrape_contest_list(platform) cache.set_contest_summaries(platform, contests) picker_contests = cache.get_contest_summaries(platform) - logger.log(('Fetched %d %s contests.'):format(#picker_contests, display_name), { level = vim.log.levels.INFO, override = true }) + logger.log( + ('Fetched %d %s contests.'):format(#picker_contests, display_name), + { level = vim.log.levels.INFO, override = true } + ) end return picker_contests diff --git a/lua/cp/race.lua b/lua/cp/race.lua index fc32f41..b44b9ab 100644 --- a/lua/cp/race.lua +++ b/lua/cp/race.lua @@ -59,7 +59,10 @@ function M.start(platform, contest_id, language) local remaining = start_time - os.time() if remaining <= 0 then - logger.log('Contest has already started, setting up...', { level = vim.log.levels.INFO, override = true }) + logger.log( + 'Contest has already started, setting up...', + { level = vim.log.levels.INFO, override = true } + ) require('cp.setup').setup_contest(platform, contest_id, nil, language) return end diff --git a/lua/cp/setup.lua b/lua/cp/setup.lua index 48bdf33..eb7ba8c 100644 --- a/lua/cp/setup.lua +++ b/lua/cp/setup.lua @@ -16,7 +16,10 @@ local function apply_template(bufnr, lang_id, platform) end local path = vim.fn.expand(eff.template) if vim.fn.filereadable(path) ~= 1 then - logger.log(('[cp.nvim] template not readable: %s'):format(path), { level = vim.log.levels.WARN }) + logger.log( + ('[cp.nvim] template not readable: %s'):format(path), + { level = vim.log.levels.WARN } + ) return end local lines = vim.fn.readfile(path) @@ -117,7 +120,10 @@ local function start_tests(platform, contest_id, problems) scraper.scrape_all_tests(platform, contest_id, function(ev) local cached_tests = {} if not ev.interactive and vim.tbl_isempty(ev.tests) then - logger.log(("No tests found for problem '%s'."):format(ev.problem_id), { level = vim.log.levels.WARN }) + logger.log( + ("No tests found for problem '%s'."):format(ev.problem_id), + { level = vim.log.levels.WARN } + ) end for i, t in ipairs(ev.tests) do cached_tests[i] = { index = i, input = t.input, expected = t.expected } @@ -144,7 +150,10 @@ local function start_tests(platform, contest_id, problems) end end end, function() - logger.log(('Loaded %d test%s.'):format(to_fetch, to_fetch == 1 and '' or 's'), { level = vim.log.levels.INFO, override = true }) + logger.log( + ('Loaded %d test%s.'):format(to_fetch, to_fetch == 1 and '' or 's'), + { level = vim.log.levels.INFO, override = true } + ) end) end end @@ -280,10 +289,20 @@ function M.setup_problem(problem_id, language) if vim.fn.filereadable(source_file) == 1 then local existing = cache.get_file_state(vim.fn.fnamemodify(source_file, ':p')) - if existing and (existing.platform ~= platform or existing.contest_id ~= (state.get_contest_id() or '') or existing.problem_id ~= problem_id) then + if + existing + and ( + existing.platform ~= platform + or existing.contest_id ~= (state.get_contest_id() or '') + or existing.problem_id ~= problem_id + ) + then logger.log( ('File %q already exists for %s/%s %s.'):format( - source_file, existing.platform, existing.contest_id, existing.problem_id + source_file, + existing.platform, + existing.contest_id, + existing.problem_id ), { level = vim.log.levels.ERROR } ) diff --git a/lua/cp/submit.lua b/lua/cp/submit.lua index cc3f594..77e3d66 100644 --- a/lua/cp/submit.lua +++ b/lua/cp/submit.lua @@ -42,7 +42,10 @@ function M.submit(opts) local problem_id = state.get_problem_id() local language = (opts and opts.language) or state.get_language() if not platform or not contest_id or not problem_id or not language then - logger.log('No active problem. Use :CP first.', { level = vim.log.levels.ERROR }) + logger.log( + 'No active problem. Use :CP first.', + { level = vim.log.levels.ERROR } + ) return end diff --git a/lua/cp/ui/edit.lua b/lua/cp/ui/edit.lua index 5d7f764..93083aa 100644 --- a/lua/cp/ui/edit.lua +++ b/lua/cp/ui/edit.lua @@ -311,7 +311,10 @@ setup_keybindings = function(buf) end if is_tracked then - logger.log('Test buffer closed unexpectedly. Exiting editor.', { level = vim.log.levels.WARN }) + logger.log( + 'Test buffer closed unexpectedly. Exiting editor.', + { level = vim.log.levels.WARN } + ) M.toggle_edit() end end) @@ -368,7 +371,10 @@ function M.toggle_edit(test_index) state.get_platform(), state.get_contest_id(), state.get_problem_id() if not platform or not contest_id or not problem_id then - logger.log('No problem context. Run :CP first.', { level = vim.log.levels.ERROR }) + logger.log( + 'No problem context. Run :CP first.', + { level = vim.log.levels.ERROR } + ) return end diff --git a/lua/cp/ui/views.lua b/lua/cp/ui/views.lua index c2053b0..b2ee23d 100644 --- a/lua/cp/ui/views.lua +++ b/lua/cp/ui/views.lua @@ -74,7 +74,10 @@ function M.toggle_interactive(interactor_cmd) and contest_data.index_map and not contest_data.problems[contest_data.index_map[problem_id]].interactive then - logger.log('This problem is not interactive. Use :CP {run,panel}.', { level = vim.log.levels.ERROR }) + logger.log( + 'This problem is not interactive. Use :CP {run,panel}.', + { level = vim.log.levels.ERROR } + ) return end @@ -383,7 +386,10 @@ function M.ensure_io_view() and contest_data.index_map and contest_data.problems[contest_data.index_map[problem_id]].interactive then - logger.log('This problem is not interactive. Use :CP {run,panel}.', { level = vim.log.levels.ERROR }) + logger.log( + 'This problem is not interactive. Use :CP {run,panel}.', + { level = vim.log.levels.ERROR } + ) return end @@ -599,7 +605,10 @@ function M.run_io_view(test_indices_arg, debug, mode) end io_view_running = true - logger.log(('%s tests...'):format(debug and 'Debugging' or 'Running'), { level = vim.log.levels.INFO, override = true }) + logger.log( + ('%s tests...'):format(debug and 'Debugging' or 'Running'), + { level = vim.log.levels.INFO, override = true } + ) mode = mode or 'combined' @@ -792,7 +801,10 @@ function M.toggle_panel(panel_opts) and contest_data.index_map and contest_data.problems[contest_data.index_map[state.get_problem_id()]].interactive then - logger.log('This is an interactive problem. Use :CP interact instead.', { level = vim.log.levels.WARN }) + logger.log( + 'This is an interactive problem. Use :CP interact instead.', + { level = vim.log.levels.WARN } + ) return end diff --git a/lua/cp/utils.lua b/lua/cp/utils.lua index 4e88cc2..48e5dc5 100644 --- a/lua/cp/utils.lua +++ b/lua/cp/utils.lua @@ -152,7 +152,10 @@ local function discover_nix_submit_cmd() :wait() if result.code ~= 0 then - logger.log('nix build #submitEnv failed: ' .. (result.stderr or ''), { level = vim.log.levels.WARN }) + logger.log( + 'nix build #submitEnv failed: ' .. (result.stderr or ''), + { level = vim.log.levels.WARN } + ) return false end @@ -216,7 +219,10 @@ local function discover_nix_python() :wait() if result.code ~= 0 then - logger.log('nix build #pythonEnv failed: ' .. (result.stderr or ''), { level = vim.log.levels.WARN }) + logger.log( + 'nix build #pythonEnv failed: ' .. (result.stderr or ''), + { level = vim.log.levels.WARN } + ) return false end diff --git a/scrapers/atcoder.py b/scrapers/atcoder.py index 477d844..33d3574 100644 --- a/scrapers/atcoder.py +++ b/scrapers/atcoder.py @@ -367,7 +367,8 @@ def _submit_headless( page.wait_for_timeout(BROWSER_SETTLE_DELAY) page.locator('button[type="submit"]').click() page.wait_for_url( - lambda url: "/submissions/me" in url, timeout=BROWSER_SUBMIT_NAV_TIMEOUT["atcoder"] + lambda url: "/submissions/me" in url, + timeout=BROWSER_SUBMIT_NAV_TIMEOUT["atcoder"], ) except Exception as e: submit_error = str(e) diff --git a/scrapers/timeouts.py b/scrapers/timeouts.py index 3dd6620..1862349 100644 --- a/scrapers/timeouts.py +++ b/scrapers/timeouts.py @@ -4,7 +4,9 @@ HTTP_TIMEOUT = 15.0 BROWSER_SESSION_TIMEOUT = 15000 BROWSER_NAV_TIMEOUT = 10000 -BROWSER_SUBMIT_NAV_TIMEOUT: defaultdict[str, int] = defaultdict(lambda: BROWSER_NAV_TIMEOUT) +BROWSER_SUBMIT_NAV_TIMEOUT: defaultdict[str, int] = defaultdict( + lambda: BROWSER_NAV_TIMEOUT +) BROWSER_SUBMIT_NAV_TIMEOUT["codeforces"] = BROWSER_NAV_TIMEOUT * 2 BROWSER_TURNSTILE_POLL = 5000 BROWSER_ELEMENT_WAIT = 10000