From 50186da0a1fa0d15a3aaf907fc52d89a893d8a60 Mon Sep 17 00:00:00 2001 From: Bagatur <22008038+baskaryan@users.noreply.github.com> Date: Wed, 22 May 2024 15:21:08 -0700 Subject: [PATCH] infra: rm unused # noqa violations (#22049) Updating #21137 --- .github/scripts/check_diff.py | 2 +- .github/scripts/get_min_versions.py | 2 +- .github/workflows/extract_ignored_words_list.py | 2 +- cookbook/rag_with_quantized_embeddings.ipynb | 4 +--- docs/api_reference/create_api_rst.py | 2 +- docs/docs/how_to/graph_mapping.ipynb | 4 ++-- docs/docs/how_to/sql_csv.ipynb | 2 +- docs/docs/how_to/sql_large_db.ipynb | 2 +- docs/docs/integrations/chat/anthropic.ipynb | 2 +- docs/docs/integrations/chat_loaders/discord.ipynb | 4 ++-- docs/docs/integrations/chat_loaders/wechat.ipynb | 2 +- .../example_data/source_code/example.py | 2 +- docs/scripts/arxiv_references.py | 2 +- docs/scripts/generate_api_reference_links.py | 2 +- docs/scripts/model_feat_table.py | 4 ++-- .../tests/unit_tests/migrate/test_replace_imports.py | 2 +- .../community/langchain_community/callbacks/manager.py | 2 +- .../langchain_community/chat_loaders/langsmith.py | 2 +- .../chat_message_histories/cosmos_db.py | 6 +++--- .../langchain_community/chat_models/azure_openai.py | 2 +- .../chat_models/azureml_endpoint.py | 2 +- .../langchain_community/document_loaders/__init__.py | 6 +++--- .../langchain_community/document_loaders/blackboard.py | 2 +- .../langchain_community/document_loaders/evernote.py | 2 +- .../langchain_community/document_loaders/pebblo.py | 6 +++--- .../document_transformers/__init__.py | 2 +- .../document_transformers/openai_functions.py | 2 +- .../langchain_community/embeddings/__init__.py | 2 +- .../langchain_community/embeddings/azure_openai.py | 2 +- .../langchain_community/embeddings/elasticsearch.py | 2 +- .../langchain_community/embeddings/infinity.py | 2 +- .../langchain_community/embeddings/localai.py | 2 +- .../community/langchain_community/embeddings/openai.py | 2 +- .../community/langchain_community/embeddings/yandex.py | 4 ++-- .../langchain_community/graphs/arangodb_graph.py | 8 ++++---- .../langchain_community/llms/azureml_endpoint.py | 2 +- libs/community/langchain_community/llms/openai.py | 6 +++--- .../langchain_community/llms/symblai_nebula.py | 2 +- .../output_parsers/ernie_functions.py | 2 +- .../retrievers/google_vertex_ai_search.py | 2 +- .../community/langchain_community/tools/bearly/tool.py | 2 +- .../langchain_community/tools/powerbi/tool.py | 2 +- .../langchain_community/utilities/__init__.py | 2 +- libs/community/langchain_community/utilities/arxiv.py | 4 ++-- .../langchain_community/utilities/awslambda.py | 2 +- .../community/langchain_community/utilities/powerbi.py | 2 +- .../langchain_community/utilities/tavily_search.py | 2 +- libs/community/langchain_community/utilities/twilio.py | 4 ++-- .../langchain_community/vectorstores/__init__.py | 4 ++-- .../langchain_community/vectorstores/jaguar.py | 2 +- .../vectorstores/momento_vector_index.py | 2 +- .../langchain_community/vectorstores/qdrant.py | 4 ++-- .../langchain_community/vectorstores/redis/base.py | 8 ++++---- .../vectorstores/timescalevector.py | 2 +- .../document_loaders/test_tensorflow_datasets.py | 2 +- .../utilities/test_tensorflow_datasets.py | 2 +- .../vectorstores/qdrant/async_api/test_add_texts.py | 2 +- .../vectorstores/test_azure_cosmos_db.py | 2 +- .../integration_tests/vectorstores/test_documentdb.py | 2 +- .../vectorstores/test_mongodb_atlas.py | 2 +- .../document_loaders/parsers/language/test_lua.py | 4 ++-- libs/community/tests/unit_tests/llms/test_llamafile.py | 2 +- libs/community/tests/unit_tests/test_cache.py | 2 +- .../tests/unit_tests/test_document_transformers.py | 2 +- libs/core/langchain_core/messages/ai.py | 2 +- libs/core/langchain_core/messages/human.py | 2 +- libs/core/langchain_core/messages/system.py | 2 +- .../langchain_core/output_parsers/openai_functions.py | 2 +- libs/core/langchain_core/outputs/chat_generation.py | 2 +- libs/core/langchain_core/prompts/chat.py | 2 +- libs/core/langchain_core/runnables/base.py | 2 +- libs/core/langchain_core/runnables/graph_ascii.py | 4 ++-- libs/core/langchain_core/runnables/history.py | 4 ++-- libs/core/langchain_core/tracers/context.py | 4 ++-- libs/core/langchain_core/utils/input.py | 2 +- libs/core/tests/unit_tests/runnables/test_utils.py | 2 +- libs/core/tests/unit_tests/test_messages.py | 2 +- libs/core/tests/unit_tests/test_tools.py | 8 ++++---- .../langchain_experimental/agents/__init__.py | 2 +- .../agents/agent_toolkits/pandas/base.py | 2 +- .../langchain_experimental/chat_models/llm_wrapper.py | 2 +- .../langchain_experimental/llm_bash/bash.py | 10 +++++----- .../langchain_experimental/pal_chain/__init__.py | 2 +- .../langchain_experimental/recommenders/__init__.py | 2 +- .../langchain_experimental/rl_chain/base.py | 2 +- .../unit_tests/chat_models/test_llm_wrapper_mixtral.py | 2 +- .../tests/unit_tests/python/test_python_2.py | 2 +- .../conversational_retrieval/openai_functions.py | 2 +- libs/langchain/langchain/callbacks/tracers/logging.py | 4 ++-- .../langchain/chains/openai_functions/openapi.py | 6 +++--- .../evaluation/agents/trajectory_eval_chain.py | 2 +- .../langchain/evaluation/criteria/eval_chain.py | 4 ++-- libs/langchain/langchain/evaluation/loading.py | 2 +- .../langchain/evaluation/scoring/eval_chain.py | 2 +- libs/langchain/langchain/smith/evaluation/config.py | 2 +- .../langchain/smith/evaluation/runner_utils.py | 2 +- .../tests/integration_tests/test_experimental.py | 2 +- .../tests/integration_tests/test_vectorstores.py | 2 +- .../mongodb/tests/unit_tests/test_vectorstores.py | 2 +- .../openai/langchain_openai/chat_models/azure.py | 4 ++-- .../openai/langchain_openai/embeddings/azure.py | 2 +- libs/partners/openai/langchain_openai/llms/azure.py | 2 +- libs/partners/qdrant/langchain_qdrant/vectorstores.py | 4 ++-- libs/partners/together/tests/unit_tests/test_llms.py | 4 ++-- templates/anthropic-iterative-search/main.py | 2 +- .../cassandra_entomology_rag/__init__.py | 2 +- templates/csv-agent/main.py | 2 +- templates/elastic-query-generator/main.py | 2 +- templates/neo4j-advanced-rag/main.py | 2 +- templates/neo4j-cypher-ft/main.py | 2 +- templates/neo4j-cypher-memory/main.py | 4 ++-- templates/neo4j-cypher/main.py | 2 +- templates/neo4j-generation/main.py | 2 +- templates/neo4j-parent/main.py | 2 +- templates/neo4j-semantic-layer/main.py | 4 ++-- .../neo4j_semantic_layer/memory_tool.py | 2 +- templates/neo4j-semantic-ollama/main.py | 4 ++-- .../neo4j_semantic_ollama/memory_tool.py | 2 +- templates/neo4j-vector-memory/main.py | 4 ++-- templates/nvidia-rag-canonical/ingest.py | 2 +- .../nvidia-rag-canonical/nvidia_rag_canonical/chain.py | 2 +- templates/openai-functions-agent-gmail/main.py | 2 +- templates/openai-functions-agent/main.py | 2 +- templates/plate-chain/plate_chain/prompts.py | 2 +- .../propositional_retrieval/ingest.py | 2 +- .../rag-astradb/astradb_entomology_rag/__init__.py | 2 +- templates/rag-astradb/main.py | 2 +- templates/rag-aws-bedrock/main.py | 2 +- templates/rag-aws-kendra/main.py | 2 +- .../rag-chroma-multi-modal-multi-vector/ingest.py | 6 +++--- templates/rag-chroma-multi-modal/ingest.py | 8 ++++---- templates/rag-elasticsearch/main.py | 4 ++-- templates/rag-fusion/main.py | 2 +- templates/rag-gemini-multi-modal/ingest.py | 8 ++++---- .../rag-google-cloud-sensitive-data-protection/main.py | 2 +- templates/rag-google-cloud-vertexai-search/main.py | 2 +- templates/rag-multi-modal-local/ingest.py | 4 ++-- templates/rag-multi-modal-mv-local/ingest.py | 6 +++--- templates/rag-opensearch/dummy_index_setup.py | 4 ++-- templates/rag-redis-multi-modal-multi-vector/ingest.py | 6 +++--- templates/rag-redis/ingest.py | 4 ++-- templates/rag-self-query/main.py | 4 ++-- .../rag_timescale_conversation/load_sample_dataset.py | 2 +- .../load_sample_dataset.py | 2 +- .../research_assistant/search/web.py | 2 +- templates/sql-llamacpp/sql_llamacpp/chain.py | 6 +++--- .../sql_research_assistant/chain.py | 2 +- .../sql_research_assistant/search/web.py | 2 +- templates/xml-agent/main.py | 2 +- 149 files changed, 212 insertions(+), 214 deletions(-) diff --git a/.github/scripts/check_diff.py b/.github/scripts/check_diff.py index 3489018d802dd..e5fe87843bca7 100644 --- a/.github/scripts/check_diff.py +++ b/.github/scripts/check_diff.py @@ -91,4 +91,4 @@ } for key, value in outputs.items(): json_output = json.dumps(value) - print(f"{key}={json_output}") # noqa: T201 + print(f"{key}={json_output}") diff --git a/.github/scripts/get_min_versions.py b/.github/scripts/get_min_versions.py index a26cc021db0ea..e942b4b52806e 100644 --- a/.github/scripts/get_min_versions.py +++ b/.github/scripts/get_min_versions.py @@ -76,4 +76,4 @@ def get_min_version_from_toml(toml_path: str): print( " ".join([f"{lib}=={version}" for lib, version in min_versions.items()]) - ) # noqa: T201 + ) diff --git a/.github/workflows/extract_ignored_words_list.py b/.github/workflows/extract_ignored_words_list.py index bb949d14f791f..7c800e0df0bce 100644 --- a/.github/workflows/extract_ignored_words_list.py +++ b/.github/workflows/extract_ignored_words_list.py @@ -7,4 +7,4 @@ pyproject_toml.get("tool", {}).get("codespell", {}).get("ignore-words-list") ) -print(f"::set-output name=ignore_words_list::{ignore_words_list}") # noqa: T201 +print(f"::set-output name=ignore_words_list::{ignore_words_list}") diff --git a/cookbook/rag_with_quantized_embeddings.ipynb b/cookbook/rag_with_quantized_embeddings.ipynb index 79a85d5cc50e1..a071ec21b1668 100644 --- a/cookbook/rag_with_quantized_embeddings.ipynb +++ b/cookbook/rag_with_quantized_embeddings.ipynb @@ -39,12 +39,10 @@ "from langchain_community.document_loaders.recursive_url_loader import (\n", " RecursiveUrlLoader,\n", ")\n", - "\n", - "# noqa\n", "from langchain_community.vectorstores import Chroma\n", "\n", "# For our example, we'll load docs from the web\n", - "from langchain_text_splitters import RecursiveCharacterTextSplitter # noqa\n", + "from langchain_text_splitters import RecursiveCharacterTextSplitter\n", "\n", "DOCSTORE_DIR = \".\"\n", "DOCSTORE_ID_KEY = \"doc_id\"" diff --git a/docs/api_reference/create_api_rst.py b/docs/api_reference/create_api_rst.py index a43aadf72d224..504d71a5b96d5 100644 --- a/docs/api_reference/create_api_rst.py +++ b/docs/api_reference/create_api_rst.py @@ -187,7 +187,7 @@ def _load_package_modules( modules_by_namespace[top_namespace] = _module_members except ImportError as e: - print(f"Error: Unable to import module '{namespace}' with error: {e}") # noqa: T201 + print(f"Error: Unable to import module '{namespace}' with error: {e}") return modules_by_namespace diff --git a/docs/docs/how_to/graph_mapping.ipynb b/docs/docs/how_to/graph_mapping.ipynb index 93c00134413a6..df3d08b8b86b6 100644 --- a/docs/docs/how_to/graph_mapping.ipynb +++ b/docs/docs/how_to/graph_mapping.ipynb @@ -300,7 +300,7 @@ "Entities in the question map to the following database values:\n", "{entities_list}\n", "Question: {question}\n", - "Cypher query:\"\"\" # noqa: E501\n", + "Cypher query:\"\"\"\n", "\n", "cypher_prompt = ChatPromptTemplate.from_messages(\n", " [\n", @@ -377,7 +377,7 @@ "response_template = \"\"\"Based on the the question, Cypher query, and Cypher response, write a natural language response:\n", "Question: {question}\n", "Cypher query: {query}\n", - "Cypher Response: {response}\"\"\" # noqa: E501\n", + "Cypher Response: {response}\"\"\"\n", "\n", "response_prompt = ChatPromptTemplate.from_messages(\n", " [\n", diff --git a/docs/docs/how_to/sql_csv.ipynb b/docs/docs/how_to/sql_csv.ipynb index 3e3ed1ce51e55..fc379c219db5f 100644 --- a/docs/docs/how_to/sql_csv.ipynb +++ b/docs/docs/how_to/sql_csv.ipynb @@ -503,7 +503,7 @@ } ], "source": [ - "chain = prompt | llm_with_tools | parser | tool # noqa\n", + "chain = prompt | llm_with_tools | parser | tool\n", "chain.invoke({\"question\": \"What's the correlation between age and fare\"})" ] }, diff --git a/docs/docs/how_to/sql_large_db.ipynb b/docs/docs/how_to/sql_large_db.ipynb index 6b98c1c5160c9..199c3c4f76572 100644 --- a/docs/docs/how_to/sql_large_db.ipynb +++ b/docs/docs/how_to/sql_large_db.ipynb @@ -262,7 +262,7 @@ " return tables\n", "\n", "\n", - "table_chain = category_chain | get_tables # noqa\n", + "table_chain = category_chain | get_tables\n", "table_chain.invoke({\"input\": \"What are all the genres of Alanis Morisette songs\"})" ] }, diff --git a/docs/docs/integrations/chat/anthropic.ipynb b/docs/docs/integrations/chat/anthropic.ipynb index 6ca0db0e5ab47..0120e7f0442a1 100644 --- a/docs/docs/integrations/chat/anthropic.ipynb +++ b/docs/docs/integrations/chat/anthropic.ipynb @@ -670,7 +670,7 @@ " \"type\": \"image_url\",\n", " \"image_url\": {\n", " # langchain logo\n", - " \"url\": f\"data:image/png;base64,{img_base64}\", # noqa: E501\n", + " \"url\": f\"data:image/png;base64,{img_base64}\",\n", " },\n", " },\n", " {\"type\": \"text\", \"text\": \"What is this logo for?\"},\n", diff --git a/docs/docs/integrations/chat_loaders/discord.ipynb b/docs/docs/integrations/chat_loaders/discord.ipynb index 515d8cf27f78a..6b4c2529e9f8e 100644 --- a/docs/docs/integrations/chat_loaders/discord.ipynb +++ b/docs/docs/integrations/chat_loaders/discord.ipynb @@ -95,7 +95,7 @@ " \"\"\"\n", " self.path = path\n", " self._message_line_regex = re.compile(\n", - " r\"(.+?) — (\\w{3,9} \\d{1,2}(?:st|nd|rd|th)?(?:, \\d{4})? \\d{1,2}:\\d{2} (?:AM|PM)|Today at \\d{1,2}:\\d{2} (?:AM|PM)|Yesterday at \\d{1,2}:\\d{2} (?:AM|PM))\", # noqa\n", + " r\"(.+?) — (\\w{3,9} \\d{1,2}(?:st|nd|rd|th)?(?:, \\d{4})? \\d{1,2}:\\d{2} (?:AM|PM)|Today at \\d{1,2}:\\d{2} (?:AM|PM)|Yesterday at \\d{1,2}:\\d{2} (?:AM|PM))\",\n", " flags=re.DOTALL,\n", " )\n", "\n", @@ -120,7 +120,7 @@ " current_content = []\n", " for line in lines:\n", " if re.match(\n", - " r\".+? — (\\d{2}/\\d{2}/\\d{4} \\d{1,2}:\\d{2} (?:AM|PM)|Today at \\d{1,2}:\\d{2} (?:AM|PM)|Yesterday at \\d{1,2}:\\d{2} (?:AM|PM))\", # noqa\n", + " r\".+? — (\\d{2}/\\d{2}/\\d{4} \\d{1,2}:\\d{2} (?:AM|PM)|Today at \\d{1,2}:\\d{2} (?:AM|PM)|Yesterday at \\d{1,2}:\\d{2} (?:AM|PM))\",\n", " line,\n", " ):\n", " if current_sender and current_content:\n", diff --git a/docs/docs/integrations/chat_loaders/wechat.ipynb b/docs/docs/integrations/chat_loaders/wechat.ipynb index b2602070ae599..40aee0e1ee24d 100644 --- a/docs/docs/integrations/chat_loaders/wechat.ipynb +++ b/docs/docs/integrations/chat_loaders/wechat.ipynb @@ -94,7 +94,7 @@ " \"\"\"\n", " self.path = path\n", " self._message_line_regex = re.compile(\n", - " r\"(?P.+?) (?P\\d{4}/\\d{2}/\\d{2} \\d{1,2}:\\d{2} (?:AM|PM))\", # noqa\n", + " r\"(?P.+?) (?P\\d{4}/\\d{2}/\\d{2} \\d{1,2}:\\d{2} (?:AM|PM))\",\n", " # flags=re.DOTALL,\n", " )\n", "\n", diff --git a/docs/docs/integrations/document_loaders/example_data/source_code/example.py b/docs/docs/integrations/document_loaders/example_data/source_code/example.py index 5838764ee4040..2a2760b6a60c3 100644 --- a/docs/docs/integrations/document_loaders/example_data/source_code/example.py +++ b/docs/docs/integrations/document_loaders/example_data/source_code/example.py @@ -3,7 +3,7 @@ def __init__(self, name): self.name = name def greet(self): - print(f"Hello, {self.name}!") # noqa: T201 + print(f"Hello, {self.name}!") def main(): diff --git a/docs/scripts/arxiv_references.py b/docs/scripts/arxiv_references.py index 76e22526c33bc..7657b788bfe1b 100644 --- a/docs/scripts/arxiv_references.py +++ b/docs/scripts/arxiv_references.py @@ -389,7 +389,7 @@ def get_papers( Returns: List of ArxivPaper objects. - """ # noqa: E501 + """ def cut_authors(authors: list) -> list[str]: if len(authors) > 3: diff --git a/docs/scripts/generate_api_reference_links.py b/docs/scripts/generate_api_reference_links.py index 31f4b22fa4910..9084b381f5a19 100644 --- a/docs/scripts/generate_api_reference_links.py +++ b/docs/scripts/generate_api_reference_links.py @@ -186,7 +186,7 @@ def replacer(match): data = code_block_re.sub(replacer, data) # if all_imports: - # print(f"Adding {len(all_imports)} links for imports in {file}") # noqa: T201 + # print(f"Adding {len(all_imports)} links for imports in {file}") with open(file, "w") as f: f.write(data) return all_imports diff --git a/docs/scripts/model_feat_table.py b/docs/scripts/model_feat_table.py index eb3ac8679afb2..725ff218009ce 100644 --- a/docs/scripts/model_feat_table.py +++ b/docs/scripts/model_feat_table.py @@ -116,7 +116,7 @@ {table} -""" # noqa: E501 +""" CHAT_MODEL_TEMPLATE = """\ --- @@ -133,7 +133,7 @@ {table} -""" # noqa: E501 +""" def get_llm_table(): diff --git a/libs/cli/tests/unit_tests/migrate/test_replace_imports.py b/libs/cli/tests/unit_tests/migrate/test_replace_imports.py index c75b1db74f782..627acb49f2def 100644 --- a/libs/cli/tests/unit_tests/migrate/test_replace_imports.py +++ b/libs/cli/tests/unit_tests/migrate/test_replace_imports.py @@ -17,7 +17,7 @@ "langchain_to_core", "community_to_core", ] -) # type: ignore[attr-defined] # noqa: E501 +) # type: ignore[attr-defined] class TestReplaceImportsCommand(CodemodTest): diff --git a/libs/community/langchain_community/callbacks/manager.py b/libs/community/langchain_community/callbacks/manager.py index f5b4530ea2955..ba942084953f6 100644 --- a/libs/community/langchain_community/callbacks/manager.py +++ b/libs/community/langchain_community/callbacks/manager.py @@ -28,7 +28,7 @@ wandb_tracing_callback_var: ContextVar[Optional[WandbTracer]] = ContextVar( "tracing_wandb_callback", default=None ) -comet_tracing_callback_var: ContextVar[Optional[CometTracer]] = ContextVar( # noqa: E501 +comet_tracing_callback_var: ContextVar[Optional[CometTracer]] = ContextVar( "tracing_comet_callback", default=None ) diff --git a/libs/community/langchain_community/chat_loaders/langsmith.py b/libs/community/langchain_community/chat_loaders/langsmith.py index 02a16d895e49f..7d099632c0b0c 100644 --- a/libs/community/langchain_community/chat_loaders/langsmith.py +++ b/libs/community/langchain_community/chat_loaders/langsmith.py @@ -143,7 +143,7 @@ def lazy_load(self) -> Iterator[ChatSession]: :return: Iterator of chat sessions containing messages. """ - from langchain_community.adapters import openai as oai_adapter # noqa: E402 + from langchain_community.adapters import openai as oai_adapter data = self.client.read_dataset_openai_finetuning( dataset_name=self.dataset_name diff --git a/libs/community/langchain_community/chat_message_histories/cosmos_db.py b/libs/community/langchain_community/chat_message_histories/cosmos_db.py index 4210d7a707623..87fc1e8be50fe 100644 --- a/libs/community/langchain_community/chat_message_histories/cosmos_db.py +++ b/libs/community/langchain_community/chat_message_histories/cosmos_db.py @@ -62,7 +62,7 @@ def __init__( self.messages: List[BaseMessage] = [] try: - from azure.cosmos import ( # pylint: disable=import-outside-toplevel # noqa: E501 + from azure.cosmos import ( # pylint: disable=import-outside-toplevel CosmosClient, ) except ImportError as exc: @@ -91,7 +91,7 @@ def prepare_cosmos(self) -> None: Use this function or the context manager to make sure your database is ready. """ try: - from azure.cosmos import ( # pylint: disable=import-outside-toplevel # noqa: E501 + from azure.cosmos import ( # pylint: disable=import-outside-toplevel PartitionKey, ) except ImportError as exc: @@ -128,7 +128,7 @@ def load_messages(self) -> None: if not self._container: raise ValueError("Container not initialized") try: - from azure.cosmos.exceptions import ( # pylint: disable=import-outside-toplevel # noqa: E501 + from azure.cosmos.exceptions import ( # pylint: disable=import-outside-toplevel CosmosHttpResponseError, ) except ImportError as exc: diff --git a/libs/community/langchain_community/chat_models/azure_openai.py b/libs/community/langchain_community/chat_models/azure_openai.py index 3834668c1f97e..3238cabe74600 100644 --- a/libs/community/langchain_community/chat_models/azure_openai.py +++ b/libs/community/langchain_community/chat_models/azure_openai.py @@ -85,7 +85,7 @@ class AzureChatOpenAI(ChatOpenAI): For more: https://www.microsoft.com/en-us/security/business/identity-access/microsoft-entra-id. - """ # noqa: E501 + """ azure_ad_token_provider: Union[Callable[[], str], None] = None """A function that returns an Azure Active Directory token. diff --git a/libs/community/langchain_community/chat_models/azureml_endpoint.py b/libs/community/langchain_community/chat_models/azureml_endpoint.py index 5f2a3f59c349b..2629c5a0ba258 100644 --- a/libs/community/langchain_community/chat_models/azureml_endpoint.py +++ b/libs/community/langchain_community/chat_models/azureml_endpoint.py @@ -233,7 +233,7 @@ class AzureMLChatOnlineEndpoint(BaseChatModel, AzureMLBaseEndpoint): endpoint_api_key="my-api-key", content_formatter=chat_content_formatter, ) - """ # noqa: E501 + """ @property def _identifying_params(self) -> Dict[str, Any]: diff --git a/libs/community/langchain_community/document_loaders/__init__.py b/libs/community/langchain_community/document_loaders/__init__.py index 1977498691df2..7f111b1aae925 100644 --- a/libs/community/langchain_community/document_loaders/__init__.py +++ b/libs/community/langchain_community/document_loaders/__init__.py @@ -214,7 +214,7 @@ GitHubIssuesLoader, ) from langchain_community.document_loaders.glue_catalog import ( - GlueCatalogLoader, # noqa: F401 + GlueCatalogLoader, ) from langchain_community.document_loaders.google_speech_to_text import ( GoogleSpeechToTextLoader, @@ -332,8 +332,8 @@ OracleAutonomousDatabaseLoader, ) from langchain_community.document_loaders.oracleai import ( - OracleDocLoader, # noqa: F401 - OracleTextSplitter, # noqa: F401 + OracleDocLoader, + OracleTextSplitter, ) from langchain_community.document_loaders.org_mode import ( UnstructuredOrgModeLoader, diff --git a/libs/community/langchain_community/document_loaders/blackboard.py b/libs/community/langchain_community/document_loaders/blackboard.py index 682eafb3cebc7..0141f2af9168b 100644 --- a/libs/community/langchain_community/document_loaders/blackboard.py +++ b/libs/community/langchain_community/document_loaders/blackboard.py @@ -31,7 +31,7 @@ class BlackboardLoader(WebBaseLoader): ) documents = loader.load() - """ # noqa: E501 + """ def __init__( self, diff --git a/libs/community/langchain_community/document_loaders/evernote.py b/libs/community/langchain_community/document_loaders/evernote.py index 07ade0ce5d8a5..296e4bcd7e764 100644 --- a/libs/community/langchain_community/document_loaders/evernote.py +++ b/libs/community/langchain_community/document_loaders/evernote.py @@ -34,7 +34,7 @@ class EverNoteLoader(BaseLoader): notes into a single long Document. If this is set to True (default) then the only metadata on the document will be the 'source' which contains the file name of the export. - """ # noqa: E501 + """ def __init__(self, file_path: Union[str, Path], load_single_document: bool = True): """Initialize with file path.""" diff --git a/libs/community/langchain_community/document_loaders/pebblo.py b/libs/community/langchain_community/document_loaders/pebblo.py index 4bc3aa1db5d1d..8a710a9a5b2c4 100644 --- a/libs/community/langchain_community/document_loaders/pebblo.py +++ b/libs/community/langchain_community/document_loaders/pebblo.py @@ -208,9 +208,9 @@ def _classify_doc(self, loaded_docs: list, loading_end: bool = False) -> list: if loading_end is True: payload["loading_end"] = "true" if "loader_details" in payload: - payload["loader_details"]["source_aggregate_size"] = ( # noqa - self.source_aggregate_size - ) + payload["loader_details"][ + "source_aggregate_size" + ] = self.source_aggregate_size payload = Doc(**payload).dict(exclude_unset=True) load_doc_url = f"{self.classifier_url}{LOADER_DOC_URL}" classified_docs = [] diff --git a/libs/community/langchain_community/document_transformers/__init__.py b/libs/community/langchain_community/document_transformers/__init__.py index 1fb3154d0c9c0..14aa448841e61 100644 --- a/libs/community/langchain_community/document_transformers/__init__.py +++ b/libs/community/langchain_community/document_transformers/__init__.py @@ -81,7 +81,7 @@ "GoogleTranslateTransformer": "langchain_community.document_transformers.google_translate", # noqa: E501 "Html2TextTransformer": "langchain_community.document_transformers.html2text", "LongContextReorder": "langchain_community.document_transformers.long_context_reorder", # noqa: E501 - "MarkdownifyTransformer": "langchain_community.document_transformers.markdownify", # noqa: E501 + "MarkdownifyTransformer": "langchain_community.document_transformers.markdownify", "NucliaTextTransformer": "langchain_community.document_transformers.nuclia_text_transform", # noqa: E501 "OpenAIMetadataTagger": "langchain_community.document_transformers.openai_functions", # noqa: E501 "get_stateful_documents": "langchain_community.document_transformers.embeddings_redundant_filter", # noqa: E501 diff --git a/libs/community/langchain_community/document_transformers/openai_functions.py b/libs/community/langchain_community/document_transformers/openai_functions.py index 5c9dec22e6167..ccad6ab1ec3ce 100644 --- a/libs/community/langchain_community/document_transformers/openai_functions.py +++ b/libs/community/langchain_community/document_transformers/openai_functions.py @@ -57,7 +57,7 @@ def transform_documents( new_documents = [] for document in documents: - extracted_metadata: Dict = self.tagging_chain.run(document.page_content) # type: ignore[assignment] # noqa: E501 + extracted_metadata: Dict = self.tagging_chain.run(document.page_content) # type: ignore[assignment] new_document = Document( page_content=document.page_content, metadata={**extracted_metadata, **document.metadata}, diff --git a/libs/community/langchain_community/embeddings/__init__.py b/libs/community/langchain_community/embeddings/__init__.py index b6e3f883613f5..5f72f232997ca 100644 --- a/libs/community/langchain_community/embeddings/__init__.py +++ b/libs/community/langchain_community/embeddings/__init__.py @@ -173,7 +173,7 @@ QuantizedBiEncoderEmbeddings, ) from langchain_community.embeddings.oracleai import ( - OracleEmbeddings, # noqa: F401 + OracleEmbeddings, ) from langchain_community.embeddings.premai import ( PremAIEmbeddings, diff --git a/libs/community/langchain_community/embeddings/azure_openai.py b/libs/community/langchain_community/embeddings/azure_openai.py index c8eb14ddac6c2..f8eeca2b2cd63 100644 --- a/libs/community/langchain_community/embeddings/azure_openai.py +++ b/libs/community/langchain_community/embeddings/azure_openai.py @@ -44,7 +44,7 @@ class AzureOpenAIEmbeddings(OpenAIEmbeddings): For more: https://www.microsoft.com/en-us/security/business/identity-access/microsoft-entra-id. - """ # noqa: E501 + """ azure_ad_token_provider: Union[Callable[[], str], None] = None """A function that returns an Azure Active Directory token. diff --git a/libs/community/langchain_community/embeddings/elasticsearch.py b/libs/community/langchain_community/embeddings/elasticsearch.py index 80596b6fd9207..ea080ab9aa989 100644 --- a/libs/community/langchain_community/embeddings/elasticsearch.py +++ b/libs/community/langchain_community/embeddings/elasticsearch.py @@ -25,7 +25,7 @@ class ElasticsearchEmbeddings(Embeddings): In Elasticsearch you need to have an embedding model loaded and deployed. - https://www.elastic.co/guide/en/elasticsearch/reference/current/infer-trained-model.html - https://www.elastic.co/guide/en/machine-learning/current/ml-nlp-deploy-models.html - """ # noqa: E501 + """ def __init__( self, diff --git a/libs/community/langchain_community/embeddings/infinity.py b/libs/community/langchain_community/embeddings/infinity.py index f5068e64f63ec..9af640baf6291 100644 --- a/libs/community/langchain_community/embeddings/infinity.py +++ b/libs/community/langchain_community/embeddings/infinity.py @@ -182,7 +182,7 @@ def _permute( length_sorted_idx = np.argsort([-sorter(sen) for sen in texts]) texts_sorted = [texts[idx] for idx in length_sorted_idx] - return texts_sorted, lambda unsorted_embeddings: [ # noqa E731 + return texts_sorted, lambda unsorted_embeddings: [ # E731 unsorted_embeddings[idx] for idx in np.argsort(length_sorted_idx) ] diff --git a/libs/community/langchain_community/embeddings/localai.py b/libs/community/langchain_community/embeddings/localai.py index b5a926e8fe2ca..fe620e9a6faf5 100644 --- a/libs/community/langchain_community/embeddings/localai.py +++ b/libs/community/langchain_community/embeddings/localai.py @@ -254,7 +254,7 @@ def _invocation_params(self) -> Dict: openai.proxy = { "http": self.openai_proxy, "https": self.openai_proxy, - } # type: ignore[assignment] # noqa: E501 + } # type: ignore[assignment] return openai_args def _embedding_func(self, text: str, *, engine: str) -> List[float]: diff --git a/libs/community/langchain_community/embeddings/openai.py b/libs/community/langchain_community/embeddings/openai.py index 3edff9055e82a..22ddac802a451 100644 --- a/libs/community/langchain_community/embeddings/openai.py +++ b/libs/community/langchain_community/embeddings/openai.py @@ -390,7 +390,7 @@ def _invocation_params(self) -> Dict[str, Any]: openai.proxy = { "http": self.openai_proxy, "https": self.openai_proxy, - } # type: ignore[assignment] # noqa: E501 + } # type: ignore[assignment] return openai_args # please refer to diff --git a/libs/community/langchain_community/embeddings/yandex.py b/libs/community/langchain_community/embeddings/yandex.py index 603ca91943047..f396239d4fdf4 100644 --- a/libs/community/langchain_community/embeddings/yandex.py +++ b/libs/community/langchain_community/embeddings/yandex.py @@ -107,13 +107,13 @@ def validate_environment(cls, values: Dict) -> Dict: raise ValueError("'doc_model_uri' or 'folder_id' must be provided.") values[ "doc_model_uri" - ] = f"emb://{values['folder_id']}/{values['doc_model_name']}/{values['model_version']}" # noqa: E501 + ] = f"emb://{values['folder_id']}/{values['doc_model_name']}/{values['model_version']}" if not values.get("model_uri"): if values["folder_id"] == "": raise ValueError("'model_uri' or 'folder_id' must be provided.") values[ "model_uri" - ] = f"emb://{values['folder_id']}/{values['model_name']}/{values['model_version']}" # noqa: E501 + ] = f"emb://{values['folder_id']}/{values['model_name']}/{values['model_version']}" if values["disable_request_logging"]: values["_grpc_metadata"].append( ( diff --git a/libs/community/langchain_community/graphs/arangodb_graph.py b/libs/community/langchain_community/graphs/arangodb_graph.py index b9e4530058e83..dd2ad16614f86 100644 --- a/libs/community/langchain_community/graphs/arangodb_graph.py +++ b/libs/community/langchain_community/graphs/arangodb_graph.py @@ -174,9 +174,9 @@ def get_arangodb_client( "Unable to import arango, please install with `pip install python-arango`." ) from e - _url: str = url or os.environ.get("ARANGODB_URL", "http://localhost:8529") # type: ignore[assignment] # noqa: E501 - _dbname: str = dbname or os.environ.get("ARANGODB_DBNAME", "_system") # type: ignore[assignment] # noqa: E501 - _username: str = username or os.environ.get("ARANGODB_USERNAME", "root") # type: ignore[assignment] # noqa: E501 - _password: str = password or os.environ.get("ARANGODB_PASSWORD", "") # type: ignore[assignment] # noqa: E501 + _url: str = url or os.environ.get("ARANGODB_URL", "http://localhost:8529") # type: ignore[assignment] + _dbname: str = dbname or os.environ.get("ARANGODB_DBNAME", "_system") # type: ignore[assignment] + _username: str = username or os.environ.get("ARANGODB_USERNAME", "root") # type: ignore[assignment] + _password: str = password or os.environ.get("ARANGODB_PASSWORD", "") # type: ignore[assignment] return ArangoClient(_url).db(_dbname, _username, _password, verify=True) diff --git a/libs/community/langchain_community/llms/azureml_endpoint.py b/libs/community/langchain_community/llms/azureml_endpoint.py index 925c43661d161..f1edd988514ae 100644 --- a/libs/community/langchain_community/llms/azureml_endpoint.py +++ b/libs/community/langchain_community/llms/azureml_endpoint.py @@ -496,7 +496,7 @@ class AzureMLOnlineEndpoint(BaseLLM, AzureMLBaseEndpoint): timeout=120, content_formatter=content_formatter, ) - """ # noqa: E501 + """ @property def _identifying_params(self) -> Mapping[str, Any]: diff --git a/libs/community/langchain_community/llms/openai.py b/libs/community/langchain_community/llms/openai.py index 0d891c299f17a..757e3d85ba270 100644 --- a/libs/community/langchain_community/llms/openai.py +++ b/libs/community/langchain_community/llms/openai.py @@ -604,7 +604,7 @@ def _invocation_params(self) -> Dict[str, Any]: if self.openai_proxy: import openai - openai.proxy = {"http": self.openai_proxy, "https": self.openai_proxy} # type: ignore[assignment] # noqa: E501 + openai.proxy = {"http": self.openai_proxy, "https": self.openai_proxy} # type: ignore[assignment] return {**openai_creds, **self._default_params} @property @@ -800,7 +800,7 @@ class AzureOpenAI(BaseOpenAI): For more: https://www.microsoft.com/en-us/security/business/identity-access/microsoft-entra-id. - """ # noqa: E501 + """ azure_ad_token_provider: Union[Callable[[], str], None] = None """A function that returns an Azure Active Directory token. @@ -1055,7 +1055,7 @@ def validate_environment(cls, values: Dict) -> Dict: if openai_organization: openai.organization = openai_organization if openai_proxy: - openai.proxy = {"http": openai_proxy, "https": openai_proxy} # type: ignore[assignment] # noqa: E501 + openai.proxy = {"http": openai_proxy, "https": openai_proxy} # type: ignore[assignment] except ImportError: raise ImportError( "Could not import openai python package. " diff --git a/libs/community/langchain_community/llms/symblai_nebula.py b/libs/community/langchain_community/llms/symblai_nebula.py index afe6598f23889..9e0b2687a2f72 100644 --- a/libs/community/langchain_community/llms/symblai_nebula.py +++ b/libs/community/langchain_community/llms/symblai_nebula.py @@ -41,7 +41,7 @@ class Nebula(LLM): nebula_service_path="NEBULA_SERVICE_PATH", nebula_api_key="NEBULA_API_KEY", ) - """ # noqa: E501 + """ """Key/value arguments to pass to the model. Reserved for future use""" model_kwargs: Optional[dict] = None diff --git a/libs/community/langchain_community/output_parsers/ernie_functions.py b/libs/community/langchain_community/output_parsers/ernie_functions.py index 223284649f3b4..93fe9771cb2a6 100644 --- a/libs/community/langchain_community/output_parsers/ernie_functions.py +++ b/libs/community/langchain_community/output_parsers/ernie_functions.py @@ -164,7 +164,7 @@ def parse_result(self, result: List[Generation], *, partial: bool = False) -> An else: fn_name = _result["name"] _args = _result["arguments"] - pydantic_args = self.pydantic_schema[fn_name].parse_raw(_args) # type: ignore # noqa: E501 + pydantic_args = self.pydantic_schema[fn_name].parse_raw(_args) # type: ignore return pydantic_args diff --git a/libs/community/langchain_community/retrievers/google_vertex_ai_search.py b/libs/community/langchain_community/retrievers/google_vertex_ai_search.py index 7c4351bc3cd8a..11cb6c58a77f2 100644 --- a/libs/community/langchain_community/retrievers/google_vertex_ai_search.py +++ b/libs/community/langchain_community/retrievers/google_vertex_ai_search.py @@ -190,7 +190,7 @@ def _convert_website_search_response( print( # noqa: T201 "Make sure that your data store is using Advanced Website " "Indexing.\n" - "https://cloud.google.com/generative-ai-app-builder/docs/about-advanced-features#advanced-website-indexing" # noqa: E501 + "https://cloud.google.com/generative-ai-app-builder/docs/about-advanced-features#advanced-website-indexing" ) return documents diff --git a/libs/community/langchain_community/tools/bearly/tool.py b/libs/community/langchain_community/tools/bearly/tool.py index 286e024f64acf..cd20e80a37504 100644 --- a/libs/community/langchain_community/tools/bearly/tool.py +++ b/libs/community/langchain_community/tools/bearly/tool.py @@ -59,7 +59,7 @@ class BearlyInterpreterToolArguments(BaseModel): path. Output can only be read from the directory, stdout, and stdin. \ Do not use things like plot.show() as it will \ not work instead write them out `output/` and a link to the file will be returned. \ -print() any output and results so you can capture the output.""" # noqa: T201 +print() any output and results so you can capture the output.""" class FileInfo(BaseModel): diff --git a/libs/community/langchain_community/tools/powerbi/tool.py b/libs/community/langchain_community/tools/powerbi/tool.py index 9f54ec453d4b6..77c1c48266771 100644 --- a/libs/community/langchain_community/tools/powerbi/tool.py +++ b/libs/community/langchain_community/tools/powerbi/tool.py @@ -51,7 +51,7 @@ def validate_llm_chain_input_variables( # pylint: disable=E0213 for var in llm_chain.prompt.input_variables: if var not in ["tool_input", "tables", "schemas", "examples"]: raise ValueError( - "LLM chain for QueryPowerBITool must have input variables ['tool_input', 'tables', 'schemas', 'examples'], found %s", # noqa: C0301 E501 # pylint: disable=C0301 + "LLM chain for QueryPowerBITool must have input variables ['tool_input', 'tables', 'schemas', 'examples'], found %s", # noqa: E501 # pylint: disable=C0301 llm_chain.prompt.input_variables, ) return llm_chain diff --git a/libs/community/langchain_community/utilities/__init__.py b/libs/community/langchain_community/utilities/__init__.py index 5aea1de062318..3a5184e7c0310 100644 --- a/libs/community/langchain_community/utilities/__init__.py +++ b/libs/community/langchain_community/utilities/__init__.py @@ -105,7 +105,7 @@ OpenWeatherMapAPIWrapper, ) from langchain_community.utilities.oracleai import ( - OracleSummary, # noqa: F401 + OracleSummary, ) from langchain_community.utilities.outline import ( OutlineAPIWrapper, diff --git a/libs/community/langchain_community/utilities/arxiv.py b/libs/community/langchain_community/utilities/arxiv.py index 7b920415623be..bab2df8061b33 100644 --- a/libs/community/langchain_community/utilities/arxiv.py +++ b/libs/community/langchain_community/utilities/arxiv.py @@ -103,7 +103,7 @@ def get_summaries_as_docs(self, query: str) -> List[Document]: Args: query: a plaintext search query - """ # noqa: E501 + """ try: if self.is_arxiv_identifier(query): results = self.arxiv_search( @@ -142,7 +142,7 @@ def run(self, query: str) -> str: Args: query: a plaintext search query - """ # noqa: E501 + """ try: if self.is_arxiv_identifier(query): results = self.arxiv_search( diff --git a/libs/community/langchain_community/utilities/awslambda.py b/libs/community/langchain_community/utilities/awslambda.py index 1b497dd5dd297..8dbaca563ae96 100644 --- a/libs/community/langchain_community/utilities/awslambda.py +++ b/libs/community/langchain_community/utilities/awslambda.py @@ -60,7 +60,7 @@ def run(self, query: str) -> str: query: an input to passed to the lambda function as the ``body`` of a JSON object. - """ # noqa: E501 + """ res = self.lambda_client.invoke( FunctionName=self.function_name, InvocationType="RequestResponse", diff --git a/libs/community/langchain_community/utilities/powerbi.py b/libs/community/langchain_community/utilities/powerbi.py index 93d4886796894..085c9b8a0ab68 100644 --- a/libs/community/langchain_community/utilities/powerbi.py +++ b/libs/community/langchain_community/utilities/powerbi.py @@ -61,7 +61,7 @@ def request_url(self) -> str: """Get the request url.""" if self.group_id: return f"{BASE_URL}/groups/{self.group_id}/datasets/{self.dataset_id}/executeQueries" # noqa: E501 # pylint: disable=C0301 - return f"{BASE_URL}/datasets/{self.dataset_id}/executeQueries" # noqa: E501 # pylint: disable=C0301 + return f"{BASE_URL}/datasets/{self.dataset_id}/executeQueries" # pylint: disable=C0301 @property def headers(self) -> Dict[str, str]: diff --git a/libs/community/langchain_community/utilities/tavily_search.py b/libs/community/langchain_community/utilities/tavily_search.py index 97dc45363f2ee..95eb52266ab50 100644 --- a/libs/community/langchain_community/utilities/tavily_search.py +++ b/libs/community/langchain_community/utilities/tavily_search.py @@ -97,7 +97,7 @@ def results( content: The content of the result. score: The score of the result. raw_content: The raw content of the result. - """ # noqa: E501 + """ raw_search_results = self.raw_results( query, max_results=max_results, diff --git a/libs/community/langchain_community/utilities/twilio.py b/libs/community/langchain_community/utilities/twilio.py index a3ff0b236964e..d1c3fce5827a3 100644 --- a/libs/community/langchain_community/utilities/twilio.py +++ b/libs/community/langchain_community/utilities/twilio.py @@ -40,7 +40,7 @@ class TwilioAPIWrapper(BaseModel): Twilio also work here. You cannot, for example, spoof messages from a private cell phone number. If you are using `messaging_service_sid`, this parameter must be empty. - """ # noqa: E501 + """ class Config: """Configuration for this pydantic object.""" @@ -77,6 +77,6 @@ def run(self, body: str, to: str) -> str: SMS/MMS or [Channel user address](https://www.twilio.com/docs/sms/channels#channel-addresses) for other 3rd-party channels. - """ # noqa: E501 + """ message = self.client.messages.create(to, from_=self.from_number, body=body) return message.sid diff --git a/libs/community/langchain_community/vectorstores/__init__.py b/libs/community/langchain_community/vectorstores/__init__.py index 7e21ad78d2d63..0bd50ad673b9f 100644 --- a/libs/community/langchain_community/vectorstores/__init__.py +++ b/libs/community/langchain_community/vectorstores/__init__.py @@ -182,7 +182,7 @@ OpenSearchVectorSearch, ) from langchain_community.vectorstores.oraclevs import ( - OracleVS, # noqa: F401 + OracleVS, ) from langchain_community.vectorstores.pathway import ( PathwayVectorClient, @@ -448,7 +448,7 @@ "MyScale": "langchain_community.vectorstores.myscale", "MyScaleSettings": "langchain_community.vectorstores.myscale", "Neo4jVector": "langchain_community.vectorstores.neo4j_vector", - "NeuralDBClientVectorStore": "langchain_community.vectorstores.thirdai_neuraldb", # noqa: E501 + "NeuralDBClientVectorStore": "langchain_community.vectorstores.thirdai_neuraldb", "NeuralDBVectorStore": "langchain_community.vectorstores.thirdai_neuraldb", "OpenSearchVectorSearch": "langchain_community.vectorstores.opensearch_vector_search", # noqa: E501 "OracleVS": "langchain_community.vectorstores.oraclevs", diff --git a/libs/community/langchain_community/vectorstores/jaguar.py b/libs/community/langchain_community/vectorstores/jaguar.py index 3a6bae51f9ef1..a7a5556428c4e 100644 --- a/libs/community/langchain_community/vectorstores/jaguar.py +++ b/libs/community/langchain_community/vectorstores/jaguar.py @@ -431,7 +431,7 @@ def logout(self) -> None: def prt(self, msg: str) -> None: with open("/tmp/debugjaguar.log", "a") as file: - print(f"msg={msg}", file=file, flush=True) # noqa: T201 + print(f"msg={msg}", file=file, flush=True) def _parseMeta(self, nvmap: dict, filecol: str) -> Tuple[List[str], List[str], str]: filepath = "" diff --git a/libs/community/langchain_community/vectorstores/momento_vector_index.py b/libs/community/langchain_community/vectorstores/momento_vector_index.py index 4e2e03dd79f81..ebfa3c4d0e988 100644 --- a/libs/community/langchain_community/vectorstores/momento_vector_index.py +++ b/libs/community/langchain_community/vectorstores/momento_vector_index.py @@ -397,7 +397,7 @@ def max_marginal_relevance_search_by_vector( ) selected = [response.hits[i].metadata for i in mmr_selected] return [ - Document(page_content=metadata.pop(self.text_field, ""), metadata=metadata) # type: ignore # noqa: E501 + Document(page_content=metadata.pop(self.text_field, ""), metadata=metadata) # type: ignore for metadata in selected ] diff --git a/libs/community/langchain_community/vectorstores/qdrant.py b/libs/community/langchain_community/vectorstores/qdrant.py index 799007530b380..6d02332cebdf9 100644 --- a/libs/community/langchain_community/vectorstores/qdrant.py +++ b/libs/community/langchain_community/vectorstores/qdrant.py @@ -1681,7 +1681,7 @@ def construct_instance( f"Existing Qdrant collection {collection_name} uses named vectors. " f"If you want to reuse it, please set `vector_name` to any of the " f"existing named vectors: " - f"{', '.join(current_vector_config.keys())}." # noqa + f"{', '.join(current_vector_config.keys())}." f"If you want to recreate the collection, set `force_recreate` " f"parameter to `True`." ) @@ -1846,7 +1846,7 @@ async def aconstruct_instance( f"Existing Qdrant collection {collection_name} uses named vectors. " f"If you want to reuse it, please set `vector_name` to any of the " f"existing named vectors: " - f"{', '.join(current_vector_config.keys())}." # noqa + f"{', '.join(current_vector_config.keys())}." f"If you want to recreate the collection, set `force_recreate` " f"parameter to `True`." ) diff --git a/libs/community/langchain_community/vectorstores/redis/base.py b/libs/community/langchain_community/vectorstores/redis/base.py index c9a19f8e7ee17..8a885aff39720 100644 --- a/libs/community/langchain_community/vectorstores/redis/base.py +++ b/libs/community/langchain_community/vectorstores/redis/base.py @@ -383,7 +383,7 @@ def from_texts_return_keys( # type check for metadata if metadatas: - if isinstance(metadatas, list) and len(metadatas) != len(texts): # type: ignore # noqa: E501 + if isinstance(metadatas, list) and len(metadatas) != len(texts): # type: ignore raise ValueError("Number of metadatas must match number of texts") if not (isinstance(metadatas, list) and isinstance(metadatas[0], dict)): raise ValueError("Metadatas must be a list of dicts") @@ -704,7 +704,7 @@ def add_texts( # type check for metadata if metadatas: - if isinstance(metadatas, list) and len(metadatas) != len(texts): # type: ignore # noqa: E501 + if isinstance(metadatas, list) and len(metadatas) != len(texts): # type: ignore raise ValueError("Number of metadatas must match number of texts") if not (isinstance(metadatas, list) and isinstance(metadatas[0], dict)): raise ValueError("Metadatas must be a list of dicts") @@ -832,7 +832,7 @@ def similarity_search_with_score( # Perform vector search # ignore type because redis-py is wrong about bytes try: - results = self.client.ft(self.index_name).search(redis_query, params_dict) # type: ignore # noqa: E501 + results = self.client.ft(self.index_name).search(redis_query, params_dict) # type: ignore except redis.exceptions.ResponseError as e: # split error message and see if it starts with "Syntax" if str(e).split(" ")[0] == "Syntax": @@ -947,7 +947,7 @@ def similarity_search_by_vector( # Perform vector search # ignore type because redis-py is wrong about bytes try: - results = self.client.ft(self.index_name).search(redis_query, params_dict) # type: ignore # noqa: E501 + results = self.client.ft(self.index_name).search(redis_query, params_dict) # type: ignore except redis.exceptions.ResponseError as e: # split error message and see if it starts with "Syntax" if str(e).split(" ")[0] == "Syntax": diff --git a/libs/community/langchain_community/vectorstores/timescalevector.py b/libs/community/langchain_community/vectorstores/timescalevector.py index 5e3e3c41ad4b8..47931634187cc 100644 --- a/libs/community/langchain_community/vectorstores/timescalevector.py +++ b/libs/community/langchain_community/vectorstores/timescalevector.py @@ -66,7 +66,7 @@ class TimescaleVector(VectorStore): collection_name=COLLECTION_NAME, service_url=SERVICE_URL, ) - """ # noqa: E501 + """ def __init__( self, diff --git a/libs/community/tests/integration_tests/document_loaders/test_tensorflow_datasets.py b/libs/community/tests/integration_tests/document_loaders/test_tensorflow_datasets.py index 7498b65e56eec..956b868313206 100644 --- a/libs/community/tests/integration_tests/document_loaders/test_tensorflow_datasets.py +++ b/libs/community/tests/integration_tests/document_loaders/test_tensorflow_datasets.py @@ -12,7 +12,7 @@ ) if TYPE_CHECKING: - import tensorflow as tf # noqa: E402 + import tensorflow as tf def decode_to_str(item: tf.Tensor) -> str: diff --git a/libs/community/tests/integration_tests/utilities/test_tensorflow_datasets.py b/libs/community/tests/integration_tests/utilities/test_tensorflow_datasets.py index 01990bc2c4b84..6e207dd7bc779 100644 --- a/libs/community/tests/integration_tests/utilities/test_tensorflow_datasets.py +++ b/libs/community/tests/integration_tests/utilities/test_tensorflow_datasets.py @@ -10,7 +10,7 @@ from langchain_community.utilities.tensorflow_datasets import TensorflowDatasets if TYPE_CHECKING: - import tensorflow as tf # noqa: E402 + import tensorflow as tf def decode_to_str(item: tf.Tensor) -> str: diff --git a/libs/community/tests/integration_tests/vectorstores/qdrant/async_api/test_add_texts.py b/libs/community/tests/integration_tests/vectorstores/qdrant/async_api/test_add_texts.py index df15626b0fb31..ab7ecebd6dd0e 100644 --- a/libs/community/tests/integration_tests/vectorstores/qdrant/async_api/test_add_texts.py +++ b/libs/community/tests/integration_tests/vectorstores/qdrant/async_api/test_add_texts.py @@ -7,7 +7,7 @@ from tests.integration_tests.vectorstores.fake_embeddings import ( ConsistentFakeEmbeddings, ) -from tests.integration_tests.vectorstores.qdrant.async_api.fixtures import ( # noqa +from tests.integration_tests.vectorstores.qdrant.async_api.fixtures import ( qdrant_locations, ) diff --git a/libs/community/tests/integration_tests/vectorstores/test_azure_cosmos_db.py b/libs/community/tests/integration_tests/vectorstores/test_azure_cosmos_db.py index 483c6ee50d235..6f132af44a215 100644 --- a/libs/community/tests/integration_tests/vectorstores/test_azure_cosmos_db.py +++ b/libs/community/tests/integration_tests/vectorstores/test_azure_cosmos_db.py @@ -74,7 +74,7 @@ def setup_class(cls) -> None: # insure the test collection is empty collection = prepare_collection() - assert collection.count_documents({}) == 0 # type: ignore[index] # noqa: E501 + assert collection.count_documents({}) == 0 # type: ignore[index] @classmethod def teardown_class(cls) -> None: diff --git a/libs/community/tests/integration_tests/vectorstores/test_documentdb.py b/libs/community/tests/integration_tests/vectorstores/test_documentdb.py index 261d98751bde7..805e46599ed2c 100644 --- a/libs/community/tests/integration_tests/vectorstores/test_documentdb.py +++ b/libs/community/tests/integration_tests/vectorstores/test_documentdb.py @@ -70,7 +70,7 @@ def setup_class(cls) -> None: # insure the test collection is empty collection = prepare_collection() - assert collection.count_documents({}) == 0 # type: ignore[index] # noqa: E501 + assert collection.count_documents({}) == 0 # type: ignore[index] @classmethod def teardown_class(cls) -> None: diff --git a/libs/community/tests/integration_tests/vectorstores/test_mongodb_atlas.py b/libs/community/tests/integration_tests/vectorstores/test_mongodb_atlas.py index d88c1d34a6ca4..d5a0b547df399 100644 --- a/libs/community/tests/integration_tests/vectorstores/test_mongodb_atlas.py +++ b/libs/community/tests/integration_tests/vectorstores/test_mongodb_atlas.py @@ -34,7 +34,7 @@ class TestMongoDBAtlasVectorSearch: def setup_class(cls) -> None: # insure the test collection is empty collection = get_collection() - assert collection.count_documents({}) == 0 # type: ignore[index] # noqa: E501 + assert collection.count_documents({}) == 0 # type: ignore[index] @classmethod def teardown_class(cls) -> None: diff --git a/libs/community/tests/unit_tests/document_loaders/parsers/language/test_lua.py b/libs/community/tests/unit_tests/document_loaders/parsers/language/test_lua.py index afb50b8345bfe..dab2ea8474bbb 100644 --- a/libs/community/tests/unit_tests/document_loaders/parsers/language/test_lua.py +++ b/libs/community/tests/unit_tests/document_loaders/parsers/language/test_lua.py @@ -33,7 +33,7 @@ def test_is_valid(self) -> None: @pytest.mark.skip( reason=( "Flakey. To be investigated. See " - "https://github.com/langchain-ai/langchain/actions/runs/7907779756/job/21585580650." # noqa: E501 + "https://github.com/langchain-ai/langchain/actions/runs/7907779756/job/21585580650." ) ) def test_extract_functions_classes(self) -> None: @@ -46,7 +46,7 @@ def test_extract_functions_classes(self) -> None: reason=( "Flakey. To be investigated. See " "https://github.com/langchain-ai/langchain/actions/runs/7923203031/job/21632416298?pr=17599 " # noqa: E501 - "and https://github.com/langchain-ai/langchain/actions/runs/7923784089/job/2163420864." # noqa: E501 + "and https://github.com/langchain-ai/langchain/actions/runs/7923784089/job/2163420864." ) ) def test_simplify_code(self) -> None: diff --git a/libs/community/tests/unit_tests/llms/test_llamafile.py b/libs/community/tests/unit_tests/llms/test_llamafile.py index 10fea66a5ac73..186629149f5ee 100644 --- a/libs/community/tests/unit_tests/llms/test_llamafile.py +++ b/libs/community/tests/unit_tests/llms/test_llamafile.py @@ -42,7 +42,7 @@ def mock_response() -> requests.Response: def mock_response_stream(): # type: ignore[no-untyped-def] mock_response = deque( [ - b'data: {"content":"the","multimodal":false,"slot_id":0,"stop":false}\n\n', # noqa + b'data: {"content":"the","multimodal":false,"slot_id":0,"stop":false}\n\n', b'data: {"content":" quick","multimodal":false,"slot_id":0,"stop":false}\n\n', # noqa ] ) diff --git a/libs/community/tests/unit_tests/test_cache.py b/libs/community/tests/unit_tests/test_cache.py index 75798ba8538ed..d3c938802143a 100644 --- a/libs/community/tests/unit_tests/test_cache.py +++ b/libs/community/tests/unit_tests/test_cache.py @@ -22,7 +22,7 @@ from langchain.globals import get_llm_cache, set_llm_cache from langchain_core.outputs import Generation, LLMResult -from langchain_community.cache import SQLAlchemyCache # noqa: E402 +from langchain_community.cache import SQLAlchemyCache from tests.unit_tests.llms.fake_llm import FakeLLM diff --git a/libs/community/tests/unit_tests/test_document_transformers.py b/libs/community/tests/unit_tests/test_document_transformers.py index 88f1d6dc9d9c1..78b0f08c77a43 100644 --- a/libs/community/tests/unit_tests/test_document_transformers.py +++ b/libs/community/tests/unit_tests/test_document_transformers.py @@ -3,7 +3,7 @@ pytest.importorskip("langchain_community") -from langchain_community.document_transformers.embeddings_redundant_filter import ( # noqa: E402,E501 +from langchain_community.document_transformers.embeddings_redundant_filter import ( # noqa: E402 _filter_similar_embeddings, ) from langchain_community.utils.math import cosine_similarity # noqa: E402 diff --git a/libs/core/langchain_core/messages/ai.py b/libs/core/langchain_core/messages/ai.py index 0f14caecf566e..4ab316b9d082a 100644 --- a/libs/core/langchain_core/messages/ai.py +++ b/libs/core/langchain_core/messages/ai.py @@ -110,7 +110,7 @@ class AIMessageChunk(AIMessage, BaseMessageChunk): # Ignoring mypy re-assignment here since we're overriding the value # to make sure that the chunk variant can be discriminated from the # non-chunk variant. - type: Literal["AIMessageChunk"] = "AIMessageChunk" # type: ignore[assignment] # noqa: E501 + type: Literal["AIMessageChunk"] = "AIMessageChunk" # type: ignore[assignment] tool_call_chunks: List[ToolCallChunk] = [] """If provided, tool call chunks associated with the message.""" diff --git a/libs/core/langchain_core/messages/human.py b/libs/core/langchain_core/messages/human.py index b89860a562853..f57b678fe8aeb 100644 --- a/libs/core/langchain_core/messages/human.py +++ b/libs/core/langchain_core/messages/human.py @@ -28,7 +28,7 @@ class HumanMessageChunk(HumanMessage, BaseMessageChunk): # Ignoring mypy re-assignment here since we're overriding the value # to make sure that the chunk variant can be discriminated from the # non-chunk variant. - type: Literal["HumanMessageChunk"] = "HumanMessageChunk" # type: ignore[assignment] # noqa: E501 + type: Literal["HumanMessageChunk"] = "HumanMessageChunk" # type: ignore[assignment] @classmethod def get_lc_namespace(cls) -> List[str]: diff --git a/libs/core/langchain_core/messages/system.py b/libs/core/langchain_core/messages/system.py index c86a60f91ffd0..7211d5327e75d 100644 --- a/libs/core/langchain_core/messages/system.py +++ b/libs/core/langchain_core/messages/system.py @@ -25,7 +25,7 @@ class SystemMessageChunk(SystemMessage, BaseMessageChunk): # Ignoring mypy re-assignment here since we're overriding the value # to make sure that the chunk variant can be discriminated from the # non-chunk variant. - type: Literal["SystemMessageChunk"] = "SystemMessageChunk" # type: ignore[assignment] # noqa: E501 + type: Literal["SystemMessageChunk"] = "SystemMessageChunk" # type: ignore[assignment] @classmethod def get_lc_namespace(cls) -> List[str]: diff --git a/libs/core/langchain_core/output_parsers/openai_functions.py b/libs/core/langchain_core/output_parsers/openai_functions.py index 721ab180bac10..08391f5243fb1 100644 --- a/libs/core/langchain_core/output_parsers/openai_functions.py +++ b/libs/core/langchain_core/output_parsers/openai_functions.py @@ -205,7 +205,7 @@ def parse_result(self, result: List[Generation], *, partial: bool = False) -> An else: fn_name = _result["name"] _args = _result["arguments"] - pydantic_args = self.pydantic_schema[fn_name].parse_raw(_args) # type: ignore # noqa: E501 + pydantic_args = self.pydantic_schema[fn_name].parse_raw(_args) # type: ignore return pydantic_args diff --git a/libs/core/langchain_core/outputs/chat_generation.py b/libs/core/langchain_core/outputs/chat_generation.py index 17ce470053009..e95c538926edf 100644 --- a/libs/core/langchain_core/outputs/chat_generation.py +++ b/libs/core/langchain_core/outputs/chat_generation.py @@ -61,7 +61,7 @@ class ChatGenerationChunk(ChatGeneration): message: BaseMessageChunk # Override type to be ChatGeneration, ignore mypy error as this is intentional - type: Literal["ChatGenerationChunk"] = "ChatGenerationChunk" # type: ignore[assignment] # noqa: E501 + type: Literal["ChatGenerationChunk"] = "ChatGenerationChunk" # type: ignore[assignment] """Type is used exclusively for serialization purposes.""" @classmethod diff --git a/libs/core/langchain_core/prompts/chat.py b/libs/core/langchain_core/prompts/chat.py index 4316dc5bdd949..eea59202cfc70 100644 --- a/libs/core/langchain_core/prompts/chat.py +++ b/libs/core/langchain_core/prompts/chat.py @@ -431,7 +431,7 @@ def from_template( if isinstance(tmpl, str): text: str = tmpl else: - text = cast(_TextTemplateParam, tmpl)["text"] # type: ignore[assignment] # noqa: E501 + text = cast(_TextTemplateParam, tmpl)["text"] # type: ignore[assignment] prompt.append( PromptTemplate.from_template( text, template_format=template_format diff --git a/libs/core/langchain_core/runnables/base.py b/libs/core/langchain_core/runnables/base.py index 67e1f7851b4a8..9ee3c7707c5c6 100644 --- a/libs/core/langchain_core/runnables/base.py +++ b/libs/core/langchain_core/runnables/base.py @@ -517,7 +517,7 @@ def as_bytes(x: Any) -> bytes: json_and_bytes_chain.invoke("[1, 2, 3]") # -> {"json": [1, 2, 3], "bytes": b"[1, 2, 3]"} - """ # noqa: E501 + """ from langchain_core.runnables.passthrough import RunnablePick return self | RunnablePick(keys) diff --git a/libs/core/langchain_core/runnables/graph_ascii.py b/libs/core/langchain_core/runnables/graph_ascii.py index 089cdb992381a..47992e2faa691 100644 --- a/libs/core/langchain_core/runnables/graph_ascii.py +++ b/libs/core/langchain_core/runnables/graph_ascii.py @@ -244,8 +244,8 @@ def draw_ascii(vertices: Mapping[str, str], edges: Sequence[LangEdge]) -> str: # NOTE: coordinates might me negative, so we need to shift # everything to the positive plane before we actually draw it. - Xs = [] # noqa: N806 - Ys = [] # noqa: N806 + Xs = [] + Ys = [] sug = _build_sugiyama_layout(vertices, edges) diff --git a/libs/core/langchain_core/runnables/history.py b/libs/core/langchain_core/runnables/history.py index c35cd42de5e25..3ff6df09d7baa 100644 --- a/libs/core/langchain_core/runnables/history.py +++ b/libs/core/langchain_core/runnables/history.py @@ -214,7 +214,7 @@ def get_session_history( config={"configurable": {"user_id": "123", "conversation_id": "1"}} ) - """ # noqa: E501 + """ get_session_history: GetSessionHistoryCallable input_messages_key: Optional[str] = None @@ -297,7 +297,7 @@ def get_session_history( into the get_session_history factory. **kwargs: Arbitrary additional kwargs to pass to parent class ``RunnableBindingBase`` init. - """ # noqa: E501 + """ history_chain: Runnable = RunnableLambda( self._enter_history, self._aenter_history ).with_config(run_name="load_history") diff --git a/libs/core/langchain_core/tracers/context.py b/libs/core/langchain_core/tracers/context.py index caadcfc68569f..00e5d3d3da4d2 100644 --- a/libs/core/langchain_core/tracers/context.py +++ b/libs/core/langchain_core/tracers/context.py @@ -33,10 +33,10 @@ tracing_callback_var: Any = None tracing_v2_callback_var: ContextVar[Optional[LangChainTracer]] = ContextVar( "tracing_callback_v2", default=None -) # noqa: E501 +) run_collector_var: ContextVar[Optional[RunCollectorCallbackHandler]] = ContextVar( "run_collector", default=None -) # noqa: E501 +) @contextmanager diff --git a/libs/core/langchain_core/utils/input.py b/libs/core/langchain_core/utils/input.py index beb8b653d1e8b..2e52a0e282fd8 100644 --- a/libs/core/langchain_core/utils/input.py +++ b/libs/core/langchain_core/utils/input.py @@ -38,6 +38,6 @@ def print_text( ) -> None: """Print text with highlighting and no end characters.""" text_to_print = get_colored_text(text, color) if color else text - print(text_to_print, end=end, file=file) # noqa: T201 + print(text_to_print, end=end, file=file) if file: file.flush() # ensure all printed content are written to file diff --git a/libs/core/tests/unit_tests/runnables/test_utils.py b/libs/core/tests/unit_tests/runnables/test_utils.py index fa8282685772f..b309287f0b29c 100644 --- a/libs/core/tests/unit_tests/runnables/test_utils.py +++ b/libs/core/tests/unit_tests/runnables/test_utils.py @@ -42,7 +42,7 @@ def test_indent_lines_after_first(text: str, prefix: str, expected_output: str) def test_nonlocals() -> None: - agent = RunnableLambda(lambda x: x * 2) # noqa: F841 + agent = RunnableLambda(lambda x: x * 2) def my_func(input: str, agent: Dict[str, str]) -> str: return agent.get("agent_name", input) diff --git a/libs/core/tests/unit_tests/test_messages.py b/libs/core/tests/unit_tests/test_messages.py index 1ae7320e15bf8..aa86b2f49e75c 100644 --- a/libs/core/tests/unit_tests/test_messages.py +++ b/libs/core/tests/unit_tests/test_messages.py @@ -143,7 +143,7 @@ def test_chat_message_chunks() -> None: role="User", content=" indeed." ) == AIMessageChunk( content="I am indeed." - ), "Other MessageChunk + ChatMessageChunk should be a MessageChunk as the left side" # noqa: E501 + ), "Other MessageChunk + ChatMessageChunk should be a MessageChunk as the left side" def test_function_message_chunks() -> None: diff --git a/libs/core/tests/unit_tests/test_tools.py b/libs/core/tests/unit_tests/test_tools.py index 78a44417431ad..f61cac1b54f5e 100644 --- a/libs/core/tests/unit_tests/test_tools.py +++ b/libs/core/tests/unit_tests/test_tools.py @@ -626,7 +626,7 @@ def test_exception_handling_callable() -> None: expected = "foo bar" def handling(e: ToolException) -> str: - return expected # noqa: E731 + return expected _tool = _FakeExceptionTool(handle_tool_error=handling) actual = _tool.run({}) @@ -657,7 +657,7 @@ async def test_async_exception_handling_callable() -> None: expected = "foo bar" def handling(e: ToolException) -> str: - return expected # noqa: E731 + return expected _tool = _FakeExceptionTool(handle_tool_error=handling) actual = await _tool.arun({}) @@ -723,7 +723,7 @@ def test_validation_error_handling_callable() -> None: expected = "foo bar" def handling(e: ValidationError) -> str: - return expected # noqa: E731 + return expected _tool = _MockStructuredTool(handle_validation_error=handling) actual = _tool.run({}) @@ -785,7 +785,7 @@ async def test_async_validation_error_handling_callable() -> None: expected = "foo bar" def handling(e: ValidationError) -> str: - return expected # noqa: E731 + return expected _tool = _MockStructuredTool(handle_validation_error=handling) actual = await _tool.arun({}) diff --git a/libs/experimental/langchain_experimental/agents/__init__.py b/libs/experimental/langchain_experimental/agents/__init__.py index fc1e4ef897855..68ca3c035026c 100644 --- a/libs/experimental/langchain_experimental/agents/__init__.py +++ b/libs/experimental/langchain_experimental/agents/__init__.py @@ -6,7 +6,7 @@ to take and in which order. Agents select and use **Tools** and **Toolkits** for actions. -""" # noqa: E501 +""" from langchain_experimental.agents.agent_toolkits import ( create_csv_agent, create_pandas_dataframe_agent, diff --git a/libs/experimental/langchain_experimental/agents/agent_toolkits/pandas/base.py b/libs/experimental/langchain_experimental/agents/agent_toolkits/pandas/base.py index 98e8403661368..6fe319fa3e8da 100644 --- a/libs/experimental/langchain_experimental/agents/agent_toolkits/pandas/base.py +++ b/libs/experimental/langchain_experimental/agents/agent_toolkits/pandas/base.py @@ -220,7 +220,7 @@ def create_pandas_dataframe_agent( verbose=True ) - """ # noqa: E501 + """ try: if engine == "modin": import modin.pandas as pd diff --git a/libs/experimental/langchain_experimental/chat_models/llm_wrapper.py b/libs/experimental/langchain_experimental/chat_models/llm_wrapper.py index e02855a761cef..8ff4d01afd4e3 100644 --- a/libs/experimental/langchain_experimental/chat_models/llm_wrapper.py +++ b/libs/experimental/langchain_experimental/chat_models/llm_wrapper.py @@ -149,7 +149,7 @@ def _llm_type(self) -> str: class Mixtral(ChatWrapper): - """See https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1#instruction-format""" # noqa: E501 + """See https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1#instruction-format""" @property def _llm_type(self) -> str: diff --git a/libs/experimental/langchain_experimental/llm_bash/bash.py b/libs/experimental/langchain_experimental/llm_bash/bash.py index 6221e05e592bb..fc94d091c9631 100644 --- a/libs/experimental/langchain_experimental/llm_bash/bash.py +++ b/libs/experimental/langchain_experimental/llm_bash/bash.py @@ -88,7 +88,7 @@ def _initialize_persistent_process(self: BashProcess, prompt: str) -> pexpect.sp Args: Prompt(str): the bash command to execute - """ # noqa: E501 + """ pexpect = self._lazy_import_pexpect() process = pexpect.spawn( "env", ["-i", "bash", "--norc", "--noprofile"], encoding="utf-8" @@ -107,7 +107,7 @@ def run(self, commands: Union[str, List[str]]) -> str: Args: commands(List[str]): a list of commands to execute in the session - """ # noqa: E501 + """ if isinstance(commands, str): commands = [commands] commands = ";".join(commands) @@ -125,7 +125,7 @@ def _run(self, command: str) -> str: Args: command: The command to run - """ # noqa: E501 + """ try: output = subprocess.run( command, @@ -149,7 +149,7 @@ def process_output(self, output: str, command: str) -> str: Args: output: a process' output string command: the executed command - """ # noqa: E501 + """ pattern = re.escape(command) + r"\s*\n" output = re.sub(pattern, "", output, count=1) return output.strip() @@ -161,7 +161,7 @@ def _run_persistent(self, command: str) -> str: Args: command: the command to execute - """ # noqa: E501 + """ pexpect = self._lazy_import_pexpect() if self.process is None: raise ValueError("Process not initialized") diff --git a/libs/experimental/langchain_experimental/pal_chain/__init__.py b/libs/experimental/langchain_experimental/pal_chain/__init__.py index bba4e717f4385..363465136ae6d 100644 --- a/libs/experimental/langchain_experimental/pal_chain/__init__.py +++ b/libs/experimental/langchain_experimental/pal_chain/__init__.py @@ -3,7 +3,7 @@ See the paper: https://arxiv.org/pdf/2211.10435.pdf. This chain is vulnerable to [arbitrary code execution](https://github.com/langchain-ai/langchain/issues/5872). -""" # noqa: E501 +""" from langchain_experimental.pal_chain.base import PALChain __all__ = ["PALChain"] diff --git a/libs/experimental/langchain_experimental/recommenders/__init__.py b/libs/experimental/langchain_experimental/recommenders/__init__.py index 1c05b72faf953..aa02599d13d59 100644 --- a/libs/experimental/langchain_experimental/recommenders/__init__.py +++ b/libs/experimental/langchain_experimental/recommenders/__init__.py @@ -3,7 +3,7 @@ [Amazon Personalize](https://docs.aws.amazon.com/personalize/latest/dg/what-is-personalize.html) is a fully managed machine learning service that uses your data to generate item recommendations for your users. -""" # noqa: E501 +""" from langchain_experimental.recommenders.amazon_personalize import AmazonPersonalize from langchain_experimental.recommenders.amazon_personalize_chain import ( AmazonPersonalizeChain, diff --git a/libs/experimental/langchain_experimental/rl_chain/base.py b/libs/experimental/langchain_experimental/rl_chain/base.py index 33fc226835910..2e501ae73440c 100644 --- a/libs/experimental/langchain_experimental/rl_chain/base.py +++ b/libs/experimental/langchain_experimental/rl_chain/base.py @@ -475,7 +475,7 @@ def activate_selection_scorer(self) -> None: def save_progress(self) -> None: """ This function should be called to save the state of the learned policy model. - """ # noqa: E501 + """ self.active_policy.save() def _validate_inputs(self, inputs: Dict[str, Any]) -> None: diff --git a/libs/experimental/tests/unit_tests/chat_models/test_llm_wrapper_mixtral.py b/libs/experimental/tests/unit_tests/chat_models/test_llm_wrapper_mixtral.py index 797c6080231cd..63871ea30e205 100644 --- a/libs/experimental/tests/unit_tests/chat_models/test_llm_wrapper_mixtral.py +++ b/libs/experimental/tests/unit_tests/chat_models/test_llm_wrapper_mixtral.py @@ -25,7 +25,7 @@ def test_prompt(model: Mixtral) -> None: actual = model.invoke(messages).content # type: ignore expected = ( - "[INST] sys-msg\nusr-msg-1 [/INST] ai-msg-1 [INST] usr-msg-2 [/INST]" # noqa: E501 + "[INST] sys-msg\nusr-msg-1 [/INST] ai-msg-1 [INST] usr-msg-2 [/INST]" ) assert actual == expected diff --git a/libs/experimental/tests/unit_tests/python/test_python_2.py b/libs/experimental/tests/unit_tests/python/test_python_2.py index 65fc8f62cb622..56ebaaaf246fb 100644 --- a/libs/experimental/tests/unit_tests/python/test_python_2.py +++ b/libs/experimental/tests/unit_tests/python/test_python_2.py @@ -78,7 +78,7 @@ def test_python_ast_repl_print() -> None: if string == string[::-1]: print(string, "is a palindrome") # noqa: T201 else: - print(string, "is not a palindrome")""" # noqa: T201 + print(string, "is not a palindrome")""" tool = PythonAstREPLTool() assert tool.run(program) == "racecar is a palindrome\n" diff --git a/libs/langchain/langchain/agents/agent_toolkits/conversational_retrieval/openai_functions.py b/libs/langchain/langchain/agents/agent_toolkits/conversational_retrieval/openai_functions.py index 344c134a2bb3c..6443b43e89e28 100644 --- a/libs/langchain/langchain/agents/agent_toolkits/conversational_retrieval/openai_functions.py +++ b/libs/langchain/langchain/agents/agent_toolkits/conversational_retrieval/openai_functions.py @@ -1,4 +1,4 @@ -from typing import Any, List, Optional # noqa: E501 +from typing import Any, List, Optional from langchain_core.language_models import BaseLanguageModel from langchain_core.memory import BaseMemory diff --git a/libs/langchain/langchain/callbacks/tracers/logging.py b/libs/langchain/langchain/callbacks/tracers/logging.py index f661c7be8f7f9..7cfc9a72f088b 100644 --- a/libs/langchain/langchain/callbacks/tracers/logging.py +++ b/libs/langchain/langchain/callbacks/tracers/logging.py @@ -33,8 +33,8 @@ def on_text( text: str, *, run_id: UUID, - parent_run_id: Optional[UUID] = None, # noqa: ARG002 - **kwargs: Any, # noqa: ARG002 + parent_run_id: Optional[UUID] = None, + **kwargs: Any, ) -> None: try: crumbs_str = f"[{self.get_breadcrumbs(run=self._get_run(run_id=run_id))}] " diff --git a/libs/langchain/langchain/chains/openai_functions/openapi.py b/libs/langchain/langchain/chains/openai_functions/openapi.py index 86819dc9eea82..79c78fdc2ef86 100644 --- a/libs/langchain/langchain/chains/openai_functions/openapi.py +++ b/libs/langchain/langchain/chains/openai_functions/openapi.py @@ -76,7 +76,7 @@ def _openapi_params_to_json_schema(params: List[Parameter], spec: OpenAPISpec) - if p.param_schema: schema = spec.get_schema(p.param_schema) else: - media_type_schema = list(p.content.values())[0].media_type_schema # type: ignore # noqa: E501 + media_type_schema = list(p.content.values())[0].media_type_schema # type: ignore schema = spec.get_schema(media_type_schema) if p.description and not schema.description: schema.description = p.description @@ -237,7 +237,7 @@ def _call( else: try: response = api_response.json() - except Exception: # noqa: E722 + except Exception: response = api_response.text return {self.output_key: response} @@ -280,7 +280,7 @@ def get_openapi_chain( break except ImportError as e: raise e - except Exception: # noqa: E722 + except Exception: pass if isinstance(spec, str): raise ValueError(f"Unable to parse spec from source {spec}") diff --git a/libs/langchain/langchain/evaluation/agents/trajectory_eval_chain.py b/libs/langchain/langchain/evaluation/agents/trajectory_eval_chain.py index 3b80f4ae989c7..e0e07906212fd 100644 --- a/libs/langchain/langchain/evaluation/agents/trajectory_eval_chain.py +++ b/libs/langchain/langchain/evaluation/agents/trajectory_eval_chain.py @@ -141,7 +141,7 @@ def geography_answers(country: str, question: str) -> str: ) print(result["score"]) # noqa: T201 # 0 - """ # noqa: E501 + """ agent_tools: Optional[List[BaseTool]] = None """A list of tools available to the agent.""" diff --git a/libs/langchain/langchain/evaluation/criteria/eval_chain.py b/libs/langchain/langchain/evaluation/criteria/eval_chain.py index 9df3853195850..00f9188502550 100644 --- a/libs/langchain/langchain/evaluation/criteria/eval_chain.py +++ b/libs/langchain/langchain/evaluation/criteria/eval_chain.py @@ -142,7 +142,7 @@ def resolve_criteria( >>> criterion = "relevance" >>> CriteriaEvalChain.resolve_criteria(criteria) {'relevance': 'Is the submission referring to a real quote from the text?'} - """ # noqa: E501 + """ if criteria is None: return { "helpfulness": _SUPPORTED_CRITERIA[Criteria.HELPFULNESS], @@ -307,7 +307,7 @@ def resolve_criteria( >>> criterion = "relevance" >>> CriteriaEvalChain.resolve_criteria(criteria) {'relevance': 'Is the submission referring to a real quote from the text?'} - """ # noqa: E501 + """ return resolve_criteria(criteria) @classmethod diff --git a/libs/langchain/langchain/evaluation/loading.py b/libs/langchain/langchain/evaluation/loading.py index 27a8f348e48f0..cc092de9465ef 100644 --- a/libs/langchain/langchain/evaluation/loading.py +++ b/libs/langchain/langchain/evaluation/loading.py @@ -56,7 +56,7 @@ def load_dataset(uri: str) -> List[Dict]: from langchain.evaluation import load_dataset ds = load_dataset("llm-math") - """ # noqa: E501 + """ try: from datasets import load_dataset except ImportError: diff --git a/libs/langchain/langchain/evaluation/scoring/eval_chain.py b/libs/langchain/langchain/evaluation/scoring/eval_chain.py index c73de5f21a316..e4a9a9d43c6b8 100644 --- a/libs/langchain/langchain/evaluation/scoring/eval_chain.py +++ b/libs/langchain/langchain/evaluation/scoring/eval_chain.py @@ -439,7 +439,7 @@ def from_llm( Raises: ValueError: If the input variables are not as expected. - """ # noqa: E501 + """ expected_input_vars = { "prediction", "input", diff --git a/libs/langchain/langchain/smith/evaluation/config.py b/libs/langchain/langchain/smith/evaluation/config.py index d73bba22624bb..e9bdd324779db 100644 --- a/libs/langchain/langchain/smith/evaluation/config.py +++ b/libs/langchain/langchain/smith/evaluation/config.py @@ -133,7 +133,7 @@ class RunEvalConfig(BaseModel): as `EvaluatorType.QA`, the evaluator type string ("qa"), or a configuration for a given evaluator (e.g., - :class:`RunEvalConfig.QA `).""" # noqa: E501 + :class:`RunEvalConfig.QA `).""" custom_evaluators: Optional[List[CUSTOM_EVALUATOR_TYPE]] = None """Custom evaluators to apply to the dataset run.""" batch_evaluators: Optional[List[BATCH_EVALUATOR_LIKE]] = None diff --git a/libs/langchain/langchain/smith/evaluation/runner_utils.py b/libs/langchain/langchain/smith/evaluation/runner_utils.py index 1df4872a8c093..9cd018d9b97bc 100644 --- a/libs/langchain/langchain/smith/evaluation/runner_utils.py +++ b/libs/langchain/langchain/smith/evaluation/runner_utils.py @@ -225,7 +225,7 @@ def _wrap_in_chain_factory( return lambda: RunnableLambda(constructor) else: # Typical correct case - return constructor # noqa + return constructor return llm_or_chain_factory diff --git a/libs/partners/anthropic/tests/integration_tests/test_experimental.py b/libs/partners/anthropic/tests/integration_tests/test_experimental.py index cc035d4589f8c..4e23e0f4422e5 100644 --- a/libs/partners/anthropic/tests/integration_tests/test_experimental.py +++ b/libs/partners/anthropic/tests/integration_tests/test_experimental.py @@ -165,5 +165,5 @@ class Email(BaseModel): { "email": "From: Erick. The email is about the new project. The tone is positive. The action items are to send the report and to schedule a meeting." # noqa: E501 } - ) # noqa: E501 + ) assert isinstance(response, Email) diff --git a/libs/partners/mongodb/tests/integration_tests/test_vectorstores.py b/libs/partners/mongodb/tests/integration_tests/test_vectorstores.py index 16d4b17bafa9b..451ff29113442 100644 --- a/libs/partners/mongodb/tests/integration_tests/test_vectorstores.py +++ b/libs/partners/mongodb/tests/integration_tests/test_vectorstores.py @@ -51,7 +51,7 @@ def setup_class(cls) -> None: # insure the test collection is empty collection = get_collection() if collection.count_documents({}): - collection.delete_many({}) # type: ignore[index] # noqa: E501 + collection.delete_many({}) # type: ignore[index] @classmethod def teardown_class(cls) -> None: diff --git a/libs/partners/mongodb/tests/unit_tests/test_vectorstores.py b/libs/partners/mongodb/tests/unit_tests/test_vectorstores.py index 9c6c781208cb7..0dc4b7fa2af2d 100644 --- a/libs/partners/mongodb/tests/unit_tests/test_vectorstores.py +++ b/libs/partners/mongodb/tests/unit_tests/test_vectorstores.py @@ -46,7 +46,7 @@ class TestMongoDBAtlasVectorSearch: def setup_class(cls) -> None: # ensure the test collection is empty collection = get_collection() - assert collection.count_documents({}) == 0 # type: ignore[index] # noqa: E501 + assert collection.count_documents({}) == 0 # type: ignore[index] @classmethod def teardown_class(cls) -> None: diff --git a/libs/partners/openai/langchain_openai/chat_models/azure.py b/libs/partners/openai/langchain_openai/chat_models/azure.py index 0f5133a4e5761..f8202287872e6 100644 --- a/libs/partners/openai/langchain_openai/chat_models/azure.py +++ b/libs/partners/openai/langchain_openai/chat_models/azure.py @@ -81,7 +81,7 @@ class AzureChatOpenAI(BaseChatOpenAI): For more: https://www.microsoft.com/en-us/security/business/identity-access/microsoft-entra-id. - """ # noqa: E501 + """ azure_ad_token_provider: Union[Callable[[], str], None] = None """A function that returns an Azure Active Directory token. @@ -178,7 +178,7 @@ def validate_environment(cls, values: Dict) -> Dict: 'azure_endpoint="https://xxx.openai.azure.com/", ' 'azure_deployment="my-deployment"\n\n' "Or you can equivalently specify:\n\n" - 'base_url="https://xxx.openai.azure.com/openai/deployments/my-deployment"' # noqa: E501 + 'base_url="https://xxx.openai.azure.com/openai/deployments/my-deployment"' ) client_params = { "api_version": values["openai_api_version"], diff --git a/libs/partners/openai/langchain_openai/embeddings/azure.py b/libs/partners/openai/langchain_openai/embeddings/azure.py index de53c8058c2f9..f4a0bd18c96df 100644 --- a/libs/partners/openai/langchain_openai/embeddings/azure.py +++ b/libs/partners/openai/langchain_openai/embeddings/azure.py @@ -49,7 +49,7 @@ class AzureOpenAIEmbeddings(OpenAIEmbeddings): For more: https://www.microsoft.com/en-us/security/business/identity-access/microsoft-entra-id. - """ # noqa: E501 + """ azure_ad_token_provider: Union[Callable[[], str], None] = None """A function that returns an Azure Active Directory token. diff --git a/libs/partners/openai/langchain_openai/llms/azure.py b/libs/partners/openai/langchain_openai/llms/azure.py index cf9be00c64af1..35ad5e79675f9 100644 --- a/libs/partners/openai/langchain_openai/llms/azure.py +++ b/libs/partners/openai/langchain_openai/llms/azure.py @@ -54,7 +54,7 @@ class AzureOpenAI(BaseOpenAI): For more: https://www.microsoft.com/en-us/security/business/identity-access/microsoft-entra-id. - """ # noqa: E501 + """ azure_ad_token_provider: Union[Callable[[], str], None] = None """A function that returns an Azure Active Directory token. diff --git a/libs/partners/qdrant/langchain_qdrant/vectorstores.py b/libs/partners/qdrant/langchain_qdrant/vectorstores.py index 766a70d0fbf9e..7f43885416f08 100644 --- a/libs/partners/qdrant/langchain_qdrant/vectorstores.py +++ b/libs/partners/qdrant/langchain_qdrant/vectorstores.py @@ -1657,7 +1657,7 @@ def construct_instance( f"Existing Qdrant collection {collection_name} uses named vectors. " f"If you want to reuse it, please set `vector_name` to any of the " f"existing named vectors: " - f"{', '.join(current_vector_config.keys())}." # noqa + f"{', '.join(current_vector_config.keys())}." f"If you want to recreate the collection, set `force_recreate` " f"parameter to `True`." ) @@ -1816,7 +1816,7 @@ async def aconstruct_instance( f"Existing Qdrant collection {collection_name} uses named vectors. " f"If you want to reuse it, please set `vector_name` to any of the " f"existing named vectors: " - f"{', '.join(current_vector_config.keys())}." # noqa + f"{', '.join(current_vector_config.keys())}." f"If you want to recreate the collection, set `force_recreate` " f"parameter to `True`." ) diff --git a/libs/partners/together/tests/unit_tests/test_llms.py b/libs/partners/together/tests/unit_tests/test_llms.py index 7cb2e8c6e6471..0e32e24b9e785 100644 --- a/libs/partners/together/tests/unit_tests/test_llms.py +++ b/libs/partners/together/tests/unit_tests/test_llms.py @@ -27,7 +27,7 @@ def test_together_api_key_masked_when_passed_from_env( temperature=0.2, max_tokens=250, ) - print(llm.together_api_key, end="") # noqa: T201 + print(llm.together_api_key, end="") captured = capsys.readouterr() assert captured.out == "**********" @@ -43,7 +43,7 @@ def test_together_api_key_masked_when_passed_via_constructor( temperature=0.2, max_tokens=250, ) - print(llm.together_api_key, end="") # noqa: T201 + print(llm.together_api_key, end="") captured = capsys.readouterr() assert captured.out == "**********" diff --git a/templates/anthropic-iterative-search/main.py b/templates/anthropic-iterative-search/main.py index c04830d110a26..27b7aa1aa6afa 100644 --- a/templates/anthropic-iterative-search/main.py +++ b/templates/anthropic-iterative-search/main.py @@ -5,7 +5,7 @@ "Which movie came out first: Oppenheimer, or " "Are You There God It's Me Margaret?" ) - print( # noqa: T201 + print( final_chain.with_config(configurable={"chain": "retrieve"}).invoke( {"query": query} ) diff --git a/templates/cassandra-entomology-rag/cassandra_entomology_rag/__init__.py b/templates/cassandra-entomology-rag/cassandra_entomology_rag/__init__.py index f54b58aa1a084..1816e8c7fddd2 100644 --- a/templates/cassandra-entomology-rag/cassandra_entomology_rag/__init__.py +++ b/templates/cassandra-entomology-rag/cassandra_entomology_rag/__init__.py @@ -42,7 +42,7 @@ # Please remove this and/or adapt to your use case! inserted_lines = populate(vector_store) if inserted_lines: - print(f"Done ({inserted_lines} lines inserted).") # noqa: T201 + print(f"Done ({inserted_lines} lines inserted).") entomology_template = """ You are an expert entomologist, tasked with answering enthusiast biologists' questions. diff --git a/templates/csv-agent/main.py b/templates/csv-agent/main.py index b0fba50cefef5..8814b92478794 100644 --- a/templates/csv-agent/main.py +++ b/templates/csv-agent/main.py @@ -2,4 +2,4 @@ if __name__ == "__main__": question = "who was in cabin c28?" - print(agent_executor.invoke({"input": question})) # noqa: T201 + print(agent_executor.invoke({"input": question})) diff --git a/templates/elastic-query-generator/main.py b/templates/elastic-query-generator/main.py index 6f1ff0b8c39d0..4f848b6e88ac6 100644 --- a/templates/elastic-query-generator/main.py +++ b/templates/elastic-query-generator/main.py @@ -1,4 +1,4 @@ from elastic_query_generator.chain import chain if __name__ == "__main__": - print(chain.invoke({"input": "how many customers named Carol"})) # noqa: T201 + print(chain.invoke({"input": "how many customers named Carol"})) diff --git a/templates/neo4j-advanced-rag/main.py b/templates/neo4j-advanced-rag/main.py index a50f7d56f5480..2b339491cd682 100644 --- a/templates/neo4j-advanced-rag/main.py +++ b/templates/neo4j-advanced-rag/main.py @@ -2,7 +2,7 @@ if __name__ == "__main__": original_query = "What is the plot of the Dune?" - print( # noqa: T201 + print( chain.invoke( {"question": original_query}, {"configurable": {"strategy": "parent_strategy"}}, diff --git a/templates/neo4j-cypher-ft/main.py b/templates/neo4j-cypher-ft/main.py index 36b7ac41e37f9..490d45425369e 100644 --- a/templates/neo4j-cypher-ft/main.py +++ b/templates/neo4j-cypher-ft/main.py @@ -2,4 +2,4 @@ if __name__ == "__main__": original_query = "Did tom cruis act in top gun?" - print(chain.invoke({"question": original_query})) # noqa: T201 + print(chain.invoke({"question": original_query})) diff --git a/templates/neo4j-cypher-memory/main.py b/templates/neo4j-cypher-memory/main.py index 0250de251bd2d..735fac99650e6 100644 --- a/templates/neo4j-cypher-memory/main.py +++ b/templates/neo4j-cypher-memory/main.py @@ -2,7 +2,7 @@ if __name__ == "__main__": original_query = "Who played in Top Gun?" - print( # noqa: T201 + print( chain.invoke( { "question": original_query, @@ -12,7 +12,7 @@ ) ) follow_up_query = "Did they play in any other movies?" - print( # noqa: T201 + print( chain.invoke( { "question": follow_up_query, diff --git a/templates/neo4j-cypher/main.py b/templates/neo4j-cypher/main.py index 7962b8f0ff4a3..611cbe2aff97e 100644 --- a/templates/neo4j-cypher/main.py +++ b/templates/neo4j-cypher/main.py @@ -2,4 +2,4 @@ if __name__ == "__main__": original_query = "Who played in Top Gun?" - print(chain.invoke({"question": original_query})) # noqa: T201 + print(chain.invoke({"question": original_query})) diff --git a/templates/neo4j-generation/main.py b/templates/neo4j-generation/main.py index 1068b9fe10cc1..578a18013fe6b 100644 --- a/templates/neo4j-generation/main.py +++ b/templates/neo4j-generation/main.py @@ -4,7 +4,7 @@ text = "Harrison works at LangChain, which is located in San Francisco" allowed_nodes = ["Person", "Organization", "Location"] allowed_relationships = ["WORKS_AT", "LOCATED_IN"] - print( # noqa: T201 + print( chain( text, allowed_nodes=allowed_nodes, diff --git a/templates/neo4j-parent/main.py b/templates/neo4j-parent/main.py index e109d57e5f661..ac52947e3f7f5 100644 --- a/templates/neo4j-parent/main.py +++ b/templates/neo4j-parent/main.py @@ -2,4 +2,4 @@ if __name__ == "__main__": original_query = "What is the plot of the Dune?" - print(chain.invoke(original_query)) # noqa: T201 + print(chain.invoke(original_query)) diff --git a/templates/neo4j-semantic-layer/main.py b/templates/neo4j-semantic-layer/main.py index cbe3517d5a200..681c6a20d6e89 100644 --- a/templates/neo4j-semantic-layer/main.py +++ b/templates/neo4j-semantic-layer/main.py @@ -11,7 +11,7 @@ "\n\n1. John Travolta\n2. John McDonough", ) ] - print(agent_executor.invoke({"input": original_query})) # noqa: T201 - print( # noqa: T201 + print(agent_executor.invoke({"input": original_query})) + print( agent_executor.invoke({"input": followup_query, "chat_history": chat_history}) ) diff --git a/templates/neo4j-semantic-layer/neo4j_semantic_layer/memory_tool.py b/templates/neo4j-semantic-layer/neo4j_semantic_layer/memory_tool.py index 6e3e0a8664966..784ba8f432515 100644 --- a/templates/neo4j-semantic-layer/neo4j_semantic_layer/memory_tool.py +++ b/templates/neo4j-semantic-layer/neo4j_semantic_layer/memory_tool.py @@ -34,7 +34,7 @@ def store_movie_rating(movie: str, rating: int): try: return response[0]["response"] except Exception as e: - print(e) # noqa: T201 + print(e) return "Something went wrong" diff --git a/templates/neo4j-semantic-ollama/main.py b/templates/neo4j-semantic-ollama/main.py index 3f8fe2b2830f0..d6ee3a919695e 100644 --- a/templates/neo4j-semantic-ollama/main.py +++ b/templates/neo4j-semantic-ollama/main.py @@ -11,7 +11,7 @@ "\n\n1. John Travolta\n2. John McDonough", ) ] - print(agent_executor.invoke({"input": original_query})) # noqa: T201 - print( # noqa: T201 + print(agent_executor.invoke({"input": original_query})) + print( agent_executor.invoke({"input": followup_query, "chat_history": chat_history}) ) diff --git a/templates/neo4j-semantic-ollama/neo4j_semantic_ollama/memory_tool.py b/templates/neo4j-semantic-ollama/neo4j_semantic_ollama/memory_tool.py index e0399af1d1468..f455f70c4b7b1 100644 --- a/templates/neo4j-semantic-ollama/neo4j_semantic_ollama/memory_tool.py +++ b/templates/neo4j-semantic-ollama/neo4j_semantic_ollama/memory_tool.py @@ -35,7 +35,7 @@ def store_movie_rating(movie: str, rating: int): try: return response[0]["response"] except Exception as e: - print(e) # noqa: T201 + print(e) return "Something went wrong" diff --git a/templates/neo4j-vector-memory/main.py b/templates/neo4j-vector-memory/main.py index ca7f16ca3ce4e..732f0954d59eb 100644 --- a/templates/neo4j-vector-memory/main.py +++ b/templates/neo4j-vector-memory/main.py @@ -4,13 +4,13 @@ user_id = "user_id_1" session_id = "session_id_1" original_query = "What is the plot of the Dune?" - print( # noqa: T201 + print( chain.invoke( {"question": original_query, "user_id": user_id, "session_id": session_id} ) ) follow_up_query = "Tell me more about Leto" - print( # noqa: T201 + print( chain.invoke( {"question": follow_up_query, "user_id": user_id, "session_id": session_id} ) diff --git a/templates/nvidia-rag-canonical/ingest.py b/templates/nvidia-rag-canonical/ingest.py index e4ebd0fc2bccd..d7851cfaed384 100644 --- a/templates/nvidia-rag-canonical/ingest.py +++ b/templates/nvidia-rag-canonical/ingest.py @@ -7,7 +7,7 @@ from langchain_text_splitters.character import CharacterTextSplitter if os.environ.get("NVIDIA_API_KEY", "").startswith("nvapi-"): - print("Valid NVIDIA_API_KEY already in environment. Delete to reset") # noqa: T201 + print("Valid NVIDIA_API_KEY already in environment. Delete to reset") else: nvapi_key = getpass.getpass("NVAPI Key (starts with nvapi-): ") assert nvapi_key.startswith("nvapi-"), f"{nvapi_key[:5]}... is not a valid key" diff --git a/templates/nvidia-rag-canonical/nvidia_rag_canonical/chain.py b/templates/nvidia-rag-canonical/nvidia_rag_canonical/chain.py index 98f1b8fc7b3d5..78d5e8e28c58e 100644 --- a/templates/nvidia-rag-canonical/nvidia_rag_canonical/chain.py +++ b/templates/nvidia-rag-canonical/nvidia_rag_canonical/chain.py @@ -23,7 +23,7 @@ INGESTION_CHUNK_OVERLAP = 0 if os.environ.get("NVIDIA_API_KEY", "").startswith("nvapi-"): - print("Valid NVIDIA_API_KEY already in environment. Delete to reset") # noqa: T201 + print("Valid NVIDIA_API_KEY already in environment. Delete to reset") else: nvapi_key = getpass.getpass("NVAPI Key (starts with nvapi-): ") assert nvapi_key.startswith("nvapi-"), f"{nvapi_key[:5]}... is not a valid key" diff --git a/templates/openai-functions-agent-gmail/main.py b/templates/openai-functions-agent-gmail/main.py index 93e23ef6d49f8..90fcfcc30df36 100644 --- a/templates/openai-functions-agent-gmail/main.py +++ b/templates/openai-functions-agent-gmail/main.py @@ -6,4 +6,4 @@ "First do background research on the sender and topics to make sure you" " understand the context, then write the draft." ) - print(agent_executor.invoke({"input": question, "chat_history": []})) # noqa: T201 + print(agent_executor.invoke({"input": question, "chat_history": []})) diff --git a/templates/openai-functions-agent/main.py b/templates/openai-functions-agent/main.py index 0e612d69f49e8..f0e1f5963f9e6 100644 --- a/templates/openai-functions-agent/main.py +++ b/templates/openai-functions-agent/main.py @@ -2,4 +2,4 @@ if __name__ == "__main__": question = "who won the womens world cup in 2023?" - print(agent_executor.invoke({"input": question, "chat_history": []})) # noqa: T201 + print(agent_executor.invoke({"input": question, "chat_history": []})) diff --git a/templates/plate-chain/plate_chain/prompts.py b/templates/plate-chain/plate_chain/prompts.py index 56f81262fda51..9b8eb7380ccd5 100644 --- a/templates/plate-chain/plate_chain/prompts.py +++ b/templates/plate-chain/plate_chain/prompts.py @@ -18,7 +18,7 @@ ```json {json_format} ``` -""" # noqa: E50 +""" NUM_PLATES_PROMPT = """- There {num_plates_str} in this data.""" ROWS_PROMPT = """- Each plate has {num_rows} rows.""" diff --git a/templates/propositional-retrieval/propositional_retrieval/ingest.py b/templates/propositional-retrieval/propositional_retrieval/ingest.py index 336f8410b7d36..1af11ad3f9c24 100644 --- a/templates/propositional-retrieval/propositional_retrieval/ingest.py +++ b/templates/propositional-retrieval/propositional_retrieval/ingest.py @@ -68,7 +68,7 @@ def create_index( from langchain_text_splitters import RecursiveCharacterTextSplitter # noqa from langchain_community.document_loaders.recursive_url_loader import ( RecursiveUrlLoader, - ) # noqa + ) # The attention is all you need paper # Could add more parsing here, as it's very raw. diff --git a/templates/rag-astradb/astradb_entomology_rag/__init__.py b/templates/rag-astradb/astradb_entomology_rag/__init__.py index 3f8e807cab664..7997d5909a5bc 100644 --- a/templates/rag-astradb/astradb_entomology_rag/__init__.py +++ b/templates/rag-astradb/astradb_entomology_rag/__init__.py @@ -26,7 +26,7 @@ inserted_lines = populate(vector_store) if inserted_lines: - print(f"Done ({inserted_lines} lines inserted).") # noqa: T201 + print(f"Done ({inserted_lines} lines inserted).") entomology_template = """ You are an expert entomologist, tasked with answering enthusiast biologists' questions. diff --git a/templates/rag-astradb/main.py b/templates/rag-astradb/main.py index e049d7f743781..f80b1b6626a97 100644 --- a/templates/rag-astradb/main.py +++ b/templates/rag-astradb/main.py @@ -2,4 +2,4 @@ if __name__ == "__main__": response = chain.invoke("Are there more coleoptera or bugs?") - print(response) # noqa: T201 + print(response) diff --git a/templates/rag-aws-bedrock/main.py b/templates/rag-aws-bedrock/main.py index 7be600d6bc987..d0a3c2f48c612 100644 --- a/templates/rag-aws-bedrock/main.py +++ b/templates/rag-aws-bedrock/main.py @@ -3,4 +3,4 @@ if __name__ == "__main__": query = "What is this data about?" - print(chain.invoke(query)) # noqa: T201 + print(chain.invoke(query)) diff --git a/templates/rag-aws-kendra/main.py b/templates/rag-aws-kendra/main.py index a44556cfe30cb..ceb1daa7afd3a 100644 --- a/templates/rag-aws-kendra/main.py +++ b/templates/rag-aws-kendra/main.py @@ -3,4 +3,4 @@ if __name__ == "__main__": query = "Does Kendra support table extraction?" - print(chain.invoke(query)) # noqa: T201 + print(chain.invoke(query)) diff --git a/templates/rag-chroma-multi-modal-multi-vector/ingest.py b/templates/rag-chroma-multi-modal-multi-vector/ingest.py index 941a8b6670f8e..9447ca478ecd9 100644 --- a/templates/rag-chroma-multi-modal-multi-vector/ingest.py +++ b/templates/rag-chroma-multi-modal-multi-vector/ingest.py @@ -66,7 +66,7 @@ def generate_img_summaries(img_base64_list): image_summaries.append(image_summarize(base64_image, prompt)) processed_images.append(base64_image) except Exception as e: - print(f"Error with image {i+1}: {e}") # noqa: T201 + print(f"Error with image {i+1}: {e}") return image_summaries, processed_images @@ -178,14 +178,14 @@ def add_documents(retriever, doc_summaries, doc_contents): # Load PDF doc_path = Path(__file__).parent / "docs/DDOG_Q3_earnings_deck.pdf" rel_doc_path = doc_path.relative_to(Path.cwd()) -print("Extract slides as images") # noqa: T201 +print("Extract slides as images") pil_images = get_images_from_pdf(rel_doc_path) # Convert to b64 images_base_64 = [convert_to_base64(i) for i in pil_images] # Image summaries -print("Generate image summaries") # noqa: T201 +print("Generate image summaries") image_summaries, images_base_64_processed = generate_img_summaries(images_base_64) # The vectorstore to use to index the images summaries diff --git a/templates/rag-chroma-multi-modal/ingest.py b/templates/rag-chroma-multi-modal/ingest.py index 98d4f701a4375..67c5f070c5b2c 100644 --- a/templates/rag-chroma-multi-modal/ingest.py +++ b/templates/rag-chroma-multi-modal/ingest.py @@ -27,14 +27,14 @@ def get_images_from_pdf(pdf_path, img_dump_path): img_dump_path = Path(__file__).parent / "docs/" rel_doc_path = doc_path.relative_to(Path.cwd()) rel_img_dump_path = img_dump_path.relative_to(Path.cwd()) -print("pdf index") # noqa: T201 +print("pdf index") pil_images = get_images_from_pdf(rel_doc_path, rel_img_dump_path) -print("done") # noqa: T201 +print("done") vectorstore = Path(__file__).parent / "chroma_db_multi_modal" re_vectorstore_path = vectorstore.relative_to(Path.cwd()) # Load embedding function -print("Loading embedding function") # noqa: T201 +print("Loading embedding function") embedding = OpenCLIPEmbeddings(model_name="ViT-H-14", checkpoint="laion2b_s32b_b79k") # Create chroma @@ -54,5 +54,5 @@ def get_images_from_pdf(pdf_path, img_dump_path): ) # Add images -print("Embedding images") # noqa: T201 +print("Embedding images") vectorstore_mmembd.add_images(uris=image_uris) diff --git a/templates/rag-elasticsearch/main.py b/templates/rag-elasticsearch/main.py index 8da3a6ab06743..4034ab08f26f4 100644 --- a/templates/rag-elasticsearch/main.py +++ b/templates/rag-elasticsearch/main.py @@ -14,7 +14,7 @@ "chat_history": [], } ) - print(response) # noqa: T201 + print(response) follow_up_question = "What are their objectives?" @@ -30,4 +30,4 @@ } ) - print(response) # noqa: T201 + print(response) diff --git a/templates/rag-fusion/main.py b/templates/rag-fusion/main.py index 8d6fe45edfe64..ed32889561abf 100644 --- a/templates/rag-fusion/main.py +++ b/templates/rag-fusion/main.py @@ -2,4 +2,4 @@ if __name__ == "__main__": original_query = "impact of climate change" - print(chain.invoke(original_query)) # noqa: T201 + print(chain.invoke(original_query)) diff --git a/templates/rag-gemini-multi-modal/ingest.py b/templates/rag-gemini-multi-modal/ingest.py index 98d4f701a4375..67c5f070c5b2c 100644 --- a/templates/rag-gemini-multi-modal/ingest.py +++ b/templates/rag-gemini-multi-modal/ingest.py @@ -27,14 +27,14 @@ def get_images_from_pdf(pdf_path, img_dump_path): img_dump_path = Path(__file__).parent / "docs/" rel_doc_path = doc_path.relative_to(Path.cwd()) rel_img_dump_path = img_dump_path.relative_to(Path.cwd()) -print("pdf index") # noqa: T201 +print("pdf index") pil_images = get_images_from_pdf(rel_doc_path, rel_img_dump_path) -print("done") # noqa: T201 +print("done") vectorstore = Path(__file__).parent / "chroma_db_multi_modal" re_vectorstore_path = vectorstore.relative_to(Path.cwd()) # Load embedding function -print("Loading embedding function") # noqa: T201 +print("Loading embedding function") embedding = OpenCLIPEmbeddings(model_name="ViT-H-14", checkpoint="laion2b_s32b_b79k") # Create chroma @@ -54,5 +54,5 @@ def get_images_from_pdf(pdf_path, img_dump_path): ) # Add images -print("Embedding images") # noqa: T201 +print("Embedding images") vectorstore_mmembd.add_images(uris=image_uris) diff --git a/templates/rag-google-cloud-sensitive-data-protection/main.py b/templates/rag-google-cloud-sensitive-data-protection/main.py index a69f075673417..30c6fa53c3fbb 100644 --- a/templates/rag-google-cloud-sensitive-data-protection/main.py +++ b/templates/rag-google-cloud-sensitive-data-protection/main.py @@ -6,4 +6,4 @@ "is 555-555-5555. And my email is lovely.pirate@gmail.com. Have a nice day.", "chat_history": [], } - print(chain.invoke(query)) # noqa: T201 + print(chain.invoke(query)) diff --git a/templates/rag-google-cloud-vertexai-search/main.py b/templates/rag-google-cloud-vertexai-search/main.py index 6912be7e2a659..a96c83c8bb477 100644 --- a/templates/rag-google-cloud-vertexai-search/main.py +++ b/templates/rag-google-cloud-vertexai-search/main.py @@ -2,4 +2,4 @@ if __name__ == "__main__": query = "Who is the CEO of Google Cloud?" - print(chain.invoke(query)) # noqa: T201 + print(chain.invoke(query)) diff --git a/templates/rag-multi-modal-local/ingest.py b/templates/rag-multi-modal-local/ingest.py index e1ad090af00e2..9aad0cf65687d 100644 --- a/templates/rag-multi-modal-local/ingest.py +++ b/templates/rag-multi-modal-local/ingest.py @@ -20,7 +20,7 @@ re_vectorstore_path = vectorstore.relative_to(Path.cwd()) # Load embedding function -print("Loading embedding function") # noqa: T201 +print("Loading embedding function") embedding = OpenCLIPEmbeddings(model_name="ViT-H-14", checkpoint="laion2b_s32b_b79k") # Create chroma @@ -31,5 +31,5 @@ ) # Add images -print("Embedding images") # noqa: T201 +print("Embedding images") vectorstore_mmembd.add_images(uris=image_uris) diff --git a/templates/rag-multi-modal-mv-local/ingest.py b/templates/rag-multi-modal-mv-local/ingest.py index 72b9dbf76931a..4e3f711bd2ece 100644 --- a/templates/rag-multi-modal-mv-local/ingest.py +++ b/templates/rag-multi-modal-mv-local/ingest.py @@ -63,7 +63,7 @@ def generate_img_summaries(img_base64_list): image_summaries.append(image_summarize(base64_image, prompt)) processed_images.append(base64_image) except Exception as e: - print(f"Error with image {i+1}: {e}") # noqa: T201 + print(f"Error with image {i+1}: {e}") return image_summaries, processed_images @@ -162,14 +162,14 @@ def add_documents(retriever, doc_summaries, doc_contents): # Load images doc_path = Path(__file__).parent / "docs/" rel_doc_path = doc_path.relative_to(Path.cwd()) -print("Read images") # noqa: T201 +print("Read images") pil_images = get_images(rel_doc_path) # Convert to b64 images_base_64 = [convert_to_base64(i) for i in pil_images] # Image summaries -print("Generate image summaries") # noqa: T201 +print("Generate image summaries") image_summaries, images_base_64_processed = generate_img_summaries(images_base_64) # The vectorstore to use to index the images summaries diff --git a/templates/rag-opensearch/dummy_index_setup.py b/templates/rag-opensearch/dummy_index_setup.py index e3bc286444a48..bb658adf51edd 100644 --- a/templates/rag-opensearch/dummy_index_setup.py +++ b/templates/rag-opensearch/dummy_index_setup.py @@ -41,7 +41,7 @@ response = client.indices.create(index=OPENSEARCH_INDEX_NAME, body=index_settings) -print(response) # noqa: T201 +print(response) # Insert docs @@ -57,4 +57,4 @@ response = client.index(index=OPENSEARCH_INDEX_NAME, body=document, refresh=True) - print(response) # noqa: T201 + print(response) diff --git a/templates/rag-redis-multi-modal-multi-vector/ingest.py b/templates/rag-redis-multi-modal-multi-vector/ingest.py index 00d6d0298753e..e916dd52fa7fa 100644 --- a/templates/rag-redis-multi-modal-multi-vector/ingest.py +++ b/templates/rag-redis-multi-modal-multi-vector/ingest.py @@ -62,7 +62,7 @@ def generate_img_summaries(img_base64_list): image_summaries.append(image_summarize(base64_image, prompt)) processed_images.append(base64_image) except Exception as e: - print(f"Error with image {i+1}: {e}") # noqa: T201 + print(f"Error with image {i+1}: {e}") return image_summaries, processed_images @@ -151,14 +151,14 @@ def add_documents(retriever, doc_summaries, doc_contents): doc_path = Path(__file__).parent / "docs/nvda-f3q24-investor-presentation-final.pdf" rel_doc_path = doc_path.relative_to(Path.cwd()) - print("Extract slides as images") # noqa: T201 + print("Extract slides as images") pil_images = get_images_from_pdf(rel_doc_path) # Convert to b64 images_base_64 = [convert_to_base64(i) for i in pil_images] # Generate image summaries - print("Generate image summaries") # noqa: T201 + print("Generate image summaries") image_summaries, images_base_64_processed = generate_img_summaries(images_base_64) # Create documents diff --git a/templates/rag-redis/ingest.py b/templates/rag-redis/ingest.py index b4963f6dc5df9..db6413daa1af9 100644 --- a/templates/rag-redis/ingest.py +++ b/templates/rag-redis/ingest.py @@ -17,7 +17,7 @@ def ingest_documents(): data_path = "data/" doc = [os.path.join(data_path, file) for file in os.listdir(data_path)][0] - print("Parsing 10k filing doc for NIKE", doc) # noqa: T201 + print("Parsing 10k filing doc for NIKE", doc) text_splitter = RecursiveCharacterTextSplitter( chunk_size=1500, chunk_overlap=100, add_start_index=True @@ -25,7 +25,7 @@ def ingest_documents(): loader = UnstructuredFileLoader(doc, mode="single", strategy="fast") chunks = loader.load_and_split(text_splitter) - print("Done preprocessing. Created", len(chunks), "chunks of the original pdf") # noqa: T201 + print("Done preprocessing. Created", len(chunks), "chunks of the original pdf") # Create vectorstore embedder = HuggingFaceEmbeddings(model_name=EMBED_MODEL) diff --git a/templates/rag-self-query/main.py b/templates/rag-self-query/main.py index 8385dfaa4f228..83a1dc4c6cbdb 100644 --- a/templates/rag-self-query/main.py +++ b/templates/rag-self-query/main.py @@ -14,7 +14,7 @@ "chat_history": [], } ) - print(response) # noqa: T201 + print(response) follow_up_question = "What are their objectives?" @@ -30,4 +30,4 @@ } ) - print(response) # noqa: T201 + print(response) diff --git a/templates/rag-timescale-conversation/rag_timescale_conversation/load_sample_dataset.py b/templates/rag-timescale-conversation/rag_timescale_conversation/load_sample_dataset.py index 223e76194b353..111d08b59d778 100644 --- a/templates/rag-timescale-conversation/rag_timescale_conversation/load_sample_dataset.py +++ b/templates/rag-timescale-conversation/rag_timescale_conversation/load_sample_dataset.py @@ -47,7 +47,7 @@ def load_ts_git_dataset( with open(json_file_path, "w") as json_file: json_file.write(response.text) else: - print(f"Failed to download JSON file. Status code: {response.status_code}") # noqa: T201 + print(f"Failed to download JSON file. Status code: {response.status_code}") loader = JSONLoader( file_path=json_file_path, diff --git a/templates/rag-timescale-hybrid-search-time/rag_timescale_hybrid_search_time/load_sample_dataset.py b/templates/rag-timescale-hybrid-search-time/rag_timescale_hybrid_search_time/load_sample_dataset.py index 223e76194b353..111d08b59d778 100644 --- a/templates/rag-timescale-hybrid-search-time/rag_timescale_hybrid_search_time/load_sample_dataset.py +++ b/templates/rag-timescale-hybrid-search-time/rag_timescale_hybrid_search_time/load_sample_dataset.py @@ -47,7 +47,7 @@ def load_ts_git_dataset( with open(json_file_path, "w") as json_file: json_file.write(response.text) else: - print(f"Failed to download JSON file. Status code: {response.status_code}") # noqa: T201 + print(f"Failed to download JSON file. Status code: {response.status_code}") loader = JSONLoader( file_path=json_file_path, diff --git a/templates/research-assistant/research_assistant/search/web.py b/templates/research-assistant/research_assistant/search/web.py index 5f647904ab84f..52ea08542d1ef 100644 --- a/templates/research-assistant/research_assistant/search/web.py +++ b/templates/research-assistant/research_assistant/search/web.py @@ -40,7 +40,7 @@ def scrape_text(url: str): else: return f"Failed to retrieve the webpage: Status code {response.status_code}" except Exception as e: - print(e) # noqa: T201 + print(e) return f"Failed to retrieve the webpage: {e}" diff --git a/templates/sql-llamacpp/sql_llamacpp/chain.py b/templates/sql-llamacpp/sql_llamacpp/chain.py index dd749681c66be..1dd53f69a5e50 100644 --- a/templates/sql-llamacpp/sql_llamacpp/chain.py +++ b/templates/sql-llamacpp/sql_llamacpp/chain.py @@ -19,15 +19,15 @@ ) # Check if file is present in the current directory if not os.path.exists(file_name): - print(f"'{file_name}' not found. Downloading...") # noqa: T201 + print(f"'{file_name}' not found. Downloading...") # Download the file response = requests.get(url) response.raise_for_status() # Raise an exception for HTTP errors with open(file_name, "wb") as f: f.write(response.content) - print(f"'{file_name}' has been downloaded.") # noqa: T201 + print(f"'{file_name}' has been downloaded.") else: - print(f"'{file_name}' already exists in the current directory.") # noqa: T201 + print(f"'{file_name}' already exists in the current directory.") # Add the LLM downloaded from HF model_path = file_name diff --git a/templates/sql-research-assistant/sql_research_assistant/chain.py b/templates/sql-research-assistant/sql_research_assistant/chain.py index 56f025df92776..d04e14efd8bc9 100644 --- a/templates/sql-research-assistant/sql_research_assistant/chain.py +++ b/templates/sql-research-assistant/sql_research_assistant/chain.py @@ -17,6 +17,6 @@ class InputType(BaseModel): if __name__ == "__main__": - print( # noqa: T201 + print( chain.invoke({"question": "who is typically older: point guards or centers?"}) ) diff --git a/templates/sql-research-assistant/sql_research_assistant/search/web.py b/templates/sql-research-assistant/sql_research_assistant/search/web.py index d1ac84c941c08..cb8b8aa41aa12 100644 --- a/templates/sql-research-assistant/sql_research_assistant/search/web.py +++ b/templates/sql-research-assistant/sql_research_assistant/search/web.py @@ -40,7 +40,7 @@ def scrape_text(url: str): else: return f"Failed to retrieve the webpage: Status code {response.status_code}" except Exception as e: - print(e) # noqa: T201 + print(e) return f"Failed to retrieve the webpage: {e}" diff --git a/templates/xml-agent/main.py b/templates/xml-agent/main.py index 55786914da330..02647eb845188 100644 --- a/templates/xml-agent/main.py +++ b/templates/xml-agent/main.py @@ -2,4 +2,4 @@ if __name__ == "__main__": question = "who won the womens world cup in 2023?" - print(agent_executor.invoke({"question": question, "chat_history": []})) # noqa: T201 + print(agent_executor.invoke({"question": question, "chat_history": []}))