From 77ec77edcd82ea8ad82e49b3f07cc12ab4695cdc Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Mon, 28 Jul 2025 10:00:13 -0400 Subject: [PATCH 1/7] correct PHONY --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a3ce56bbea3..ae3f322711f 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all clean help docs_build docs_clean docs_linkcheck api_docs_build api_docs_clean api_docs_linkcheck spell_check spell_fix lint lint_package lint_tests format format_diff +.PHONY: all help clean docs_build docs_clean docs_linkcheck api_docs_build api_docs_quick_preview api_docs_clean api_docs_linkcheck spell_check spell_fix lint lint_package lint_tests format format_diff update-package-downloads .EXPORT_ALL_VARIABLES: UV_FROZEN = true @@ -100,7 +100,7 @@ lint lint_package lint_tests: uv run --group lint ruff check docs cookbook uv run --group lint ruff format docs cookbook cookbook --diff git --no-pager grep 'from langchain import' docs cookbook | grep -vE 'from langchain import (hub)' && echo "Error: no importing langchain from root in docs, except for hub" && exit 1 || exit 0 - + git --no-pager grep 'api.python.langchain.com' -- docs/docs ':!docs/docs/additional_resources/arxiv_references.mdx' ':!docs/docs/integrations/document_loaders/sitemap.ipynb' || exit 0 && \ echo "Error: you should link python.langchain.com/api_reference, not api.python.langchain.com in the docs" && \ exit 1 From 80a0d494a1773330858e2cb38da450d6141e39fa Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Mon, 28 Jul 2025 10:00:20 -0400 Subject: [PATCH 2/7] update `help` --- libs/standard-tests/Makefile | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/libs/standard-tests/Makefile b/libs/standard-tests/Makefile index 4e1d8bae5d0..c50b6064f4f 100644 --- a/libs/standard-tests/Makefile +++ b/libs/standard-tests/Makefile @@ -56,9 +56,20 @@ check_imports: $(shell find langchain_tests -name '*.py') help: @echo '----' - @echo 'check_imports - check imports' - @echo 'format - run code formatters' - @echo 'lint - run linters' + @echo 'Available targets:' + @echo '----' @echo 'test - run unit tests' @echo 'tests - run unit tests' + @echo 'integration_test - run integration tests' + @echo 'integration_tests - run integration tests' @echo 'test TEST_FILE= - run all tests in file' + @echo 'lint - run linters' + @echo 'lint_diff - run linters on changed files' + @echo 'lint_package - run linters on package files' + @echo 'lint_tests - run linters on test files' + @echo 'format - run code formatters' + @echo 'format_diff - run formatters on changed files' + @echo 'spell_check - check spelling' + @echo 'spell_fix - fix spelling issues' + @echo 'check_imports - check imports' + @echo 'help - show this help message' From 083a99b102697dd2122920928a4beb9bdcd4fb1b Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Mon, 28 Jul 2025 10:23:14 -0400 Subject: [PATCH 3/7] fix: remove unused PHONY target --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ae3f322711f..7fc2b691d1c 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all help clean docs_build docs_clean docs_linkcheck api_docs_build api_docs_quick_preview api_docs_clean api_docs_linkcheck spell_check spell_fix lint lint_package lint_tests format format_diff update-package-downloads +.PHONY: help clean docs_build docs_clean docs_linkcheck api_docs_build api_docs_quick_preview api_docs_clean api_docs_linkcheck spell_check spell_fix lint lint_package lint_tests format format_diff update-package-downloads .EXPORT_ALL_VARIABLES: UV_FROZEN = true From 0bbfdaf3d5638c40ac10e198eea24f9ceaba4e6e Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Mon, 28 Jul 2025 10:23:42 -0400 Subject: [PATCH 4/7] `make test` -> `make unit_test` --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- .github/copilot-instructions.md | 2 +- .github/workflows/_test.yml | 4 ++-- .github/workflows/_test_pydantic.yml | 4 ++-- docs/docs/contributing/how_to/code/setup.mdx | 6 +++--- docs/docs/contributing/how_to/testing.mdx | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index b99fdd92cc3..aa5d8dbcf0a 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -22,7 +22,7 @@ Thank you for contributing to LangChain! Follow these steps to mark your pull re 1. A test for the integration, preferably unit tests that do not rely on network access, 2. An example notebook showing its use. It lives in `docs/docs/integrations` directory. -- [ ] **Lint and test**: Run `make format`, `make lint` and `make test` from the root of the package(s) you've modified. **We will not consider a PR unless these three are passing in CI.** See [contribution guidelines](https://python.langchain.com/docs/contributing/) for more. +- [ ] **Lint and test**: Run `make format`, `make lint` and `make unit_test` from the root of the package(s) you've modified. **We will not consider a PR unless these three are passing in CI.** See [contribution guidelines](https://python.langchain.com/docs/contributing/) for more. Additional guidelines: diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index b12f23edb2e..bb53e16bbcb 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -239,7 +239,7 @@ uv lock ```bash # Run unit tests (no network) -make test +make unit_test # Don't run integration tests, as API keys must be set diff --git a/.github/workflows/_test.yml b/.github/workflows/_test.yml index 0deb2b53592..8a0426122b1 100644 --- a/.github/workflows/_test.yml +++ b/.github/workflows/_test.yml @@ -46,7 +46,7 @@ jobs: - name: '🧪 Run Core Unit Tests' shell: bash run: | - make test + make unit_test - name: '🔍 Calculate Minimum Dependency Versions' working-directory: ${{ inputs.working-directory }} @@ -79,4 +79,4 @@ jobs: # grep will exit non-zero if the target message isn't found, # and `set -e` above will cause the step to fail. echo "$STATUS" | grep 'nothing to commit, working tree clean' - + diff --git a/.github/workflows/_test_pydantic.yml b/.github/workflows/_test_pydantic.yml index a6b6b183755..0394dd6958b 100644 --- a/.github/workflows/_test_pydantic.yml +++ b/.github/workflows/_test_pydantic.yml @@ -52,7 +52,7 @@ jobs: - name: '🧪 Run Core Tests' shell: bash run: | - make test + make unit_test - name: '🧹 Verify Clean Working Directory' shell: bash @@ -64,4 +64,4 @@ jobs: # grep will exit non-zero if the target message isn't found, # and `set -e` above will cause the step to fail. - echo "$STATUS" | grep 'nothing to commit, working tree clean' \ No newline at end of file + echo "$STATUS" | grep 'nothing to commit, working tree clean' diff --git a/docs/docs/contributing/how_to/code/setup.mdx b/docs/docs/contributing/how_to/code/setup.mdx index 9ba53d52242..6bd390da428 100644 --- a/docs/docs/contributing/how_to/code/setup.mdx +++ b/docs/docs/contributing/how_to/code/setup.mdx @@ -48,7 +48,7 @@ uv sync Then verify dependency installation: ```bash -make test +make unit_test ``` ## Testing @@ -61,7 +61,7 @@ If you add new logic, please add a unit test. To run unit tests: ```bash -make test +make unit_test ``` There are also [integration tests and code-coverage](../testing.mdx) available. @@ -72,7 +72,7 @@ If you are only developing `langchain_core`, you can simply install the dependen ```bash cd libs/core -make test +make unit_test ``` ## Formatting and linting diff --git a/docs/docs/contributing/how_to/testing.mdx b/docs/docs/contributing/how_to/testing.mdx index cc5a1155c32..b7e6659ecfc 100644 --- a/docs/docs/contributing/how_to/testing.mdx +++ b/docs/docs/contributing/how_to/testing.mdx @@ -24,13 +24,13 @@ poetry install --with test To run unit tests: ```bash -make test +make unit_test ``` To run a specific test: ```bash -TEST_FILE=tests/unit_tests/test_imports.py make test +TEST_FILE=tests/unit_tests/test_imports.py make unit_test ``` ## Integration tests From c95a1e26de8954331331378218026be119b51f9f Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Mon, 28 Jul 2025 10:23:49 -0400 Subject: [PATCH 5/7] . --- libs/langchain/Makefile | 1 - libs/langchain_v1/Makefile | 1 - 2 files changed, 2 deletions(-) diff --git a/libs/langchain/Makefile b/libs/langchain/Makefile index 3a445f2a35d..a0cb16f21ec 100644 --- a/libs/langchain/Makefile +++ b/libs/langchain/Makefile @@ -89,7 +89,6 @@ help: @echo '-- TESTS --' @echo 'coverage - run unit tests and generate coverage report' @echo 'test - run unit tests' - @echo 'tests - run unit tests (alias for "make test")' @echo 'test TEST_FILE= - run all tests in file' @echo 'extended_tests - run only extended unit tests' @echo 'test_watch - run unit tests in watch mode' diff --git a/libs/langchain_v1/Makefile b/libs/langchain_v1/Makefile index 885a56cf7b6..d56c646f94b 100644 --- a/libs/langchain_v1/Makefile +++ b/libs/langchain_v1/Makefile @@ -88,7 +88,6 @@ help: @echo '-- TESTS --' @echo 'coverage - run unit tests and generate coverage report' @echo 'test - run unit tests' - @echo 'tests - run unit tests (alias for "make test")' @echo 'test TEST_FILE= - run all tests in file' @echo 'extended_tests - run only extended unit tests' @echo 'test_watch - run unit tests in watch mode' From 6d2fc87584bfc4b82ef077b0cb7b78e8670ef6b9 Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Mon, 28 Jul 2025 10:32:02 -0400 Subject: [PATCH 6/7] feat: update all check_imports docstrings --- libs/partners/anthropic/scripts/check_imports.py | 14 ++++++++++++++ libs/partners/chroma/scripts/check_imports.py | 14 +++++++++++++- libs/partners/deepseek/scripts/check_imports.py | 14 ++++++++++++++ libs/partners/exa/scripts/check_imports.py | 14 ++++++++++++++ libs/partners/fireworks/scripts/check_imports.py | 14 ++++++++++++++ libs/partners/groq/scripts/check_imports.py | 14 ++++++++++++++ libs/partners/huggingface/scripts/check_imports.py | 14 ++++++++++++++ libs/partners/mistralai/scripts/check_imports.py | 14 ++++++++++++++ libs/partners/nomic/scripts/check_imports.py | 14 ++++++++++++++ libs/partners/ollama/scripts/check_imports.py | 14 +++++++++++++- libs/partners/openai/scripts/check_imports.py | 14 ++++++++++++++ libs/partners/perplexity/scripts/check_imports.py | 14 ++++++++++++++ libs/partners/prompty/scripts/check_imports.py | 14 ++++++++++++++ libs/partners/qdrant/scripts/check_imports.py | 14 ++++++++++++++ libs/partners/xai/scripts/check_imports.py | 14 +++++++++++++- libs/standard-tests/scripts/check_imports.py | 14 ++++++++++++++ 16 files changed, 221 insertions(+), 3 deletions(-) diff --git a/libs/partners/anthropic/scripts/check_imports.py b/libs/partners/anthropic/scripts/check_imports.py index 58a460c1493..f9b0d8cf231 100644 --- a/libs/partners/anthropic/scripts/check_imports.py +++ b/libs/partners/anthropic/scripts/check_imports.py @@ -1,3 +1,17 @@ +"""Import validation script. + +Validates that Python files can be imported without errors by dynamically +loading each file as a module. This is crucial for ensuring: + +1. All dependencies are properly installed and available +2. Module-level code executes without syntax or runtime errors +3. Import statements are valid and don't create circular dependencies +4. The code structure follows Python import conventions + +Typically run in CI/CD to catch import problems before deployment, ensuring that +all modules can be successfully imported in production environments. +""" + import sys import traceback from importlib.machinery import SourceFileLoader diff --git a/libs/partners/chroma/scripts/check_imports.py b/libs/partners/chroma/scripts/check_imports.py index b850913e53e..dc1f613d4da 100644 --- a/libs/partners/chroma/scripts/check_imports.py +++ b/libs/partners/chroma/scripts/check_imports.py @@ -1,4 +1,16 @@ -"""This module checks if the given python files can be imported without error.""" +"""Import validation script. + +Validates that Python files can be imported without errors by dynamically +loading each file as a module. This is crucial for ensuring: + +1. All dependencies are properly installed and available +2. Module-level code executes without syntax or runtime errors +3. Import statements are valid and don't create circular dependencies +4. The code structure follows Python import conventions + +Typically run in CI/CD to catch import problems before deployment, ensuring that +all modules can be successfully imported in production environments. +""" import sys import traceback diff --git a/libs/partners/deepseek/scripts/check_imports.py b/libs/partners/deepseek/scripts/check_imports.py index 724644fce53..dc1f613d4da 100644 --- a/libs/partners/deepseek/scripts/check_imports.py +++ b/libs/partners/deepseek/scripts/check_imports.py @@ -1,3 +1,17 @@ +"""Import validation script. + +Validates that Python files can be imported without errors by dynamically +loading each file as a module. This is crucial for ensuring: + +1. All dependencies are properly installed and available +2. Module-level code executes without syntax or runtime errors +3. Import statements are valid and don't create circular dependencies +4. The code structure follows Python import conventions + +Typically run in CI/CD to catch import problems before deployment, ensuring that +all modules can be successfully imported in production environments. +""" + import sys import traceback from importlib.machinery import SourceFileLoader diff --git a/libs/partners/exa/scripts/check_imports.py b/libs/partners/exa/scripts/check_imports.py index 58a460c1493..f9b0d8cf231 100644 --- a/libs/partners/exa/scripts/check_imports.py +++ b/libs/partners/exa/scripts/check_imports.py @@ -1,3 +1,17 @@ +"""Import validation script. + +Validates that Python files can be imported without errors by dynamically +loading each file as a module. This is crucial for ensuring: + +1. All dependencies are properly installed and available +2. Module-level code executes without syntax or runtime errors +3. Import statements are valid and don't create circular dependencies +4. The code structure follows Python import conventions + +Typically run in CI/CD to catch import problems before deployment, ensuring that +all modules can be successfully imported in production environments. +""" + import sys import traceback from importlib.machinery import SourceFileLoader diff --git a/libs/partners/fireworks/scripts/check_imports.py b/libs/partners/fireworks/scripts/check_imports.py index 58a460c1493..f9b0d8cf231 100644 --- a/libs/partners/fireworks/scripts/check_imports.py +++ b/libs/partners/fireworks/scripts/check_imports.py @@ -1,3 +1,17 @@ +"""Import validation script. + +Validates that Python files can be imported without errors by dynamically +loading each file as a module. This is crucial for ensuring: + +1. All dependencies are properly installed and available +2. Module-level code executes without syntax or runtime errors +3. Import statements are valid and don't create circular dependencies +4. The code structure follows Python import conventions + +Typically run in CI/CD to catch import problems before deployment, ensuring that +all modules can be successfully imported in production environments. +""" + import sys import traceback from importlib.machinery import SourceFileLoader diff --git a/libs/partners/groq/scripts/check_imports.py b/libs/partners/groq/scripts/check_imports.py index ec3fc6e95f5..2fdb373949c 100644 --- a/libs/partners/groq/scripts/check_imports.py +++ b/libs/partners/groq/scripts/check_imports.py @@ -1,3 +1,17 @@ +"""Import validation script. + +Validates that Python files can be imported without errors by dynamically +loading each file as a module. This is crucial for ensuring: + +1. All dependencies are properly installed and available +2. Module-level code executes without syntax or runtime errors +3. Import statements are valid and don't create circular dependencies +4. The code structure follows Python import conventions + +Typically run in CI/CD to catch import problems before deployment, ensuring that +all modules can be successfully imported in production environments. +""" + import sys import traceback from importlib.machinery import SourceFileLoader diff --git a/libs/partners/huggingface/scripts/check_imports.py b/libs/partners/huggingface/scripts/check_imports.py index 58a460c1493..f9b0d8cf231 100644 --- a/libs/partners/huggingface/scripts/check_imports.py +++ b/libs/partners/huggingface/scripts/check_imports.py @@ -1,3 +1,17 @@ +"""Import validation script. + +Validates that Python files can be imported without errors by dynamically +loading each file as a module. This is crucial for ensuring: + +1. All dependencies are properly installed and available +2. Module-level code executes without syntax or runtime errors +3. Import statements are valid and don't create circular dependencies +4. The code structure follows Python import conventions + +Typically run in CI/CD to catch import problems before deployment, ensuring that +all modules can be successfully imported in production environments. +""" + import sys import traceback from importlib.machinery import SourceFileLoader diff --git a/libs/partners/mistralai/scripts/check_imports.py b/libs/partners/mistralai/scripts/check_imports.py index 58a460c1493..f9b0d8cf231 100644 --- a/libs/partners/mistralai/scripts/check_imports.py +++ b/libs/partners/mistralai/scripts/check_imports.py @@ -1,3 +1,17 @@ +"""Import validation script. + +Validates that Python files can be imported without errors by dynamically +loading each file as a module. This is crucial for ensuring: + +1. All dependencies are properly installed and available +2. Module-level code executes without syntax or runtime errors +3. Import statements are valid and don't create circular dependencies +4. The code structure follows Python import conventions + +Typically run in CI/CD to catch import problems before deployment, ensuring that +all modules can be successfully imported in production environments. +""" + import sys import traceback from importlib.machinery import SourceFileLoader diff --git a/libs/partners/nomic/scripts/check_imports.py b/libs/partners/nomic/scripts/check_imports.py index 58a460c1493..f9b0d8cf231 100644 --- a/libs/partners/nomic/scripts/check_imports.py +++ b/libs/partners/nomic/scripts/check_imports.py @@ -1,3 +1,17 @@ +"""Import validation script. + +Validates that Python files can be imported without errors by dynamically +loading each file as a module. This is crucial for ensuring: + +1. All dependencies are properly installed and available +2. Module-level code executes without syntax or runtime errors +3. Import statements are valid and don't create circular dependencies +4. The code structure follows Python import conventions + +Typically run in CI/CD to catch import problems before deployment, ensuring that +all modules can be successfully imported in production environments. +""" + import sys import traceback from importlib.machinery import SourceFileLoader diff --git a/libs/partners/ollama/scripts/check_imports.py b/libs/partners/ollama/scripts/check_imports.py index 64b1b383092..f9b0d8cf231 100644 --- a/libs/partners/ollama/scripts/check_imports.py +++ b/libs/partners/ollama/scripts/check_imports.py @@ -1,4 +1,16 @@ -"""load multiple Python files specified as command line arguments.""" +"""Import validation script. + +Validates that Python files can be imported without errors by dynamically +loading each file as a module. This is crucial for ensuring: + +1. All dependencies are properly installed and available +2. Module-level code executes without syntax or runtime errors +3. Import statements are valid and don't create circular dependencies +4. The code structure follows Python import conventions + +Typically run in CI/CD to catch import problems before deployment, ensuring that +all modules can be successfully imported in production environments. +""" import sys import traceback diff --git a/libs/partners/openai/scripts/check_imports.py b/libs/partners/openai/scripts/check_imports.py index 58a460c1493..f9b0d8cf231 100644 --- a/libs/partners/openai/scripts/check_imports.py +++ b/libs/partners/openai/scripts/check_imports.py @@ -1,3 +1,17 @@ +"""Import validation script. + +Validates that Python files can be imported without errors by dynamically +loading each file as a module. This is crucial for ensuring: + +1. All dependencies are properly installed and available +2. Module-level code executes without syntax or runtime errors +3. Import statements are valid and don't create circular dependencies +4. The code structure follows Python import conventions + +Typically run in CI/CD to catch import problems before deployment, ensuring that +all modules can be successfully imported in production environments. +""" + import sys import traceback from importlib.machinery import SourceFileLoader diff --git a/libs/partners/perplexity/scripts/check_imports.py b/libs/partners/perplexity/scripts/check_imports.py index 58a460c1493..f9b0d8cf231 100644 --- a/libs/partners/perplexity/scripts/check_imports.py +++ b/libs/partners/perplexity/scripts/check_imports.py @@ -1,3 +1,17 @@ +"""Import validation script. + +Validates that Python files can be imported without errors by dynamically +loading each file as a module. This is crucial for ensuring: + +1. All dependencies are properly installed and available +2. Module-level code executes without syntax or runtime errors +3. Import statements are valid and don't create circular dependencies +4. The code structure follows Python import conventions + +Typically run in CI/CD to catch import problems before deployment, ensuring that +all modules can be successfully imported in production environments. +""" + import sys import traceback from importlib.machinery import SourceFileLoader diff --git a/libs/partners/prompty/scripts/check_imports.py b/libs/partners/prompty/scripts/check_imports.py index ec3fc6e95f5..2fdb373949c 100644 --- a/libs/partners/prompty/scripts/check_imports.py +++ b/libs/partners/prompty/scripts/check_imports.py @@ -1,3 +1,17 @@ +"""Import validation script. + +Validates that Python files can be imported without errors by dynamically +loading each file as a module. This is crucial for ensuring: + +1. All dependencies are properly installed and available +2. Module-level code executes without syntax or runtime errors +3. Import statements are valid and don't create circular dependencies +4. The code structure follows Python import conventions + +Typically run in CI/CD to catch import problems before deployment, ensuring that +all modules can be successfully imported in production environments. +""" + import sys import traceback from importlib.machinery import SourceFileLoader diff --git a/libs/partners/qdrant/scripts/check_imports.py b/libs/partners/qdrant/scripts/check_imports.py index ec3fc6e95f5..2fdb373949c 100644 --- a/libs/partners/qdrant/scripts/check_imports.py +++ b/libs/partners/qdrant/scripts/check_imports.py @@ -1,3 +1,17 @@ +"""Import validation script. + +Validates that Python files can be imported without errors by dynamically +loading each file as a module. This is crucial for ensuring: + +1. All dependencies are properly installed and available +2. Module-level code executes without syntax or runtime errors +3. Import statements are valid and don't create circular dependencies +4. The code structure follows Python import conventions + +Typically run in CI/CD to catch import problems before deployment, ensuring that +all modules can be successfully imported in production environments. +""" + import sys import traceback from importlib.machinery import SourceFileLoader diff --git a/libs/partners/xai/scripts/check_imports.py b/libs/partners/xai/scripts/check_imports.py index 620bc296aa8..00c42b1d9ee 100644 --- a/libs/partners/xai/scripts/check_imports.py +++ b/libs/partners/xai/scripts/check_imports.py @@ -1,4 +1,16 @@ -"""This module checks if the given python files can be imported without error.""" +"""Import validation script. + +Validates that Python files can be imported without errors by dynamically +loading each file as a module. This is crucial for ensuring: + +1. All dependencies are properly installed and available +2. Module-level code executes without syntax or runtime errors +3. Import statements are valid and don't create circular dependencies +4. The code structure follows Python import conventions + +Typically run in CI/CD to catch import problems before deployment, ensuring that +all modules can be successfully imported in production environments. +""" import sys import traceback diff --git a/libs/standard-tests/scripts/check_imports.py b/libs/standard-tests/scripts/check_imports.py index 825bea5b487..864072e654a 100644 --- a/libs/standard-tests/scripts/check_imports.py +++ b/libs/standard-tests/scripts/check_imports.py @@ -1,3 +1,17 @@ +"""Import validation script. + +Validates that Python files can be imported without errors by dynamically +loading each file as a module. This is crucial for ensuring: + +1. All dependencies are properly installed and available +2. Module-level code executes without syntax or runtime errors +3. Import statements are valid and don't create circular dependencies +4. The code structure follows Python import conventions + +Typically run in CI/CD to catch import problems before deployment, ensuring that +all modules can be successfully imported in production environments. +""" + import random import string import sys From 881a2e8cc059db9552ad7b4df431ba0a4cb63f0b Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Mon, 28 Jul 2025 16:25:35 -0400 Subject: [PATCH 7/7] standard-tests --- libs/standard-tests/Makefile | 48 +++++++++++++++--------------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/libs/standard-tests/Makefile b/libs/standard-tests/Makefile index c50b6064f4f..132751d52e6 100644 --- a/libs/standard-tests/Makefile +++ b/libs/standard-tests/Makefile @@ -1,7 +1,9 @@ -.PHONY: all format lint test tests integration_tests help extended_tests +.PHONY: format lint test tests unit_test unit_tests integration_tests help extended_tests format_diff lint_diff lint_package lint_tests spell_check spell_fix check_imports -# Default target executed when no arguments are given to make. -all: help +## help: Show this help info. +help: Makefile + @printf "\n\033[1mUsage: make ...\033[0m\n\n\033[1mTargets:\033[0m\n\n" + @sed -n 's/^## //p' $< | awk -F':' '{printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | sort | sed -e 's/^/ /' .EXPORT_ALL_VARIABLES: UV_FROZEN = true @@ -12,9 +14,14 @@ INTEGRATION_TEST_FILE ?= tests/integration_tests/ integration_test integration_tests: TEST_FILE=$(INTEGRATION_TEST_FILE) -test tests: +## test: Run both unit and integration tests +test tests: unit_test integration_tests + +## unit_test: Run only unit tests +unit_test unit_tests: uv run --group test pytest $(TEST_FILE) +## integration_test: Run only integration tests integration_test integration_tests: uv run --group test --group test_integration pytest $(TEST_FILE) @@ -23,7 +30,6 @@ integration_test integration_tests: # LINTING AND FORMATTING ###################### -# Define a variable for Python and notebook files. PYTHON_FILES=. MYPY_CACHE=.mypy_cache lint format: PYTHON_FILES=. @@ -32,44 +38,30 @@ lint_package: PYTHON_FILES=langchain_tests lint_tests: PYTHON_FILES=tests lint_tests: MYPY_CACHE=.mypy_cache_test +## lint: Run linters on all files +## lint_diff: Run linters on changed files only +## lint_package: Run linters on package files only +## lint_tests: Run linters on test files only lint lint_diff lint_package lint_tests: [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check $(PYTHON_FILES) [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES) --diff [ "$(PYTHON_FILES)" = "" ] || mkdir -p $(MYPY_CACHE) && uv run --all-groups mypy $(PYTHON_FILES) --cache-dir $(MYPY_CACHE) +## format: Format all code +## format_diff: Format changed files only format format_diff: [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES) [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --fix $(PYTHON_FILES) +## spell_check: Check spelling in code spell_check: uv run --all-groups codespell --toml pyproject.toml +## spell_fix: Apply spelling fixes in code spell_fix: uv run --all-groups codespell --toml pyproject.toml -w +## check_imports: Check import statements check_imports: $(shell find langchain_tests -name '*.py') uv run --all-groups python ./scripts/check_imports.py $^ -###################### -# HELP -###################### - -help: - @echo '----' - @echo 'Available targets:' - @echo '----' - @echo 'test - run unit tests' - @echo 'tests - run unit tests' - @echo 'integration_test - run integration tests' - @echo 'integration_tests - run integration tests' - @echo 'test TEST_FILE= - run all tests in file' - @echo 'lint - run linters' - @echo 'lint_diff - run linters on changed files' - @echo 'lint_package - run linters on package files' - @echo 'lint_tests - run linters on test files' - @echo 'format - run code formatters' - @echo 'format_diff - run formatters on changed files' - @echo 'spell_check - check spelling' - @echo 'spell_fix - fix spelling issues' - @echo 'check_imports - check imports' - @echo 'help - show this help message'