Skip to content

Commit 227fb09

Browse files
authored
Latest tooling (#804)
1 parent ec4e486 commit 227fb09

File tree

6 files changed

+59
-33
lines changed

6 files changed

+59
-33
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ repos:
2323
- id: mixed-line-ending
2424
- id: trailing-whitespace
2525
- repo: https://github.com/astral-sh/ruff-pre-commit
26-
rev: v0.8.4
26+
rev: v0.9.1
2727
hooks:
2828
- id: ruff
2929
args: [--fix, --exit-non-zero-on-fix]
@@ -55,15 +55,15 @@ repos:
5555
hooks:
5656
- id: check-mailmap
5757
- repo: https://github.com/henryiii/validate-pyproject-schema-store
58-
rev: 2024.11.25
58+
rev: 2025.01.10
5959
hooks:
6060
- id: validate-pyproject
6161
- repo: https://github.com/astral-sh/uv-pre-commit
6262
rev: 0.4.30
6363
hooks:
6464
- id: uv-lock
6565
- repo: https://github.com/renovatebot/pre-commit-hooks
66-
rev: 39.75.1
66+
rev: 39.100.1
6767
hooks:
6868
- id: renovate-config-validator
6969
args: [--strict]
@@ -72,11 +72,11 @@ repos:
7272
hooks:
7373
- id: blacken-docs
7474
- repo: https://github.com/jsh9/markdown-toc-creator
75-
rev: 0.0.8
75+
rev: 0.0.10
7676
hooks:
7777
- id: markdown-toc-creator
7878
- repo: https://github.com/pre-commit/mirrors-mypy
79-
rev: v1.13.0
79+
rev: v1.14.1
8080
hooks:
8181
- id: mypy
8282
args: [--pretty, --ignore-missing-imports]

paperqa/agents/search.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import pickle
1010
import warnings
1111
import zlib
12-
from collections.abc import Awaitable, Callable, Collection, Sequence
12+
from collections.abc import Callable, Collection, Sequence
1313
from enum import StrEnum, auto
1414
from typing import TYPE_CHECKING, Any, ClassVar
1515
from uuid import UUID
@@ -456,7 +456,7 @@ async def process_file(
456456
manifest: dict[str, Any],
457457
semaphore: anyio.Semaphore,
458458
settings: Settings,
459-
progress_bar_update: Callable[[], Awaitable] | None = None,
459+
progress_bar_update: Callable[[], Any] | None = None,
460460
) -> None:
461461
abs_file_path = (
462462
pathlib.Path(settings.agent.index.paper_directory).absolute() / rel_file_path
@@ -500,7 +500,7 @@ async def process_file(
500500
# separate process_file invocation leads to a segfault or crash
501501
await search_index.save_index()
502502
if progress_bar_update:
503-
await progress_bar_update()
503+
progress_bar_update()
504504
return
505505

506506
this_doc = next(iter(tmp_docs.docs.values()))
@@ -527,15 +527,15 @@ async def process_file(
527527

528528
# Update progress bar for either a new or previously indexed file
529529
if progress_bar_update:
530-
await progress_bar_update()
530+
progress_bar_update()
531531

532532

533533
WARN_IF_INDEXING_MORE_THAN = 999
534534

535535

536536
def _make_progress_bar_update(
537537
sync_index_w_directory: bool, total: int
538-
) -> tuple[contextlib.AbstractContextManager, Callable[[], Awaitable] | None]:
538+
) -> tuple[contextlib.AbstractContextManager, Callable[[], Any] | None]:
539539
# Disable should override enable
540540
env_var_disable = (
541541
os.environ.get("PQA_INDEX_DISABLE_PROGRESS_BAR", "").lower() in ENV_VAR_MATCH
@@ -562,7 +562,7 @@ def _make_progress_bar_update(
562562
)
563563
task_id = progress.add_task("Indexing...", total=total)
564564

565-
async def progress_bar_update() -> None:
565+
def progress_bar_update() -> None:
566566
progress.update(task_id, advance=1)
567567

568568
return progress, progress_bar_update

paperqa/clients/openalex.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def reformat_name(name: str) -> str:
3333
return f"{given_names} {family}"
3434

3535

36-
async def get_openalex_mailto() -> str | None:
36+
def get_openalex_mailto() -> str | None:
3737
"""Get the OpenAlex mailto address.
3838
3939
Returns:
@@ -71,7 +71,7 @@ async def get_doc_details_from_openalex(
7171
ValueError: If neither DOI nor title is provided.
7272
DOINotFoundError: If the paper cannot be found.
7373
"""
74-
mailto = await get_openalex_mailto()
74+
mailto = get_openalex_mailto()
7575
params = {"mailto": mailto} if mailto else {}
7676

7777
if doi is title is None:
@@ -126,10 +126,10 @@ async def get_doc_details_from_openalex(
126126
if doi and results_data.get("doi") != doi:
127127
raise DOINotFoundError(f"DOI {doi!r} not found in OpenAlex.")
128128

129-
return await parse_openalex_to_doc_details(results_data)
129+
return parse_openalex_to_doc_details(results_data)
130130

131131

132-
async def parse_openalex_to_doc_details(message: dict[str, Any]) -> DocDetails:
132+
def parse_openalex_to_doc_details(message: dict[str, Any]) -> DocDetails:
133133
"""Parse OpenAlex API response to DocDetails.
134134
135135
Args:

pyproject.toml

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,12 @@ enable_all = true
287287
ignore = [
288288
"FURB101", # Rely on ruff FURB101 for this
289289
"FURB103", # Rely on ruff FURB103 for this
290-
"FURB141", # FURB141, FURB144, FURB146, FURB147, FURB150, FURB155: don't care to enforce pathlib
291-
"FURB144",
292-
"FURB146",
293-
"FURB147",
294-
"FURB150",
295-
"FURB155",
290+
"FURB141", # Rely on ruff PTH110 for this
291+
"FURB144", # Rely on ruff PTH107 for this
292+
"FURB146", # Rely on ruff PTH113 for this
293+
"FURB147", # Rely on ruff PTH118 for this
294+
"FURB150", # Rely on ruff PTH102 for this
295+
"FURB155", # Rely on ruff PTH202 for this
296296
]
297297

298298
[tool.ruff]
@@ -310,10 +310,13 @@ preview = true
310310
[tool.ruff.lint]
311311
explicit-preview-rules = true
312312
extend-select = [
313-
"A006",
313+
"AIR301",
314+
"AIR302",
315+
"AIR303",
314316
"ASYNC116",
315317
"B901",
316318
"B909",
319+
"B911",
317320
"C420",
318321
"DOC202",
319322
"DOC403",
@@ -359,6 +362,7 @@ extend-select = [
359362
"E305",
360363
"E306",
361364
"E502",
365+
"FAST003",
362366
"FURB101",
363367
"FURB103",
364368
"FURB110",
@@ -379,32 +383,51 @@ extend-select = [
379383
"FURB166",
380384
"FURB171",
381385
"FURB180",
382-
"FURB181",
383-
"FURB188",
384386
"FURB189",
385387
"FURB192",
386388
"LOG015",
389+
"PLC1802",
387390
"PLC1901",
388391
"PLC2701",
389392
"PLC2801",
390393
"PLE0304",
391394
"PLE1141",
392395
"PLE4703",
396+
"PLR0202",
397+
"PLR0203",
398+
"PLR0916",
399+
"PLR1733",
400+
"PLR6104",
393401
"PLR6201",
394402
"PLW0108",
403+
"PLW0177",
404+
"PLW1507",
405+
"PLW3201",
406+
"PTH210",
395407
"PYI059",
408+
"PYI061",
396409
"RUF027",
397410
"RUF028",
411+
"RUF029",
398412
"RUF031",
399-
"RUF032",
400-
"RUF033",
401-
"RUF034",
402413
"RUF035",
403414
"RUF036",
415+
"RUF037",
404416
"RUF038",
405417
"RUF039",
418+
"RUF040",
419+
"RUF041",
420+
"RUF043",
406421
"RUF048",
422+
"RUF049",
423+
"RUF051",
424+
"RUF052",
425+
"RUF055",
426+
"RUF056",
427+
"RUF057",
407428
"SIM905",
429+
"TC007",
430+
"TC008",
408431
"UP042",
409432
"UP044",
410433
"W391",
@@ -416,6 +439,7 @@ external = [
416439
"FURB", # refurb
417440
]
418441
ignore = [
442+
"A005", # Overly pedantic
419443
"ANN", # Don't care to enforce typing
420444
"BLE001", # Don't care to enforce blind exception catching
421445
"C901", # we can be complex
@@ -453,6 +477,7 @@ ignore = [
453477
"PLW2901", # Allow modifying loop variables
454478
"PTH", # Overly pedantic
455479
"RUF027", # Prompt templates may not be f-strings
480+
"RUF052", # Previous code uses leading underscore to indicate throwaway
456481
"S311", # Ok to use python random
457482
"SLF001", # Overly pedantic
458483
"T201", # Overly pedantic

tests/test_agents.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,9 @@ async def test_successful_memory_agent(agent_test_settings: Settings) -> None:
331331
thoughts: list[str] = []
332332
orig_llm_model_call = MultipleCompletionLLMModel.call
333333

334-
async def on_agent_action(action: OpResult[ToolRequestMessage], *_) -> None:
334+
async def on_agent_action( # noqa: RUF029
335+
action: OpResult[ToolRequestMessage], *_
336+
) -> None:
335337
thoughts.append(extract_thought(content=action.value.content))
336338

337339
async def llm_model_call(*args, **kwargs):
@@ -415,7 +417,7 @@ async def test_gather_evidence_rejects_empty_docs(
415417
) -> None:
416418

417419
@wraps(GenerateAnswer.gen_answer)
418-
async def gen_answer(self, state) -> str: # noqa: ARG001
420+
async def gen_answer(self, state) -> str: # noqa: ARG001, RUF029
419421
return f"{CANNOT_ANSWER_PHRASE}."
420422

421423
# Patch GenerateAnswerTool.gen_answer so that if this tool is chosen first,
@@ -919,7 +921,7 @@ async def test_unsure_answer(
919921
) -> None:
920922
unsure_answer = "Based on the sources provided, it appears no one has done x."
921923

922-
async def emulate_answered_but_unsure(
924+
async def emulate_answered_but_unsure( # noqa: RUF029
923925
*_, query: PQASession, **__
924926
) -> PQASession:
925927
query.answer = unsure_answer

tests/test_clients.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,10 +529,9 @@ async def test_ensure_robust_to_timeouts() -> None:
529529
assert details is None, "Should return None for timeout"
530530

531531

532-
@pytest.mark.asyncio
533-
async def test_bad_init() -> None:
532+
def test_bad_init() -> None:
534533
with pytest.raises(
535-
ValueError, match="At least one MetadataProvider must be provided."
534+
ValueError, match=r"At least one MetadataProvider must be provided."
536535
):
537536
client = DocMetadataClient(clients=[]) # noqa: F841
538537

0 commit comments

Comments
 (0)