Skip to content

Commit 3935266

Browse files
authored
Run pre-commit (#1423)
1 parent 497016d commit 3935266

File tree

10 files changed

+80
-80
lines changed

10 files changed

+80
-80
lines changed

packages/jupyter-ai-magics/jupyter_ai_magics/partner_providers/vertexai.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class VertexAIProvider(BaseProvider, VertexAI):
2020
"For more information, see the [Vertex AI authentication documentation](https://python.langchain.com/docs/integrations/llms/google_vertex_ai_palm/)."
2121
)
2222

23+
2324
class VertexAIEmbeddingsProvider(BaseProvider, VertexAIEmbeddings):
2425
id = "vertexai"
2526
name = "Vertex AI"
@@ -35,4 +36,4 @@ class VertexAIEmbeddingsProvider(BaseProvider, VertexAIEmbeddings):
3536
"- Store the path to a service account JSON file as the GOOGLE_APPLICATION_CREDENTIALS environment variable\n\n"
3637
"This codebase uses the google.auth library which first looks for the application credentials variable mentioned above, and then looks for system-level auth. "
3738
"For more information, see the [Vertex AI authentication documentation](https://python.langchain.com/docs/integrations/llms/google_vertex_ai_palm/)."
38-
)
39+
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .config_models import JaiConfig, UpdateConfigRequest, DescribeConfigResponse
1+
from .config_models import DescribeConfigResponse, JaiConfig, UpdateConfigRequest

packages/jupyter-ai/jupyter_ai/config/config_models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
from pydantic import BaseModel, field_validator
21
from typing import Any, Optional
32

3+
from pydantic import BaseModel, field_validator
4+
5+
46
class JaiConfig(BaseModel):
57
"""
68
Pydantic model that serializes and validates the Jupyter AI config.

packages/jupyter-ai/jupyter_ai/config_manager.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import logging
33
import os
44
import time
5+
from copy import deepcopy
56
from typing import Optional, Union
67

7-
from copy import deepcopy
88
from deepmerge import always_merger
99
from jupyter_ai_magics.utils import (
1010
AnyProvider,
@@ -13,11 +13,12 @@
1313
get_em_provider,
1414
get_lm_provider,
1515
)
16-
from .config import JaiConfig, DescribeConfigResponse, UpdateConfigRequest
1716
from jupyter_core.paths import jupyter_data_dir
1817
from traitlets import Integer, Unicode
1918
from traitlets.config import Configurable
2019

20+
from .config import DescribeConfigResponse, JaiConfig, UpdateConfigRequest
21+
2122
Logger = Union[logging.Logger, logging.LoggerAdapter]
2223

2324
# default path to config
@@ -26,6 +27,7 @@
2627
# default no. of spaces to use when formatting config
2728
DEFAULT_INDENTATION_DEPTH = 4
2829

30+
2931
class AuthError(Exception):
3032
pass
3133

@@ -62,7 +64,7 @@ def remove_none_entries(d: dict):
6264
Returns a deep copy of the given dictionary that excludes all top-level
6365
entries whose value is `None`.
6466
"""
65-
d = { k: deepcopy(d[k]) for k in d if d[k] is not None }
67+
d = {k: deepcopy(d[k]) for k in d if d[k] is not None}
6668
return d
6769

6870

@@ -105,7 +107,6 @@ class ConfigManager(Configurable):
105107
`self._config`.
106108
"""
107109

108-
109110
def __init__(
110111
self,
111112
log: Logger,
@@ -161,10 +162,11 @@ def _init_config(self):
161162
# configuration on init.
162163
if self._defaults:
163164
existing_config_args = self._read_config().model_dump()
164-
merged_config_args = always_merger.merge(existing_config_args, self._defaults)
165+
merged_config_args = always_merger.merge(
166+
existing_config_args, self._defaults
167+
)
165168
merged_config = JaiConfig(**merged_config_args)
166169
self._write_config(merged_config)
167-
168170

169171
def _process_existing_config(self):
170172
"""

packages/jupyter-ai/jupyter_ai/handlers.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66
from tornado import web
77
from tornado.web import HTTPError
88

9+
from .config import UpdateConfigRequest
910
from .models import (
1011
ListProvidersEntry,
1112
ListProvidersResponse,
1213
)
13-
from .config import (
14-
UpdateConfigRequest
15-
)
1614

1715
if TYPE_CHECKING:
1816
from jupyter_ai_magics.embedding_providers import BaseEmbeddingsProvider

packages/jupyter-ai/jupyter_ai/models.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,3 @@ class IndexedDir(BaseModel):
3636

3737
class IndexMetadata(BaseModel):
3838
dirs: list[IndexedDir]
39-

packages/jupyter-ai/jupyter_ai/personas/base_persona.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ def process_attachments(self, message: Message) -> Optional[str]:
352352
"""
353353
Process file attachments in the message and return their content as a string.
354354
"""
355-
355+
356356
if not message.attachments:
357357
return None
358358

@@ -363,22 +363,22 @@ def process_attachments(self, message: Message) -> Optional[str]:
363363
try:
364364
# Try to resolve attachment using multiple strategies
365365
file_path = self.resolve_attachment_to_path(attachment_id)
366-
366+
367367
if not file_path:
368-
self.log.warning(f"Could not resolve attachment ID: {attachment_id}")
368+
self.log.warning(
369+
f"Could not resolve attachment ID: {attachment_id}"
370+
)
369371
continue
370-
372+
371373
# Read the file content
372-
with open(file_path, "r", encoding="utf-8") as f:
374+
with open(file_path, encoding="utf-8") as f:
373375
file_content = f.read()
374-
376+
375377
# Get relative path for display
376378
rel_path = os.path.relpath(file_path, self.get_workspace_dir())
377-
379+
378380
# Add file content with header
379-
context_parts.append(
380-
f"File: {rel_path}\n```\n{file_content}\n```"
381-
)
381+
context_parts.append(f"File: {rel_path}\n```\n{file_content}\n```")
382382

383383
except Exception as e:
384384
self.log.warning(f"Failed to read attachment {attachment_id}: {e}")
@@ -393,34 +393,34 @@ def resolve_attachment_to_path(self, attachment_id: str) -> Optional[str]:
393393
"""
394394
Resolve an attachment ID to its file path using multiple strategies.
395395
"""
396-
396+
397397
try:
398398
attachment_data = self.ychat.get_attachments().get(attachment_id)
399-
399+
400400
if attachment_data and isinstance(attachment_data, dict):
401401
# If attachment has a 'value' field with filename
402-
if 'value' in attachment_data:
403-
filename = attachment_data['value']
404-
402+
if "value" in attachment_data:
403+
filename = attachment_data["value"]
404+
405405
# Try relative to workspace directory
406406
workspace_path = os.path.join(self.get_workspace_dir(), filename)
407407
if os.path.exists(workspace_path):
408408
return workspace_path
409-
409+
410410
# Try as absolute path
411411
if os.path.exists(filename):
412412
return filename
413-
413+
414414
return None
415-
415+
416416
except Exception as e:
417417
self.log.error(f"Failed to resolve attachment {attachment_id}: {e}")
418418
return None
419-
419+
420420
def shutdown(self) -> None:
421421
"""
422422
Shuts the persona down. This method should:
423-
423+
424424
- Halt all background tasks started by this instance.
425425
- Remove the persona from the chat awareness
426426

packages/jupyter-ai/jupyter_ai/personas/jupyternaut/jupyternaut.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,3 @@ def build_runnable(self) -> Any:
6464
)
6565

6666
return runnable
67-

0 commit comments

Comments
 (0)