mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-25 16:13:25 +00:00
community[patch]: Fix remaining __inits__ in community (#22037)
Fixes the __init__ files in community to use __all__ which is statically defined.
This commit is contained in:
parent
b7d08bf764
commit
36813d2f00
@ -168,6 +168,3 @@ def __getattr__(name: str) -> Any:
|
||||
module = importlib.import_module(_module_lookup[name])
|
||||
return getattr(module, name)
|
||||
raise AttributeError(f"module {__name__} has no attribute {name}")
|
||||
|
||||
|
||||
__all__ = list(_module_lookup.keys())
|
||||
|
@ -81,6 +81,3 @@ def __getattr__(name: str) -> Any:
|
||||
module = importlib.import_module(_module_lookup[name])
|
||||
return getattr(module, name)
|
||||
raise AttributeError(f"module {__name__} has no attribute {name}")
|
||||
|
||||
|
||||
__all__ = list(_module_lookup.keys())
|
||||
|
@ -137,6 +137,3 @@ def __getattr__(name: str) -> Any:
|
||||
module = importlib.import_module(_module_lookup[name])
|
||||
return getattr(module, name)
|
||||
raise AttributeError(f"module {__name__} has no attribute {name}")
|
||||
|
||||
|
||||
__all__ = list(_module_lookup.keys())
|
||||
|
@ -29,8 +29,6 @@ if TYPE_CHECKING:
|
||||
Wikipedia,
|
||||
)
|
||||
|
||||
__all__ = ["DocstoreFn", "InMemoryDocstore", "Wikipedia"]
|
||||
|
||||
_module_lookup = {
|
||||
"DocstoreFn": "langchain_community.docstore.arbitrary_fn",
|
||||
"InMemoryDocstore": "langchain_community.docstore.in_memory",
|
||||
@ -45,4 +43,4 @@ def __getattr__(name: str) -> Any:
|
||||
raise AttributeError(f"module {__name__} has no attribute {name}")
|
||||
|
||||
|
||||
__all__ = list(_module_lookup.keys())
|
||||
__all__ = ["DocstoreFn", "InMemoryDocstore", "Wikipedia"]
|
||||
|
@ -6,7 +6,7 @@ if TYPE_CHECKING:
|
||||
FlashrankRerank,
|
||||
)
|
||||
from langchain_community.document_compressors.jina_rerank import (
|
||||
JinaRerank, # noqa: F401
|
||||
JinaRerank,
|
||||
)
|
||||
from langchain_community.document_compressors.llmlingua_filter import (
|
||||
LLMLinguaCompressor,
|
||||
@ -15,7 +15,6 @@ if TYPE_CHECKING:
|
||||
OpenVINOReranker,
|
||||
)
|
||||
|
||||
__all__ = ["LLMLinguaCompressor", "OpenVINOReranker", "FlashrankRerank"]
|
||||
|
||||
_module_lookup = {
|
||||
"LLMLinguaCompressor": "langchain_community.document_compressors.llmlingua_filter",
|
||||
@ -32,4 +31,4 @@ def __getattr__(name: str) -> Any:
|
||||
raise AttributeError(f"module {__name__} has no attribute {name}")
|
||||
|
||||
|
||||
__all__ = list(_module_lookup.keys())
|
||||
__all__ = ["LLMLinguaCompressor", "OpenVINOReranker", "FlashrankRerank", "JinaRerank"]
|
||||
|
@ -1,5 +1,36 @@
|
||||
import importlib
|
||||
from typing import Any
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.document_loaders.parsers.audio import (
|
||||
OpenAIWhisperParser,
|
||||
)
|
||||
from langchain_community.document_loaders.parsers.doc_intelligence import (
|
||||
AzureAIDocumentIntelligenceParser,
|
||||
)
|
||||
from langchain_community.document_loaders.parsers.docai import (
|
||||
DocAIParser,
|
||||
)
|
||||
from langchain_community.document_loaders.parsers.grobid import (
|
||||
GrobidParser,
|
||||
)
|
||||
from langchain_community.document_loaders.parsers.html import (
|
||||
BS4HTMLParser,
|
||||
)
|
||||
from langchain_community.document_loaders.parsers.language import (
|
||||
LanguageParser,
|
||||
)
|
||||
from langchain_community.document_loaders.parsers.pdf import (
|
||||
PDFMinerParser,
|
||||
PDFPlumberParser,
|
||||
PyMuPDFParser,
|
||||
PyPDFium2Parser,
|
||||
PyPDFParser,
|
||||
)
|
||||
from langchain_community.document_loaders.parsers.vsdx import (
|
||||
VsdxParser,
|
||||
)
|
||||
|
||||
|
||||
_module_lookup = {
|
||||
"AzureAIDocumentIntelligenceParser": "langchain_community.document_loaders.parsers.doc_intelligence", # noqa: E501
|
||||
@ -24,4 +55,17 @@ def __getattr__(name: str) -> Any:
|
||||
raise AttributeError(f"module {__name__} has no attribute {name}")
|
||||
|
||||
|
||||
__all__ = list(_module_lookup.keys())
|
||||
__all__ = [
|
||||
"AzureAIDocumentIntelligenceParser",
|
||||
"BS4HTMLParser",
|
||||
"DocAIParser",
|
||||
"GrobidParser",
|
||||
"LanguageParser",
|
||||
"OpenAIWhisperParser",
|
||||
"PDFMinerParser",
|
||||
"PDFPlumberParser",
|
||||
"PyMuPDFParser",
|
||||
"PyPDFParser",
|
||||
"PyPDFium2Parser",
|
||||
"VsdxParser",
|
||||
]
|
||||
|
@ -93,6 +93,3 @@ def __getattr__(name: str) -> Any:
|
||||
module = importlib.import_module(_module_lookup[name])
|
||||
return getattr(module, name)
|
||||
raise AttributeError(f"module {__name__} has no attribute {name}")
|
||||
|
||||
|
||||
__all__ = list(_module_lookup.keys())
|
||||
|
@ -57,6 +57,3 @@ def __getattr__(name: str) -> Any:
|
||||
module = importlib.import_module(_module_lookup[name])
|
||||
return getattr(module, name)
|
||||
raise AttributeError(f"module {__name__} has no attribute {name}")
|
||||
|
||||
|
||||
__all__ = list(_module_lookup.keys())
|
||||
|
@ -496,6 +496,3 @@ def __getattr__(name: str) -> Any:
|
||||
module = importlib.import_module(_module_lookup[name])
|
||||
return getattr(module, name)
|
||||
raise AttributeError(f"module {__name__} has no attribute {name}")
|
||||
|
||||
|
||||
__all__ = list(_module_lookup.keys())
|
||||
|
@ -4,8 +4,6 @@ import importlib
|
||||
from pathlib import Path
|
||||
from typing import List, Tuple
|
||||
|
||||
import pytest
|
||||
|
||||
COMMUNITY_ROOT = Path(__file__).parent.parent.parent / "langchain_community"
|
||||
ALL_COMMUNITY_GLOB = COMMUNITY_ROOT.as_posix() + "/**/*.py"
|
||||
HERE = Path(__file__).parent
|
||||
@ -68,7 +66,6 @@ def _check_correct_or_not_defined__all__(code: str) -> bool:
|
||||
return all_good
|
||||
|
||||
|
||||
@pytest.mark.xfail
|
||||
def test_no_dynamic__all__() -> None:
|
||||
"""Verify that __all__ is not computed at runtime.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user