ci: format

This commit is contained in:
Barrett Ruth 2026-03-05 01:39:59 -05:00
parent 2cdde85d36
commit 1afe41103f
Signed by: barrett
GPG key ID: A6C96C9349D2FC81
4 changed files with 17 additions and 25 deletions

View file

@ -338,7 +338,9 @@ def _submit_headless(
page.fill('input[name="username"]', credentials.get("username", ""))
page.fill('input[name="password"]', credentials.get("password", ""))
page.click("#submit")
page.wait_for_url(lambda url: "/login" not in url, timeout=BROWSER_NAV_TIMEOUT)
page.wait_for_url(
lambda url: "/login" not in url, timeout=BROWSER_NAV_TIMEOUT
)
except Exception as e:
login_error = str(e)
@ -365,7 +367,9 @@ def _submit_headless(
finally:
os.unlink(tmp_path)
page.locator('button[type="submit"]').click()
page.wait_for_url(lambda url: "/submissions/me" in url, timeout=BROWSER_NAV_TIMEOUT)
page.wait_for_url(
lambda url: "/submissions/me" in url, timeout=BROWSER_NAV_TIMEOUT
)
except Exception as e:
submit_error = str(e)

View file

@ -328,9 +328,7 @@ def _submit_headless(
_ensure_browser()
cookie_cache = (
Path.home() / ".cache" / "cp-nvim" / "codeforces-cookies.json"
)
cookie_cache = Path.home() / ".cache" / "cp-nvim" / "codeforces-cookies.json"
cookie_cache.parent.mkdir(parents=True, exist_ok=True)
saved_cookies: list[dict[str, Any]] = []
if cookie_cache.exists():
@ -372,9 +370,7 @@ def _submit_headless(
'input[name="password"]',
credentials.get("password", ""),
)
page.locator(
'#enterForm input[type="submit"]'
).click()
page.locator('#enterForm input[type="submit"]').click()
page.wait_for_url(
lambda url: "/enter" not in url, timeout=BROWSER_NAV_TIMEOUT
)
@ -394,24 +390,20 @@ def _submit_headless(
'select[name="submittedProblemIndex"]',
problem_id.upper(),
)
page.select_option(
'select[name="programTypeId"]', language_id
)
page.select_option('select[name="programTypeId"]', language_id)
with tempfile.NamedTemporaryFile(
mode="w", suffix=".cpp", delete=False, prefix="cf_"
) as tf:
tf.write(source_code)
tmp_path = tf.name
try:
page.set_input_files(
'input[name="sourceFile"]', tmp_path
)
page.set_input_files('input[name="sourceFile"]', tmp_path)
page.wait_for_timeout(BROWSER_SETTLE_DELAY)
except Exception:
page.fill('textarea[name="source"]', source_code)
finally:
os.unlink(tmp_path)
page.locator('form.submit-form input.submit').click()
page.locator("form.submit-form input.submit").click()
page.wait_for_url(
lambda url: "/my" in url or "/status" in url,
timeout=BROWSER_NAV_TIMEOUT,
@ -435,17 +427,13 @@ def _submit_headless(
try:
browser_cookies = session.context.cookies()
if any(
c["name"] == "JSESSIONID" for c in browser_cookies
):
if any(c["name"] == "JSESSIONID" for c in browser_cookies):
cookie_cache.write_text(json.dumps(browser_cookies))
except Exception:
pass
if login_error:
return SubmitResult(
success=False, error=f"Login failed: {login_error}"
)
return SubmitResult(success=False, error=f"Login failed: {login_error}")
if submit_error:
return SubmitResult(success=False, error=submit_error)

View file

@ -342,9 +342,7 @@ class CSESScraper(BaseScraper):
return None
return token
async def _check_token(
self, client: httpx.AsyncClient, token: str
) -> bool:
async def _check_token(self, client: httpx.AsyncClient, token: str) -> bool:
try:
r = await client.get(
f"{API_URL}/login",

View file

@ -58,7 +58,9 @@ RESULTS_PAGE_RE = re.compile(
async def _fetch_text(client: httpx.AsyncClient, url: str) -> str:
r = await client.get(url, headers=HEADERS, timeout=HTTP_TIMEOUT, follow_redirects=True)
r = await client.get(
url, headers=HEADERS, timeout=HTTP_TIMEOUT, follow_redirects=True
)
r.raise_for_status()
return r.text