mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-12 15:59:56 +00:00
langchain[patch]: CI add lint rule for community imports (#21618)
Add a rule to check for imports from community in global scope
This commit is contained in:
parent
4378fbbef0
commit
b923951062
@ -27,6 +27,12 @@ langchain.(pydantic_v1|utils|schema|load|callbacks|env|_api|storage|llms|docstor
|
|||||||
# make sure not importing from langchain_experimental
|
# make sure not importing from langchain_experimental
|
||||||
git --no-pager grep '^from langchain_experimental\.' . && errors=$((errors+1))
|
git --no-pager grep '^from langchain_experimental\.' . && errors=$((errors+1))
|
||||||
|
|
||||||
|
# Add a basic lint rule to prevent imports from the global namespaces of langchain_community
|
||||||
|
# This lint rule won't catch imports from local scope.
|
||||||
|
# We can't add that rule without a more complex script to ignore imports from inside
|
||||||
|
# a if TYPE_CHECKING block.
|
||||||
|
git grep '^from langchain_community' | grep -vE '# ignore: community-import' && errors=$((errors+1))
|
||||||
|
|
||||||
# Decide on an exit status based on the errors
|
# Decide on an exit status based on the errors
|
||||||
if [ "$errors" -gt 0 ]; then
|
if [ "$errors" -gt 0 ]; then
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -12,7 +12,9 @@ pytest.importorskip(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
from langchain_community.llms.openai import OpenAI as CommunityOpenAI # noqa: E402
|
from langchain_community.llms.openai import ( # noqa: E402, # ignore: community-import
|
||||||
|
OpenAI as CommunityOpenAI,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class NotSerializable:
|
class NotSerializable:
|
||||||
|
Loading…
Reference in New Issue
Block a user