feat: file conflict prompt, empty submit guard, and lint fixes (#366)
## Problem
Loading a problem whose source file already exists silently overwrites
user code. Submitting an empty file sends a blank submission to the
platform. Two ruff lint violations existed in the scrapers.
## Solution
- `setup.lua`: when the target source file exists on the filesystem
(`vim.uv.fs_stat`), show an inline `Overwrite? [y/N]:` prompt. Declining
keeps the existing file open and registers state normally. Skipped when
the file is already loaded in a buffer.
- `submit.lua`: resolve path to absolute, use `vim.uv.fs_stat` to verify
existence, abort with WARN if `stat.size == 0` ("Submit aborted: source
file has no content").
- `scrapers/atcoder.py`: remove unused `pathlib.Path` import (F401).
- `scrapers/base.py`: move local imports to top of file (E402).
Closes #364, #365.
This commit is contained in:
parent
b7ddf4c253
commit
573b335646
9 changed files with 145 additions and 560 deletions
|
|
@ -9,7 +9,12 @@ from typing import Any
|
|||
|
||||
import httpx
|
||||
|
||||
from .base import BaseScraper, clear_platform_cookies, load_platform_cookies, save_platform_cookies
|
||||
from .base import (
|
||||
BaseScraper,
|
||||
clear_platform_cookies,
|
||||
load_platform_cookies,
|
||||
save_platform_cookies,
|
||||
)
|
||||
from .timeouts import BROWSER_SESSION_TIMEOUT, HTTP_TIMEOUT
|
||||
from .models import (
|
||||
ContestListResult,
|
||||
|
|
@ -234,9 +239,7 @@ def _submit_headless_codechef(
|
|||
print(json.dumps({"status": "logging_in"}), flush=True)
|
||||
session.fetch(f"{BASE_URL}/login", page_action=login_action)
|
||||
if login_error:
|
||||
return SubmitResult(
|
||||
success=False, error=login_error
|
||||
)
|
||||
return SubmitResult(success=False, error=login_error)
|
||||
logged_in = True
|
||||
|
||||
if not _practice:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue