From 1afe41103fb1f28d868e423cfe41ed0c3acb1d5f Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Thu, 5 Mar 2026 01:39:59 -0500 Subject: [PATCH] ci: format --- scrapers/atcoder.py | 8 ++++++-- scrapers/codeforces.py | 26 +++++++------------------- scrapers/cses.py | 4 +--- scrapers/usaco.py | 4 +++- 4 files changed, 17 insertions(+), 25 deletions(-) diff --git a/scrapers/atcoder.py b/scrapers/atcoder.py index 719135e..16eba40 100644 --- a/scrapers/atcoder.py +++ b/scrapers/atcoder.py @@ -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) diff --git a/scrapers/codeforces.py b/scrapers/codeforces.py index 05e4ba0..8eaa874 100644 --- a/scrapers/codeforces.py +++ b/scrapers/codeforces.py @@ -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) diff --git a/scrapers/cses.py b/scrapers/cses.py index fe819fc..7d9f4f0 100644 --- a/scrapers/cses.py +++ b/scrapers/cses.py @@ -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", diff --git a/scrapers/usaco.py b/scrapers/usaco.py index b78f88e..9e4d7da 100644 --- a/scrapers/usaco.py +++ b/scrapers/usaco.py @@ -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