Skip to content

Commit 85f5ebf

Browse files
committed
All fixes for passing refurb
1 parent d40a96b commit 85f5ebf

File tree

8 files changed

+10
-20
lines changed

8 files changed

+10
-20
lines changed

packages/paper-qa-pymupdf/src/paperqa_pymupdf/reader.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import pymupdf
55
from paperqa.types import ParsedMedia, ParsedMetadata, ParsedText
66
from paperqa.utils import ImpossibleParsingError
7-
from paperqa.version import __version__ as pqa_version
87

98

109
def setup_pymupdf_python_logging() -> None:
@@ -171,7 +170,6 @@ def parse_pdf_to_pages(
171170

172171
metadata = ParsedMetadata(
173172
parsing_libraries=[f"{pymupdf.__name__} ({pymupdf.__version__})"],
174-
paperqa_version=pqa_version,
175173
total_parsed_text_length=total_length,
176174
count_parsed_media=count_media,
177175
parse_type="pdf",

packages/paper-qa-pymupdf/tests/test_paperqa_pymupdf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ async def test_parse_pdf_to_pages() -> None:
7373
fig_1_text.text = "stub" # Replace text to confirm multimodality works
7474
docs = Docs()
7575
assert await docs.aadd_texts(texts=[fig_1_text], doc=doc)
76-
for query, substrings_min_counts in [
76+
for query, substrings_min_counts in (
7777
("What actions can the Crawler take?", [(("search", "expand", "stop"), 2)]),
7878
("What actions can the Selector take?", [(("select", "drop"), 2)]),
7979
(
8080
"How many User Query are there, and what do they do?",
8181
[(("two", "2"), 2), (("crawler", "selector"), 2)],
8282
),
83-
]:
83+
):
8484
session = await docs.aquery(query=query)
8585
assert session.contexts, "Expected contexts to be generated"
8686
assert all(
@@ -107,7 +107,7 @@ async def test_parse_pdf_to_pages() -> None:
107107
assert page_text
108108
assert full_page_image.index == 0, "Full page image should have index 0"
109109
assert isinstance(full_page_image.data, bytes)
110-
assert len(full_page_image.data) > 0, "Full page image should have data"
110+
assert full_page_image.data, "Full page image should have data"
111111
# Check useful attributes are present and are JSON serializable
112112
json.dumps(p2_image.info)
113113
for attr in ("width", "height"):

packages/paper-qa-pypdf/src/paperqa_pypdf/reader.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import pypdf
66
from paperqa.types import ParsedMedia, ParsedMetadata, ParsedText
77
from paperqa.utils import ImpossibleParsingError
8-
from paperqa.version import __version__ as pqa_version
98

109
try:
1110
import pypdfium2 as pdfium
@@ -96,7 +95,6 @@ def parse_pdf_to_pages(
9695
else pypdf_version_str
9796
)
9897
],
99-
paperqa_version=pqa_version,
10098
total_parsed_text_length=total_length,
10199
count_parsed_media=count_media,
102100
parse_type="pdf",

packages/paper-qa-pypdf/tests/test_paperqa_pypdf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ async def test_parse_pdf_to_pages() -> None:
7676
fig_1_text.text = "stub" # Replace text to confirm multimodality works
7777
docs = Docs()
7878
assert await docs.aadd_texts(texts=[fig_1_text], doc=doc)
79-
for query, substrings_min_counts in [
79+
for query, substrings_min_counts in (
8080
("What actions can the Crawler take?", [(("search", "expand", "stop"), 2)]),
8181
("What actions can the Selector take?", [(("select", "drop"), 2)]),
8282
(
8383
"How many User Query are there, and what do they do?",
8484
[(("two", "2"), 2), (("crawler", "selector"), 2)],
8585
),
86-
]:
86+
):
8787
session = await docs.aquery(query=query)
8888
assert session.contexts, "Expected contexts to be generated"
8989
assert all(

src/paperqa/agents/tools.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,8 @@ async def gather_evidence(self, question: str, state: EnvironmentState) -> str:
263263
)
264264

265265
top_contexts = "\n\n".join(
266-
[
267-
f"- {sc.context}"
268-
for n, sc in enumerate(
269-
sorted_contexts[: self.settings.agent.agent_evidence_n]
270-
)
271-
]
266+
f"- {sc.context}"
267+
for sc in sorted_contexts[: self.settings.agent.agent_evidence_n]
272268
)
273269

274270
best_evidence = (

src/paperqa/clients/journal_quality.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,7 @@ async def main() -> None:
204204
)
205205
records = await process_csv(downloaded_path)
206206

207-
with open( # noqa: ASYNC230
208-
DEFAULT_JOURNAL_QUALITY_CSV_PATH, "w", encoding="utf-8"
209-
) as csvfile:
207+
with DEFAULT_JOURNAL_QUALITY_CSV_PATH.open("w", encoding="utf-8") as csvfile:
210208
writer = csv.writer(csvfile)
211209
writer.writerow(["clean_name", "quality"])
212210
for name, quality in records:

src/paperqa/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ def string_to_bytes(value: str) -> bytes:
659659
"""Convert a base64-encoded string to bytes."""
660660
# 1. Convert base64 string to base64 bytes
661661
# 2. Convert base64 bytes to original bytes
662-
return base64.b64decode(value.encode("utf-8"))
662+
return base64.b64decode(value.encode("utf-8")) # noqa: FURB120
663663

664664

665665
def validate_image(path: StrOrBytesPath | IO[bytes]) -> None:

tests/test_paperqa.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1470,7 +1470,7 @@ async def test_read_doc_images_metadata(stub_data_dir: Path) -> None:
14701470
assert isinstance(parsed_image, ParsedMedia)
14711471
assert parsed_image.index == 0
14721472
assert isinstance(parsed_image.data, bytes)
1473-
assert len(parsed_image.data) > 0
1473+
assert parsed_image.data
14741474
assert not parsed_image.text, "Expected no text content for a standalone image"
14751475
assert parsed_image.info["suffix"] == ".png"
14761476
image_id = parsed_image.to_id()

0 commit comments

Comments
 (0)