add checks on basic base modules (#10693)

This commit is contained in:
Harrison Chase
2023-09-16 22:08:11 -07:00
committed by GitHub
parent 5442d2b1fa
commit 2c957de2fc
3 changed files with 18 additions and 4 deletions

View File

@@ -77,6 +77,7 @@ lint_diff format_diff: PYTHON_FILES=$(shell git diff --relative=libs/langchain -
lint lint_diff:
./scripts/check_pydantic.sh .
./scripts/check_imports.sh
poetry run ruff .
poetry run black $(PYTHON_FILES) --check
poetry run mypy $(PYTHON_FILES)

View File

@@ -0,0 +1,14 @@
#!/bin/bash
set -eu
git grep 'from langchain import' langchain | grep -vE 'from langchain import (__version__|hub)' && exit 1 || exit 0
# Pydantic bridge should not import from any other module
git grep 'from langchain ' langchain/pydantic_v1 && exit 1 || exit 0
# load should not import from anything except itself and pydantic_v1
git grep 'from langchain' langchain/load | grep -vE 'from langchain.(pydantic_v1)' && exit 1 || exit 0
# utils should not import from anything except itself and pydantic_v1
git grep 'from langchain' langchain/utils | grep -vE 'from langchain.(pydantic_v1|utils)' && exit 1 || exit 0