diff --git a/paperqa/agents/main.py b/paperqa/agents/main.py index f193b406..18ef6763 100644 --- a/paperqa/agents/main.py +++ b/paperqa/agents/main.py @@ -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( diff --git a/paperqa/agents/search.py b/paperqa/agents/search.py index d5089acb..7187c5fb 100644 --- a/paperqa/agents/search.py +++ b/paperqa/agents/search.py @@ -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( @@ -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, ) @@ -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, ) @@ -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: diff --git a/paperqa/llms.py b/paperqa/llms.py index bc6fe5d9..ac2092f5 100644 --- a/paperqa/llms.py +++ b/paperqa/llms.py @@ -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) diff --git a/paperqa/rate_limiter.py b/paperqa/rate_limiter.py index 8ad48502..58ec103e 100644 --- a/paperqa/rate_limiter.py +++ b/paperqa/rate_limiter.py @@ -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 diff --git a/paperqa/settings.py b/paperqa/settings.py index 3d822b16..4dd30857 100644 --- a/paperqa/settings.py +++ b/paperqa/settings.py @@ -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, ) @@ -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") @@ -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." ), ) @@ -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, ) @@ -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, ) diff --git a/paperqa/types.py b/paperqa/types.py index 4f963db6..9d897a71 100644 --- a/paperqa/types.py +++ b/paperqa/types.py @@ -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( @@ -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." diff --git a/tests/test_agents.py b/tests/test_agents.py index 9b295b05..ed693f88 100644 --- a/tests/test_agents.py +++ b/tests/test_agents.py @@ -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", diff --git a/tests/test_clients.py b/tests/test_clients.py index c71f91d4..3c4d990c 100644 --- a/tests/test_clients.py +++ b/tests/test_clients.py @@ -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