From fad17c50c7728fcec7d3f792ca74705ef9308ff5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 15:59:54 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- packages/jupyter-ai/jupyter_ai/extension.py | 2 +- .../jupyter_ai/tests/test_config_manager.py | 39 ++++++++++++------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/packages/jupyter-ai/jupyter_ai/extension.py b/packages/jupyter-ai/jupyter_ai/extension.py index 8292ea88c..0ff6bc224 100644 --- a/packages/jupyter-ai/jupyter_ai/extension.py +++ b/packages/jupyter-ai/jupyter_ai/extension.py @@ -4,7 +4,7 @@ from jupyter_ai.chat_handlers.learn import Retriever from jupyter_ai_magics.utils import get_em_providers, get_lm_providers from jupyter_server.extension.application import ExtensionApp -from traitlets import List, Unicode, Dict +from traitlets import Dict, List, Unicode from .chat_handlers import ( AskChatHandler, diff --git a/packages/jupyter-ai/jupyter_ai/tests/test_config_manager.py b/packages/jupyter-ai/jupyter_ai/tests/test_config_manager.py index 183dc39b0..849fe6a26 100644 --- a/packages/jupyter-ai/jupyter_ai/tests/test_config_manager.py +++ b/packages/jupyter-ai/jupyter_ai/tests/test_config_manager.py @@ -42,7 +42,7 @@ def common_cm_kwargs(config_path, schema_path): "embeddings_provider_id": None, "api_keys": None, "fields": None, - } + }, } @@ -63,8 +63,13 @@ def cm_kargs_with_defaults(config_path, schema_path): "model_provider_id": "bedrock-chat:anthropic.claude-v1", "embeddings_provider_id": "bedrock:amazon.titan-embed-text-v1", "api_keys": {"OPENAI_API_KEY": "open-ai-key-value"}, - "fields": {"bedrock-chat:anthropic.claude-v1":{"credentials_profile_name": "default","region_name": "us-west-2"}}, - } + "fields": { + "bedrock-chat:anthropic.claude-v1": { + "credentials_profile_name": "default", + "region_name": "us-west-2", + } + }, + }, } @@ -148,11 +153,12 @@ def test_init_with_existing_config( config_path=config_path, schema_path=schema_path, restrictions={"allowed_providers": None, "blocked_providers": None}, - provider_defaults=None + provider_defaults=None, ) + def test_init_with_default_values( - cm_with_defaults: ConfigManager, config_path: str, schema_path: str + cm_with_defaults: ConfigManager, config_path: str, schema_path: str ): """ Test that the ConfigManager initializes with the expected default values. @@ -163,18 +169,25 @@ def test_init_with_default_values( schema_path (str): The path to the schema file. """ config_response = cm_with_defaults.get_config() - #assert config response + # assert config response assert config_response.model_provider_id == "bedrock-chat:anthropic.claude-v1" - assert config_response.embeddings_provider_id == "bedrock:amazon.titan-embed-text-v1" + assert ( + config_response.embeddings_provider_id == "bedrock:amazon.titan-embed-text-v1" + ) assert config_response.api_keys == ["OPENAI_API_KEY"] - assert config_response.fields == {"bedrock-chat:anthropic.claude-v1":{"credentials_profile_name": "default","region_name": "us-west-2"}} + assert config_response.fields == { + "bedrock-chat:anthropic.claude-v1": { + "credentials_profile_name": "default", + "region_name": "us-west-2", + } + } del cm_with_defaults log = logging.getLogger() lm_providers = get_lm_providers() em_providers = get_em_providers() - cm_with_defaults_override =ConfigManager( + cm_with_defaults_override = ConfigManager( log=log, lm_providers=lm_providers, em_providers=em_providers, @@ -184,10 +197,10 @@ def test_init_with_default_values( provider_defaults={"model_provider_id": "bedrock-chat:anthropic.claude-v2"}, ) - assert cm_with_defaults_override.get_config().model_provider_id == "bedrock-chat:anthropic.claude-v2" - - - + assert ( + cm_with_defaults_override.get_config().model_provider_id + == "bedrock-chat:anthropic.claude-v2" + ) def test_property_access_on_default_config(cm: ConfigManager):