mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-05 22:53:30 +00:00
add checks on basic base modules (#10693)
This commit is contained in:
parent
5442d2b1fa
commit
2c957de2fc
@ -1,5 +1,5 @@
|
||||
---
|
||||
name: Imports
|
||||
name: Documentation Lint
|
||||
|
||||
on:
|
||||
push:
|
||||
@ -18,6 +18,5 @@ jobs:
|
||||
- name: Run import check
|
||||
run: |
|
||||
# We should not encourage imports directly from main init file
|
||||
# Expect for __version__ and hub
|
||||
# And of course expect for this file
|
||||
git grep 'from langchain import' | grep -vE 'from langchain import (__version__|hub)' | grep -v '.github/workflows/check-imports.yml' && exit 1 || exit 0
|
||||
# Expect for hub
|
||||
git grep 'from langchain import' docs | grep -vE 'from langchain import (hub)' && exit 1 || exit 0
|
@ -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)
|
||||
|
14
libs/langchain/scripts/check_imports.sh
Executable file
14
libs/langchain/scripts/check_imports.sh
Executable 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
|
Loading…
Reference in New Issue
Block a user