Skip to content

Commit

Permalink
Ran 'pre-commit run -a' with black preview formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesbraza committed Oct 25, 2024
1 parent 6d5eedd commit 6c7bf74
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 39 deletions.
3 changes: 2 additions & 1 deletion paperqa/agents/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ async def run_aviary_agent(
while not done:
if max_timesteps is not None and timestep >= max_timesteps:
logger.warning(
f"Agent didn't finish within {max_timesteps} timesteps, just answering."
f"Agent didn't finish within {max_timesteps} timesteps, just"
" answering."
)
generate_answer_tool = next(
filter(
Expand Down
21 changes: 9 additions & 12 deletions paperqa/agents/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ async def maybe_get_manifest(
}
if not file_loc_to_records:
raise ValueError( # noqa: TRY301
f"No mapping of file location to details extracted from manifest"
"No mapping of file location to details extracted from manifest"
f" file {filename}."
)
logger.debug(
Expand Down Expand Up @@ -593,11 +593,9 @@ async def get_directory_index( # noqa: PLR0912
index_settings = _settings.agent.index
if index_name:
warnings.warn(
(
f"The index_name argument has been moved to"
f" {type(_settings.agent.index).__name__},"
" this deprecation will conclude in version 6."
),
"The index_name argument has been moved to"
f" {type(_settings.agent.index).__name__},"
" this deprecation will conclude in version 6.",
category=DeprecationWarning,
stacklevel=2,
)
Expand All @@ -620,11 +618,9 @@ async def get_directory_index( # noqa: PLR0912

if not sync_index_w_directory:
warnings.warn(
(
f"The sync_index_w_directory argument has been moved to"
f" {type(_settings.agent.index).__name__},"
" this deprecation will conclude in version 6."
),
"The sync_index_w_directory argument has been moved to"
f" {type(_settings.agent.index).__name__},"
" this deprecation will conclude in version 6.",
category=DeprecationWarning,
stacklevel=2,
)
Expand Down Expand Up @@ -686,7 +682,8 @@ async def get_directory_index( # noqa: PLR0912
)
else:
logger.debug(
f"File {rel_file_path} found in paper directory {paper_directory}."
f"File {rel_file_path} found in paper directory"
f" {paper_directory}."
)

if search_index.changed:
Expand Down
3 changes: 2 additions & 1 deletion paperqa/llms.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ def __init__(self, **kwargs):
from sentence_transformers import SentenceTransformer
except ImportError as exc:
raise ImportError(
"Please install paper-qa[local] to use SentenceTransformerEmbeddingModel."
"Please install paper-qa[local] to use"
" SentenceTransformerEmbeddingModel."
) from exc

self._model = SentenceTransformer(self.name)
Expand Down
3 changes: 2 additions & 1 deletion paperqa/rate_limiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ async def try_acquire(

if rate_limit.amount < weight and raise_impossible_limits:
raise ValueError(
f"Weight ({weight}) > RateLimit ({rate_limit}), cannot satisfy rate limit."
f"Weight ({weight}) > RateLimit ({rate_limit}), cannot satisfy rate"
" limit."
)
while True:
elapsed = 0.0
Expand Down
33 changes: 15 additions & 18 deletions paperqa/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,9 @@ def _deprecated_field(self) -> Self:
# default is True, so we only warn if it's False
if not self.evidence_detailed_citations:
warnings.warn(
(
"The 'evidence_detailed_citations' field is deprecated and will be"
" removed in version 6. Adjust 'PromptSettings.context_inner' to remove"
" detailed citations."
),
"The 'evidence_detailed_citations' field is deprecated and will be"
" removed in version 6. Adjust 'PromptSettings.context_inner' to remove"
" detailed citations.",
category=DeprecationWarning,
stacklevel=2,
)
Expand Down Expand Up @@ -259,8 +257,10 @@ class PromptSettings(BaseModel):
)
context_inner: str = Field(
default=CONTEXT_INNER_PROMPT,
description="Prompt for how to format a single context in generate answer. "
"This should at least contain key and name.",
description=(
"Prompt for how to format a single context in generate answer. "
"This should at least contain key and name."
),
)

@field_validator("summary")
Expand Down Expand Up @@ -380,7 +380,8 @@ class IndexSettings(BaseModel):
default=True,
description=(
"Whether to sync the index with the paper directory when loading an index."
" Setting to True will add or delete index files to match the source paper directory."
" Setting to True will add or delete index files to match the source paper"
" directory."
),
)

Expand Down Expand Up @@ -537,11 +538,9 @@ def _deprecated_field(self) -> Self:
value = getattr(self, deprecated_field_name)
if value != type(self).model_fields[deprecated_field_name].default:
warnings.warn(
(
f"The {deprecated_field_name!r} field has been moved to"
f" {AgentSettings.__name__},"
" this deprecation will conclude in version 6."
),
f"The {deprecated_field_name!r} field has been moved to"
f" {AgentSettings.__name__},"
" this deprecation will conclude in version 6.",
category=DeprecationWarning,
stacklevel=2,
)
Expand Down Expand Up @@ -667,11 +666,9 @@ def _deprecated_field(self) -> Self:
value = getattr(self, deprecated_field_name)
if value != type(self).model_fields[deprecated_field_name].default:
warnings.warn(
(
f"The {deprecated_field_name!r} field has been moved to"
f" {AgentSettings.__name__},"
" this deprecation will conclude in version 6."
),
f"The {deprecated_field_name!r} field has been moved to"
f" {AgentSettings.__name__},"
" this deprecation will conclude in version 6.",
category=DeprecationWarning,
stacklevel=2,
)
Expand Down
10 changes: 6 additions & 4 deletions paperqa/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,10 @@ class DocDetails(Doc):
file_location: str | os.PathLike | None = None
license: str | None = Field(
default=None,
description="string indicating license."
" Should refer specifically to pdf_url (since that could be preprint). None means unknown/unset.",
description=(
"string indicating license. Should refer specifically to pdf_url (since"
" that could be preprint). None means unknown/unset."
),
)
pdf_url: str | None = None
other: dict[str, Any] = Field(
Expand Down Expand Up @@ -612,8 +614,8 @@ def formatted_citation(self) -> str:

if self.source_quality_message:
return (
f"{self.citation} This article has {self.citation_count} citations and is"
f" from a {self.source_quality_message}."
f"{self.citation} This article has {self.citation_count} citations and"
f" is from a {self.source_quality_message}."
)
return f"{self.citation} This article has {self.citation_count} citations."

Expand Down
5 changes: 4 additions & 1 deletion tests/test_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,10 @@ async def test_get_directory_index_w_manifest(agent_test_settings: Settings) ->
absolute_index = await get_directory_index(settings=absolute_test_settings)
assert set((await absolute_index.index_files).keys()) == {
str(abs_paper_dir / f) for f in EXPECTED_STUB_DATA_FILES
}, "Incorrect index files, should be absolute to deny sharing indexes across machines"
}, (
"Incorrect index files, should be absolute to deny sharing indexes across"
" machines"
)
for index in (relative_index, absolute_index):
assert index.fields == [
"file_location",
Expand Down
5 changes: 4 additions & 1 deletion tests/test_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,10 @@ async def test_crossref_retraction_status(stub_data_dir: Path) -> None:
),
)
crossref_details = await crossref_client.query(
title="The Dilemma and Countermeasures of Music Education under the Background of Big Data",
title=(
"The Dilemma and Countermeasures of Music Education under the"
" Background of Big Data"
),
fields=["title", "doi", "authors", "journal"],
)
assert crossref_details
Expand Down

0 comments on commit 6c7bf74

Please sign in to comment.