Skip to content

Commit 1c61574

Browse files
author
Richard Kuo (Onyx)
committed
reformatted again
1 parent 6968f0b commit 1c61574

File tree

28 files changed

+112
-123
lines changed

28 files changed

+112
-123
lines changed

Diff for: .pre-commit-config.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
repos:
22
- repo: https://github.com/psf/black
3-
rev: 23.3.0
3+
rev: 25.1.0
44
hooks:
55
- id: black
66
language_version: python3.11
77

88
- repo: https://github.com/asottile/reorder_python_imports
9-
rev: v3.9.0
9+
rev: v3.14.0
1010
hooks:
1111
- id: reorder-python-imports
1212
args: ['--py311-plus', '--application-directories=backend/']
@@ -18,14 +18,14 @@ repos:
1818
# These settings will remove unused imports with side effects
1919
# Note: The repo currently does not and should not have imports with side effects
2020
- repo: https://github.com/PyCQA/autoflake
21-
rev: v2.2.0
21+
rev: v2.3.1
2222
hooks:
2323
- id: autoflake
2424
args: [ '--remove-all-unused-imports', '--remove-unused-variables', '--in-place' , '--recursive']
2525

2626
- repo: https://github.com/astral-sh/ruff-pre-commit
2727
# Ruff version.
28-
rev: v0.0.286
28+
rev: v0.11.4
2929
hooks:
3030
- id: ruff
3131
- repo: https://github.com/pre-commit/mirrors-prettier

Diff for: backend/ee/onyx/server/oauth/google_drive.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ def handle_google_drive_oauth_callback(
195195
credential_dict: dict[str, str] = {}
196196
credential_dict[DB_CREDENTIALS_DICT_TOKEN_KEY] = oauth_creds_sanitized_json_str
197197
credential_dict[DB_CREDENTIALS_PRIMARY_ADMIN_KEY] = session.email
198-
credential_dict[
199-
DB_CREDENTIALS_AUTHENTICATION_METHOD
200-
] = GoogleOAuthAuthenticationMethod.OAUTH_INTERACTIVE.value
198+
credential_dict[DB_CREDENTIALS_AUTHENTICATION_METHOD] = (
199+
GoogleOAuthAuthenticationMethod.OAUTH_INTERACTIVE.value
200+
)
201201

202202
credential_info = CredentialBase(
203203
credential_json=credential_dict,

Diff for: backend/onyx/agents/agent_search/deep_search/main/nodes/generate_validate_refined_answer.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,7 @@ def generate_validate_refined_answer(
244244
revision_question_efficiency = (
245245
len(total_answered_questions) / len(initial_answered_sub_questions)
246246
if initial_answered_sub_questions
247-
else 10.0
248-
if refined_answered_sub_questions
249-
else 1.0
247+
else 10.0 if refined_answered_sub_questions else 1.0
250248
)
251249

252250
sub_question_answer_str = "\n\n------\n\n".join(

Diff for: backend/onyx/agents/agent_search/deep_search/main/states.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ class SubQuestionResultsUpdate(LoggerUpdate):
112112
list[InferenceSection], dedup_inference_sections
113113
] = []
114114
context_documents: Annotated[list[InferenceSection], dedup_inference_sections] = []
115-
cited_documents: Annotated[
116-
list[InferenceSection], dedup_inference_sections
117-
] = [] # cited docs from sub-answers are used for answer context
115+
cited_documents: Annotated[list[InferenceSection], dedup_inference_sections] = (
116+
[]
117+
) # cited docs from sub-answers are used for answer context
118118
sub_question_results: Annotated[
119119
list[SubQuestionAnswerResults], dedup_question_answer_results
120120
] = []

Diff for: backend/onyx/agents/agent_search/deep_search/shared/expanded_retrieval/states.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ class DocVerificationUpdate(LoggerUpdate, BaseModel):
4444

4545
class DocRetrievalUpdate(LoggerUpdate, BaseModel):
4646
query_retrieval_results: Annotated[list[QueryRetrievalResult], add] = []
47-
retrieved_documents: Annotated[
48-
list[InferenceSection], dedup_inference_sections
49-
] = []
47+
retrieved_documents: Annotated[list[InferenceSection], dedup_inference_sections] = (
48+
[]
49+
)
5050

5151

5252
class DocRerankingUpdate(LoggerUpdate, BaseModel):
@@ -64,9 +64,9 @@ class ExpandedRetrievalUpdate(LoggerUpdate, BaseModel):
6464
class ExpandedRetrievalOutput(LoggerUpdate, BaseModel):
6565
expanded_retrieval_result: QuestionRetrievalResult = QuestionRetrievalResult()
6666
base_expanded_retrieval_result: QuestionRetrievalResult = QuestionRetrievalResult()
67-
retrieved_documents: Annotated[
68-
list[InferenceSection], dedup_inference_sections
69-
] = []
67+
retrieved_documents: Annotated[list[InferenceSection], dedup_inference_sections] = (
68+
[]
69+
)
7070

7171

7272
## Graph State

Diff for: backend/onyx/agents/agent_search/shared_graph_utils/operators.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ def dedup_question_answer_results(
2323
question_answer_results_1: list[SubQuestionAnswerResults],
2424
question_answer_results_2: list[SubQuestionAnswerResults],
2525
) -> list[SubQuestionAnswerResults]:
26-
deduped_question_answer_results: list[
27-
SubQuestionAnswerResults
28-
] = question_answer_results_1
26+
deduped_question_answer_results: list[SubQuestionAnswerResults] = (
27+
question_answer_results_1
28+
)
2929
utilized_question_ids: set[str] = set(
3030
[x.question_id for x in question_answer_results_1]
3131
)

Diff for: backend/onyx/background/indexing/run_indexing.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,9 @@ def _run_indexing(
423423
unresolved_only=True,
424424
db_session=db_session_temp,
425425
)
426-
doc_id_to_unresolved_errors: dict[
427-
str, list[IndexAttemptError]
428-
] = defaultdict(list)
426+
doc_id_to_unresolved_errors: dict[str, list[IndexAttemptError]] = (
427+
defaultdict(list)
428+
)
429429
for error in unresolved_errors:
430430
if error.document_id:
431431
doc_id_to_unresolved_errors[error.document_id].append(error)

Diff for: backend/onyx/chat/answer.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ def citations(self) -> list[CitationInfo]:
212212
return citations
213213

214214
def citations_by_subquestion(self) -> dict[SubQuestionKey, list[CitationInfo]]:
215-
citations_by_subquestion: dict[
216-
SubQuestionKey, list[CitationInfo]
217-
] = defaultdict(list)
215+
citations_by_subquestion: dict[SubQuestionKey, list[CitationInfo]] = (
216+
defaultdict(list)
217+
)
218218
basic_subq_key = SubQuestionKey(level=BASIC_KEY[0], question_num=BASIC_KEY[1])
219219
for packet in self.processed_streamed_output:
220220
if isinstance(packet, CitationInfo):

Diff for: backend/onyx/chat/process_message.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@ def _translate_citations(
172172
citation_to_saved_doc_id_map: dict[int, int] = {}
173173
for citation in citations_list:
174174
if citation.citation_num not in citation_to_saved_doc_id_map:
175-
citation_to_saved_doc_id_map[
176-
citation.citation_num
177-
] = doc_id_to_saved_doc_id_map[citation.document_id]
175+
citation_to_saved_doc_id_map[citation.citation_num] = (
176+
doc_id_to_saved_doc_id_map[citation.document_id]
177+
)
178178

179179
return MessageSpecificCitations(citation_map=citation_to_saved_doc_id_map)
180180

Diff for: backend/onyx/connectors/confluence/onyx_confluence.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -397,9 +397,9 @@ def __getattr__(self, name: str) -> Any:
397397
return attr
398398

399399
# wrap the method with our retry handler
400-
rate_limited_method: Callable[
401-
..., Any
402-
] = self._make_rate_limited_confluence_method(name, self._credentials_provider)
400+
rate_limited_method: Callable[..., Any] = (
401+
self._make_rate_limited_confluence_method(name, self._credentials_provider)
402+
)
403403

404404
def wrapped_method(*args: Any, **kwargs: Any) -> Any:
405405
return rate_limited_method(*args, **kwargs)

Diff for: backend/onyx/connectors/connector_runner.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ def __init__(
8888

8989
self.doc_batch: list[Document] = []
9090

91-
def run(
92-
self, checkpoint: CT
93-
) -> Generator[
91+
def run(self, checkpoint: CT) -> Generator[
9492
tuple[list[Document] | None, ConnectorFailure | None, CT | None],
9593
None,
9694
None,

Diff for: backend/onyx/connectors/egnyte/connector.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ def _process_egnyte_file(
100100

101101
# Add lock info if present
102102
if lock_info := file_metadata.get("lock_info"):
103-
metadata[
104-
"lock_owner"
105-
] = f"{lock_info.get('first_name', '')} {lock_info.get('last_name', '')}"
103+
metadata["lock_owner"] = (
104+
f"{lock_info.get('first_name', '')} {lock_info.get('last_name', '')}"
105+
)
106106

107107
# Create the document owners
108108
primary_owner = None

Diff for: backend/onyx/connectors/gong/connector.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,9 @@ def _fetch_calls(
280280
speaker_id = segment.get("speakerId", "")
281281
if speaker_id not in speaker_to_name:
282282
if self.hide_user_info:
283-
speaker_to_name[
284-
speaker_id
285-
] = f"User {len(speaker_to_name) + 1}"
283+
speaker_to_name[speaker_id] = (
284+
f"User {len(speaker_to_name) + 1}"
285+
)
286286
else:
287287
speaker_to_name[speaker_id] = id_to_name_map.get(
288288
speaker_id, "Unknown"

Diff for: backend/onyx/connectors/google_drive/connector.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ def __call__(
141141
checkpoint: GoogleDriveCheckpoint,
142142
start: SecondsSinceUnixEpoch | None = None,
143143
end: SecondsSinceUnixEpoch | None = None,
144-
) -> Iterator[RetrievedDriveFile]:
145-
...
144+
) -> Iterator[RetrievedDriveFile]: ...
146145

147146

148147
def add_retrieval_info(

Diff for: backend/onyx/connectors/google_utils/google_kv.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ def build_service_account_creds(
147147
if primary_admin_email:
148148
credential_dict[DB_CREDENTIALS_PRIMARY_ADMIN_KEY] = primary_admin_email
149149

150-
credential_dict[
151-
DB_CREDENTIALS_AUTHENTICATION_METHOD
152-
] = GoogleOAuthAuthenticationMethod.UPLOADED.value
150+
credential_dict[DB_CREDENTIALS_AUTHENTICATION_METHOD] = (
151+
GoogleOAuthAuthenticationMethod.UPLOADED.value
152+
)
153153

154154
return CredentialBase(
155155
credential_json=credential_dict,

Diff for: backend/onyx/connectors/notion/connector.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -576,9 +576,9 @@ def _recursive_load(self) -> Generator[list[Document], None, None]:
576576

577577
def load_credentials(self, credentials: dict[str, Any]) -> dict[str, Any] | None:
578578
"""Applies integration token to headers"""
579-
self.headers[
580-
"Authorization"
581-
] = f'Bearer {credentials["notion_integration_token"]}'
579+
self.headers["Authorization"] = (
580+
f'Bearer {credentials["notion_integration_token"]}'
581+
)
582582
return None
583583

584584
def load_from_state(self) -> GenerateDocumentsOutput:

Diff for: backend/onyx/db/auth.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
def get_default_admin_user_emails() -> list[str]:
3030
"""Returns a list of emails who should default to Admin role.
3131
Only used in the EE version. For MIT, just return empty list."""
32-
get_default_admin_user_emails_fn: Callable[
33-
[], list[str]
34-
] = fetch_versioned_implementation_with_fallback(
35-
"onyx.auth.users", "get_default_admin_user_emails_", lambda: list[str]()
32+
get_default_admin_user_emails_fn: Callable[[], list[str]] = (
33+
fetch_versioned_implementation_with_fallback(
34+
"onyx.auth.users", "get_default_admin_user_emails_", lambda: list[str]()
35+
)
3636
)
3737
return get_default_admin_user_emails_fn()
3838

Diff for: backend/onyx/db/models.py

+17-17
Original file line numberDiff line numberDiff line change
@@ -702,12 +702,12 @@ class Connector(Base):
702702
back_populates="connector",
703703
cascade="all, delete-orphan",
704704
)
705-
documents_by_connector: Mapped[
706-
list["DocumentByConnectorCredentialPair"]
707-
] = relationship(
708-
"DocumentByConnectorCredentialPair",
709-
back_populates="connector",
710-
passive_deletes=True,
705+
documents_by_connector: Mapped[list["DocumentByConnectorCredentialPair"]] = (
706+
relationship(
707+
"DocumentByConnectorCredentialPair",
708+
back_populates="connector",
709+
passive_deletes=True,
710+
)
711711
)
712712

713713
# synchronize this validation logic with RefreshFrequencySchema etc on front end
@@ -760,12 +760,12 @@ class Credential(Base):
760760
back_populates="credential",
761761
cascade="all, delete-orphan",
762762
)
763-
documents_by_credential: Mapped[
764-
list["DocumentByConnectorCredentialPair"]
765-
] = relationship(
766-
"DocumentByConnectorCredentialPair",
767-
back_populates="credential",
768-
passive_deletes=True,
763+
documents_by_credential: Mapped[list["DocumentByConnectorCredentialPair"]] = (
764+
relationship(
765+
"DocumentByConnectorCredentialPair",
766+
back_populates="credential",
767+
passive_deletes=True,
768+
)
769769
)
770770

771771
user: Mapped[User | None] = relationship("User", back_populates="credentials")
@@ -2194,11 +2194,11 @@ class UserGroup(Base):
21942194
secondary=UserGroup__ConnectorCredentialPair.__table__,
21952195
viewonly=True,
21962196
)
2197-
cc_pair_relationships: Mapped[
2198-
list[UserGroup__ConnectorCredentialPair]
2199-
] = relationship(
2200-
"UserGroup__ConnectorCredentialPair",
2201-
viewonly=True,
2197+
cc_pair_relationships: Mapped[list[UserGroup__ConnectorCredentialPair]] = (
2198+
relationship(
2199+
"UserGroup__ConnectorCredentialPair",
2200+
viewonly=True,
2201+
)
22022202
)
22032203
personas: Mapped[list[Persona]] = relationship(
22042204
"Persona",

Diff for: backend/onyx/document_index/vespa/index.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ def __init__(
177177
self.index_to_large_chunks_enabled: dict[str, bool] = {}
178178
self.index_to_large_chunks_enabled[index_name] = large_chunks_enabled
179179
if secondary_index_name and secondary_large_chunks_enabled:
180-
self.index_to_large_chunks_enabled[
181-
secondary_index_name
182-
] = secondary_large_chunks_enabled
180+
self.index_to_large_chunks_enabled[secondary_index_name] = (
181+
secondary_large_chunks_enabled
182+
)
183183

184184
def ensure_indices_exist(
185185
self,
@@ -389,9 +389,9 @@ def index(
389389
new_document_id_to_original_document_id: dict[str, str] = {}
390390
for ind, chunk in enumerate(cleaned_chunks):
391391
old_chunk = chunks[ind]
392-
new_document_id_to_original_document_id[
393-
chunk.source_document.id
394-
] = old_chunk.source_document.id
392+
new_document_id_to_original_document_id[chunk.source_document.id] = (
393+
old_chunk.source_document.id
394+
)
395395

396396
existing_docs: set[str] = set()
397397

Diff for: backend/onyx/indexing/indexing_pipeline.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ def __call__(
122122
self,
123123
document_batch: list[Document],
124124
index_attempt_metadata: IndexAttemptMetadata,
125-
) -> IndexingPipelineResult:
126-
...
125+
) -> IndexingPipelineResult: ...
127126

128127

129128
def _upsert_documents_in_db(
@@ -835,10 +834,10 @@ def index_doc_batch(
835834
doc_id_to_user_file_id: dict[str, int | None] = fetch_user_files_for_documents(
836835
document_ids=updatable_ids, db_session=db_session
837836
)
838-
doc_id_to_user_folder_id: dict[
839-
str, int | None
840-
] = fetch_user_folders_for_documents(
841-
document_ids=updatable_ids, db_session=db_session
837+
doc_id_to_user_folder_id: dict[str, int | None] = (
838+
fetch_user_folders_for_documents(
839+
document_ids=updatable_ids, db_session=db_session
840+
)
842841
)
843842

844843
doc_id_to_previous_chunk_cnt: dict[str, int | None] = {

Diff for: backend/onyx/server/features/persona/api.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,9 @@ def delete_persona(
381381

382382
@basic_router.get("/image-generation-tool")
383383
def get_image_generation_tool(
384-
_: User
385-
| None = Depends(current_user), # User param not used but kept for consistency
384+
_: User | None = Depends(
385+
current_user
386+
), # User param not used but kept for consistency
386387
db_session: Session = Depends(get_session),
387388
) -> ImageGenerationToolStatus: # Use bool instead of str for boolean values
388389
is_available = is_image_generation_available(db_session=db_session)

Diff for: backend/onyx/server/manage/llm/api.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,9 @@ def set_provider_as_default(
237237
@admin_router.post("/provider/{provider_id}/default-vision")
238238
def set_provider_as_default_vision(
239239
provider_id: int,
240-
vision_model: str
241-
| None = Query(None, description="The default vision model to use"),
240+
vision_model: str | None = Query(
241+
None, description="The default vision model to use"
242+
),
242243
_: User | None = Depends(current_admin_user),
243244
db_session: Session = Depends(get_session),
244245
) -> None:

Diff for: backend/onyx/server/manage/slack_bot.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ def _form_channel_config(
9696
if follow_up_tags is not None:
9797
channel_config["follow_up_tags"] = follow_up_tags
9898

99-
channel_config[
100-
"show_continue_in_web_ui"
101-
] = slack_channel_config_creation_request.show_continue_in_web_ui
99+
channel_config["show_continue_in_web_ui"] = (
100+
slack_channel_config_creation_request.show_continue_in_web_ui
101+
)
102102

103-
channel_config[
104-
"respond_to_bots"
105-
] = slack_channel_config_creation_request.respond_to_bots
103+
channel_config["respond_to_bots"] = (
104+
slack_channel_config_creation_request.respond_to_bots
105+
)
106106

107107
channel_config["is_ephemeral"] = slack_channel_config_creation_request.is_ephemeral
108108

0 commit comments

Comments
 (0)