diff --git a/.github/workflows/_pydantic_compatibility.yml b/.github/workflows/_pydantic_compatibility.yml index 680d961c30549..72f47cdfbab4d 100644 --- a/.github/workflows/_pydantic_compatibility.yml +++ b/.github/workflows/_pydantic_compatibility.yml @@ -44,6 +44,10 @@ jobs: shell: bash run: poetry install + - name: Check imports with base dependencies + shell: bash + run: make check_imports + - name: Install langchain editable working-directory: ${{ inputs.working-directory }} if: ${{ inputs.langchain-location }} diff --git a/libs/core/Makefile b/libs/core/Makefile index 6ab8c21d5adf0..b5a20ce0619db 100644 --- a/libs/core/Makefile +++ b/libs/core/Makefile @@ -15,6 +15,10 @@ tests: test_watch: poetry run ptw --snapshot-update --now . -- -vv -x tests/unit_tests +check_imports: langchain_core/**/*.py + for f in $^ ; do \ + python -c "from importlib.machinery import SourceFileLoader; SourceFileLoader('x', '$$f').load_module()" ; \ + done ###################### # LINTING AND FORMATTING @@ -27,7 +31,7 @@ lint_diff format_diff: PYTHON_FILES=$(shell git diff --relative=libs/experimenta lint lint_diff: ./scripts/check_pydantic.sh . - ./scripts/check_imports.sh + ./scripts/lint_imports.sh poetry run ruff . [ "$(PYTHON_FILES)" = "" ] || poetry run ruff format $(PYTHON_FILES) --diff [ "$(PYTHON_FILES)" = "" ] || poetry run ruff --select I $(PYTHON_FILES) diff --git a/libs/core/scripts/check_imports.sh b/libs/core/scripts/lint_imports.sh similarity index 100% rename from libs/core/scripts/check_imports.sh rename to libs/core/scripts/lint_imports.sh diff --git a/libs/langchain/Makefile b/libs/langchain/Makefile index 3c6e8ed1840a0..713ff9d076fc1 100644 --- a/libs/langchain/Makefile +++ b/libs/langchain/Makefile @@ -40,6 +40,11 @@ docker_tests: docker build -t my-langchain-image:test . docker run --rm my-langchain-image:test +check_imports: langchain/**/*.py + for f in $^ ; do \ + python -c "from importlib.machinery import SourceFileLoader; SourceFileLoader('x', '$$f').load_module()" ; \ + done + ###################### # LINTING AND FORMATTING ###################### @@ -51,7 +56,7 @@ lint_diff format_diff: PYTHON_FILES=$(shell git diff --relative=libs/langchain - lint lint_diff: ./scripts/check_pydantic.sh . - ./scripts/check_imports.sh + ./scripts/lint_imports.sh poetry run ruff . [ "$(PYTHON_FILES)" = "" ] || poetry run ruff format $(PYTHON_FILES) --diff [ "$(PYTHON_FILES)" = "" ] || poetry run ruff --select I $(PYTHON_FILES) diff --git a/libs/langchain/scripts/check_imports.sh b/libs/langchain/scripts/lint_imports.sh similarity index 100% rename from libs/langchain/scripts/check_imports.sh rename to libs/langchain/scripts/lint_imports.sh