treefmt-check
default.checks.x86_64-linux.treefmt
· build #52
· raw
1treefmt v2.5.0ERRO formatter | ruff-check: failed to apply with options '[check --fix]': exit status 123DTZ011 `datetime.date.today()` used4 --> eval/seed-recall/run.py:107:205 |6106 | db = PGStore(settings.pg_conninfo)7107 | current_year = datetime.date.today().year8 | ^^^^^^^^^^^^^^^^^^^^^9108 | seed_scores: list[tuple[str, float]] = []10109 | for seed in seeds:11 |12help: Use `datetime.datetime.now(tz=...).date()` instead1314PLW1510 `subprocess.run` without explicit `check` argument15 --> quarry/assets/download.py:237:1116 |17236 | # Dry-run to count pending operations18237 | dry = subprocess.run(19 | ^^^^^^^^^^^^^^20238 | base_cmd + ["--dryrun"],21239 | capture_output=True,22 |23help: Add explicit `check=False`2425PLW1510 `subprocess.run` without explicit `check` argument26 --> quarry/assets/load.py:403:1627 |28401 | def _optimize(table: str) -> tuple[str, int, str]:29402 | query = f"OPTIMIZE TABLE {table} FINAL"30403 | proc = subprocess.run(31 | ^^^^^^^^^^^^^^32404 | _ch_client_cmd() + ["--query", query],33405 | capture_output=True,34 |35help: Add explicit `check=False`3637ISC004 Unparenthesized implicit string concatenation in collection38 --> quarry/assets/load.py:510:939 |40508 | "papers_export",41509 | "papers",42510 | / "pmid, doi, pmc_id, title, abstract, pub_year, pub_date, "43511 | | "journal_title, journal_issn, journal_abbr, volume, issue, pages, "44512 | | "language, pub_type, country, medline_status, created_date, revised_date, "45513 | | "indexed_date, is_deleted, deleted_date, rcr, nih_percentile, apt, "46514 | | "is_clinical, human, animal, molecular_cellular, field_citation_rate",47 | |_____________________________________________________________________________^48515 | ),49516 | (50 |51help: Did you forget a comma?52help: Wrap implicitly concatenated strings in parentheses5354ISC004 Unparenthesized implicit string concatenation in collection55 --> quarry/assets/load.py:519:956 |57517 | "oa_work_authors",58518 | "work_authors",59519 | / "work_id, author_position, display_name, orcid, "60520 | | "institution_name, institution_ror, raw_affiliation",61 | |____________________________________________________________^62521 | ),63522 | (64 |65help: Did you forget a comma?66help: Wrap implicitly concatenated strings in parentheses6768ISC004 Unparenthesized implicit string concatenation in collection69 --> quarry/assets/load.py:530:970 |71528 | "pm_authors",72529 | "authors",73530 | / "pmid, author_position, last_name, fore_name, initials, "74531 | | "orcid, affiliation, is_collective",75 | |___________________________________________^76532 | ),77533 | (78 |79help: Did you forget a comma?80help: Wrap implicitly concatenated strings in parentheses8182ISC004 Unparenthesized implicit string concatenation in collection83 --> quarry/assets/load.py:536:984 |85534 | "pm_mesh_headings",86535 | "mesh_headings",87536 | / "pmid, descriptor_ui, descriptor_name, qualifier_ui, "88537 | | "qualifier_name, is_major_topic",89 | |________________________________________^90538 | ),91539 | ("pm_grants", "grants", "pmid, grant_id, acronym, agency, country"),92 |93help: Did you forget a comma?94help: Wrap implicitly concatenated strings in parentheses9596ISC004 Unparenthesized implicit string concatenation in collection97 --> quarry/assets/load.py:557:998 |99555 | "work_mesh_export",100556 | "work_mesh",101557 | / "work_id, descriptor_ui, descriptor_name, qualifier_ui, "102558 | | "qualifier_name, is_major_topic",103 | |________________________________________^104559 | ),105560 | ("cited_by_clin_export", "cited_by_clin", "pmid, citing_pmid"),106 |107help: Did you forget a comma?108help: Wrap implicitly concatenated strings in parentheses109110PLW1510 `subprocess.run` without explicit `check` argument111 --> quarry/assets/load.py:574:16112 |113572 | cmd = _ch_client_cmd() + ["--query", query + " FORMAT Parquet"]114573 | with open(out_path, "wb") as f:115574 | return subprocess.run(cmd, stdout=f, stderr=subprocess.PIPE, text=True)116 | ^^^^^^^^^^^^^^117help: Add explicit `check=False`118119BLE001 Do not catch blind exception: `Exception`120 --> quarry/assets/load.py:843:20121 |122841 | done += 1123842 | context.log.info(f"[PG] {name} done [{done}/{total}]")124843 | except Exception as exc:125 | ^^^^^^^^^126844 | context.log.error(f"[PG] {name} failed: {exc}")127845 | failed.append(name)128 |129130B008 Do not perform function call `typer.Argument` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable131 --> quarry/cli.py:56:27132 |13354 | @app.command()13455 | def info(13556 | work_ids: list[str] = typer.Argument(136 | ___________________________^13757 | | ..., help="One or more work IDs: W<id>, DOI, PMID"13858 | | ),139 | |_____^14059 | full: bool = typer.Option(False, "--full", help="Show full abstract"),14160 | show_mesh: bool = typer.Option(False, "--mesh", help="Show MeSH descriptors"),142 |143144PIE810 Call `startswith` once with a `tuple`145 --> quarry/cli.py:163:8146 |147162 | # DOI148163 | if identifier.startswith("10.") or identifier.startswith("https://doi.org/"):149 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^150164 | doi = "https://doi.org/" + identifier.removeprefix("https://doi.org/").lower()151165 | return db.get_work_by_doi(doi)152 |153help: Merge into a single `startswith` call154155B008 Do not perform function call `typer.Argument` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable156 --> quarry/cli.py:690:24157 |158688 | @app.command()159689 | def bridge(160690 | seeds: list[str] = typer.Argument(161 | ________________________^162691 | | ...,163692 | | help="Two or more seed papers: work_id_int, W<id>, DOI, or https://doi.org/...",164693 | | ),165 | |_____^166694 | types: list[str] = typer.Option(167695 | None,168 |169170B008 Do not perform function call `typer.Option` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable171 --> quarry/cli.py:694:24172 |173692 | help="Two or more seed papers: work_id_int, W<id>, DOI, or https://doi.org/...",174693 | ),175694 | types: list[str] = typer.Option(176 | ________________________^177695 | | None,178696 | | "--type",179697 | | "-t",180698 | | help="Bridge types to compute (default: all). "181699 | | "Options: common_refs, common_citers, coupling, cocitation, path, ppr",182700 | | ),183 | |_____^184701 | limit: int = typer.Option(100, "--limit", "-n", help="Max results per type"),185702 | max_neighbor_degree: int = typer.Option(186 |187188PIE810 Call `startswith` once with a `tuple`189 --> quarry/core/expand.py:211:8190 |191210 | # DOI — normalize to OA format192211 | if seed.startswith("10.") or seed.startswith("https://doi.org/"):193 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^194212 | doi = "https://doi.org/" + seed.removeprefix("https://doi.org/").lower()195213 | with psycopg.connect(pg_conninfo) as conn, conn.cursor() as cur:196 |197help: Merge into a single `startswith` call198199BLE001 Do not catch blind exception: `Exception`200 --> quarry/core/expand.py:259:12201 |202257 | result[row[0]] = entry203258 | return result204259 | except Exception:205 | ^^^^^^^^^206260 | return {}207 |208209PLW1510 `subprocess.run` without explicit `check` argument210 --> quarry/etl/embeddings.py:60:12211 |21258 | def _ch_exec(query: str) -> str:21359 | """Execute CH query, return stdout. Raises on error."""21460 | proc = subprocess.run(215 | ^^^^^^^^^^^^^^21661 | _ch_cmd() + ["--query", query],21762 | capture_output=True,218 |219help: Add explicit `check=False`220221BLE001 Do not catch blind exception: `Exception`222 --> quarry/etl/embeddings.py:335:16223 |224333 | try:225334 | _ch_exec(f"DROP TABLE IF EXISTS {table}")226335 | except Exception as exc:227 | ^^^^^^^^^228336 | logger.warning("Failed to drop %s: %s", table, exc)229 |230231BLE001 Do not catch blind exception: `Exception`232 --> quarry/etl/embeddings.py:352:12233 |234350 | logger.info("Building work_id BTree index for hash lookups...")235351 | lance.create_scalar_index("work_id")236352 | except Exception:237 | ^^^^^^^^^238353 | lance.create_table()239 |240241SIM113 Use `enumerate()` for index variable `batch_num` in `for` loop242 --> quarry/etl/embeddings.py:407:13243 |244406 | total_encoded += len(to_encode)245407 | batch_num += 1246 | ^^^^^^^^^^^^^^247408 | throughput = len(texts) / elapsed if elapsed > 0 else 0248 |249250DTZ007 Naive datetime constructed using `datetime.datetime.strptime()` without %z251 --> quarry/etl/fetch.py:68:29252 |25366 | if modify:25467 | try:25568 | remote_ts = datetime.strptime(modify[:14], "%Y%m%d%H%M%S")256 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^25769 | local_ts = datetime.fromtimestamp(local_path.stat().st_mtime)25870 | if remote_ts > local_ts:259 |260help: Call `.replace(tzinfo=<timezone>)` or `.astimezone()` to convert to an aware datetime261262DTZ006 `datetime.datetime.fromtimestamp()` called without a `tz` argument263 --> quarry/etl/fetch.py:69:28264 |26567 | try:26668 | remote_ts = datetime.strptime(modify[:14], "%Y%m%d%H%M%S")26769 | local_ts = datetime.fromtimestamp(local_path.stat().st_mtime)268 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^26970 | if remote_ts > local_ts:27071 | to_download.append(name)271 |272help: Pass a `datetime.timezone` object to the `tz` parameter273274S110 `try`-`except`-`pass` detected, consider logging the exception275 --> quarry/etl/fetch.py:121:29276 |277119 | … try:278120 | … conn.close()279121 | / … except Exception:280122 | | … pass281 | |______________________________^282123 | … conn = ftplib.FTP(host, timeout=120)283124 | … conn.login()284 |285286BLE001 Do not catch blind exception: `Exception`287 --> quarry/etl/fetch.py:121:36288 |289119 | … try:290120 | … conn.close()291121 | … except Exception:292 | ^^^^^^^^^293122 | … pass294123 | … conn = ftplib.FTP(host, timeout=120)295 |296297S110 `try`-`except`-`pass` detected, consider logging the exception298 --> quarry/etl/fetch.py:128:13299 |300126 | try:301127 | conn.quit()302128 | / except Exception:303129 | | pass304 | |____________________^305130 | return results306 |307308BLE001 Do not catch blind exception: `Exception`309 --> quarry/etl/fetch.py:128:20310 |311126 | try:312127 | conn.quit()313128 | except Exception:314 | ^^^^^^^^^315129 | pass316130 | return results317 |318319DTZ005 `datetime.datetime.now()` called without a `tz` argument320 --> quarry/etl/fetch.py:189:15321 |322188 | if dest.exists() and max_age_days is not None:323189 | age = datetime.now() - datetime.fromtimestamp(dest.stat().st_mtime)324 | ^^^^^^^^^^^^^^325190 | if age < timedelta(days=max_age_days):326191 | return {"status": "fresh", "path": str(dest), "bytes": dest.stat().st_size}327 |328help: Pass a `datetime.timezone` object to the `tz` parameter329330DTZ006 `datetime.datetime.fromtimestamp()` called without a `tz` argument331 --> quarry/etl/fetch.py:189:32332 |333188 | if dest.exists() and max_age_days is not None:334189 | age = datetime.now() - datetime.fromtimestamp(dest.stat().st_mtime)335 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^336190 | if age < timedelta(days=max_age_days):337191 | return {"status": "fresh", "path": str(dest), "bytes": dest.stat().st_size}338 |339help: Pass a `datetime.timezone` object to the `tz` parameter340341DTZ005 `datetime.datetime.now()` called without a `tz` argument342 --> quarry/etl/fetch.py:247:15343 |344246 | if target.exists():345247 | age = datetime.now() - datetime.fromtimestamp(target.stat().st_mtime)346 | ^^^^^^^^^^^^^^347248 | if age < timedelta(days=max_age_days):348249 | return {349 |350help: Pass a `datetime.timezone` object to the `tz` parameter351352DTZ006 `datetime.datetime.fromtimestamp()` called without a `tz` argument353 --> quarry/etl/fetch.py:247:32354 |355246 | if target.exists():356247 | age = datetime.now() - datetime.fromtimestamp(target.stat().st_mtime)357 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^358248 | if age < timedelta(days=max_age_days):359249 | return {360 |361help: Pass a `datetime.timezone` object to the `tz` parameter362363SIM117 Use a single `with` statement with multiple contexts instead of nested `with` statements364 --> quarry/etl/fetch.py:259:5365 |366258 | tmp_target = target.with_suffix(target.suffix + ".tmp")367259 | / with zipfile.ZipFile(zip_path) as zf:368260 | | # Extract only the expected file to a temp path369261 | | with zf.open(expected_file) as src, open(tmp_target, "wb") as dst:370 | |__________________________________________________________________________^371262 | while chunk := src.read(65536):372263 | dst.write(chunk)373 |374help: Combine `with` statements375376BLE001 Do not catch blind exception: `Exception`377 --> quarry/fetch.py:109:12378 |379107 | try:380108 | tree = lxml_html.fromstring(html_bytes)381109 | except Exception:382 | ^^^^^^^^^383110 | return None384 |385386BLE001 Do not catch blind exception: `Exception`387 --> quarry/fetch.py:146:12388 |389144 | p.remove(tag)390145 | return " ".join(tree.text_content().split())391146 | except Exception:392 | ^^^^^^^^^393147 | return ""394 |395396BLE001 Do not catch blind exception: `Exception`397 --> quarry/fetch.py:223:12398 |399221 | result = converter.convert(stream)400222 | return result.document.export_to_markdown()401223 | except Exception:402 | ^^^^^^^^^403224 | return ""404 |405406BLE001 Do not catch blind exception: `Exception`407 --> quarry/fetch.py:288:12408 |409286 | result.layer = "FAIL"410287 |411288 | except Exception as e:412 | ^^^^^^^^^413289 | result.notes.append(f"error: {e}")414290 | result.layer = "FAIL"415 |416417BLE001 Do not catch blind exception: `Exception`418 --> quarry/fetch.py:342:12419 |420340 | result.notes.append(f"unexpected ct: {ct[:40]}")421341 |422342 | except Exception as e:423 | ^^^^^^^^^424343 | result.notes.append(f"error: {e}")425 |426427S110 `try`-`except`-`pass` detected, consider logging the exception428 --> quarry/fetch.py:381:21429 |430379 | try:431380 | pdf_data.append(await response.body())432381 | / except Exception:433382 | | pass434 | |____________________________^435383 |436384 | page.on("response", intercept_pdf)437 |438439BLE001 Do not catch blind exception: `Exception`440 --> quarry/fetch.py:381:28441 |442379 | try:443380 | pdf_data.append(await response.body())444381 | except Exception:445 | ^^^^^^^^^446382 | pass447 |448449BLE001 Do not catch blind exception: `Exception`450 --> quarry/fetch.py:429:20451 |452427 | result.notes.append("no PDF found in rendered page")453428 |454429 | except Exception as e:455 | ^^^^^^^^^456430 | result.notes.append(f"navigation error: {e}")457431 | finally:458 |459460BLE001 Do not catch blind exception: `Exception`461 --> quarry/fetch.py:434:12462 |463432 | await browser.close()464433 |465434 | except Exception as e:466 | ^^^^^^^^^467435 | result.notes.append(f"L2 error: {e}")468 |469470BLE001 Do not catch blind exception: `Exception`471 --> quarry/fetch.py:475:12472 |473473 | result.notes.append(f"text: {text[:60]!r}")474474 |475475 | except Exception as e:476 | ^^^^^^^^^477476 | result.layer = "FAIL"478477 | result.notes.append(f"error: {e}")479 |480481BLE001 Do not catch blind exception: `Exception`482 --> quarry/fetch.py:551:12483 |484549 | result.notes.append(f"unpaywall -> {oa_url[:70]}")485550 |486551 | except Exception as e:487 | ^^^^^^^^^488552 | result.layer = "FAIL"489553 | result.notes.append(f"unpaywall error: {e}")490 |491492SIM102 Use a single `if` statement instead of nested `if` statements493 --> quarry/fetch.py:580:5494 |495578 | # API — Zenodo496579 | r_api = await _zenodo_api(url)497580 | / if r_api is not None:498581 | | if r_api.success:499 | |_________________________^500582 | return r_api501583 | # Recognized zenodo record but failed — fall through to L1502 |503help: Combine `if` statements using `and`504505PLW1510 `subprocess.run` without explicit `check` argument506 --> tests/integration/conftest.py:67:9507 |50865 | """Run a command with logging."""50966 | logger.info(f"[{label}] {' '.join(cmd)}")51067 | r = subprocess.run(cmd, capture_output=True, text=True)511 | ^^^^^^^^^^^^^^51268 | if r.stdout.strip():51369 | for line in r.stdout.strip().split("\n"):514 |515help: Add explicit `check=False`516517PLW1510 `subprocess.run` without explicit `check` argument518 --> tests/integration/conftest.py:164:5519 |520162 | )521163 | # Kill any lingering clickhouse-client processes targeting quarry_test522164 | subprocess.run(523 | ^^^^^^^^^^^^^^524165 | ["pkill", "-f", f"clickhouse-client.*{TEST_CH_DATABASE}"],525166 | capture_output=True,526 |527help: Add explicit `check=False`528529PLW1510 `subprocess.run` without explicit `check` argument530 --> tests/integration/test_pipeline.py:276:13531 |532274 | out_dir = PARSED_DIR / "oa"533275 | out_dir.mkdir(parents=True, exist_ok=True)534276 | r = subprocess.run(535 | ^^^^^^^^^^^^^^536277 | [537278 | "quarry-parse",538 |539help: Add explicit `check=False`540541PLW1510 `subprocess.run` without explicit `check` argument542 --> tests/integration/test_pipeline.py:295:13543 |544293 | out_dir = PARSED_DIR / "pubmed"545294 | out_dir.mkdir(parents=True, exist_ok=True)546295 | r = subprocess.run(547 | ^^^^^^^^^^^^^^548296 | [549297 | "quarry-parse",550 |551help: Add explicit `check=False`552553PLW1510 `subprocess.run` without explicit `check` argument554 --> tests/integration/test_pipeline.py:315:13555 |556313 | out_dir.mkdir(parents=True, exist_ok=True)557314 | xml_path = DATA_DIR / "pubmed" / "mesh" / "desc_test.xml"558315 | r = subprocess.run(559 | ^^^^^^^^^^^^^^560316 | [561317 | "quarry-parse",562 |563help: Add explicit `check=False`564565PLW1510 `subprocess.run` without explicit `check` argument566 --> tests/integration/test_pipeline.py:414:13567 |568413 | # Verify PG has data569414 | r = subprocess.run(570 | ^^^^^^^^^^^^^^571415 | ["psql", settings.pg_conninfo, "-t", "-c", "SELECT count(*) FROM works"],572416 | capture_output=True,573 |574help: Add explicit `check=False`575576PLW1510 `subprocess.run` without explicit `check` argument577 --> tests/integration/test_pipeline.py:424:13578 |579423 | # Verify join worked (works_export has PM/iCite enrichment)580424 | r = subprocess.run(581 | ^^^^^^^^^^^^^^582425 | [583426 | "psql",584 |585help: Add explicit `check=False`586587PLW1510 `subprocess.run` without explicit `check` argument588 --> tests/integration/test_pipeline.py:453:17589 |590451 | print("\n=== PG table summary ===")591452 | for t in tables:592453 | r = subprocess.run(593 | ^^^^^^^^^^^^^^594454 | ["psql", settings.pg_conninfo, "-t", "-c", f"SELECT count(*) FROM {t}"],595455 | capture_output=True,596 |597help: Add explicit `check=False`598599PLW1510 `subprocess.run` without explicit `check` argument600 --> tests/unit/test_cli_features.py:17:12601 |60215 | def _quarry(*args: str, timeout: int = 60) -> subprocess.CompletedProcess:60316 | """Run quarry CLI command and return result."""60417 | return subprocess.run(605 | ^^^^^^^^^^^^^^60618 | ["quarry", *args],60719 | capture_output=True,608 |609help: Add explicit `check=False`610611Found 73 errors (21 fixed, 52 remaining).612No fixes available (8 hidden fixes can be enabled with the `--unsafe-fixes` option).613614traversed 171 files615emitted 140 files for processing616formatted 93 files (7 changed) in 535ms617Error: failed to finalise formatting: formatting failures detected