From ca09272af000307762d301c99da46ddc70d3bfd2 Mon Sep 17 00:00:00 2001 From: James Braza Date: Tue, 3 Oct 2023 09:20:19 -0700 Subject: [PATCH] Supporting `mypy` local usage with `venv` (#7952) --- experimental/splitter_playground/app.py | 6 +++--- pyproject.toml | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/experimental/splitter_playground/app.py b/experimental/splitter_playground/app.py index 6317101247bae..6accef9795ecf 100644 --- a/experimental/splitter_playground/app.py +++ b/experimental/splitter_playground/app.py @@ -7,6 +7,8 @@ from langchain.text_splitter import ( CharacterTextSplitter, RecursiveCharacterTextSplitter, +) +from langchain.text_splitter import ( TextSplitter as LCSplitter, ) from langchain.text_splitter import TokenTextSplitter as LCTokenTextSplitter @@ -29,7 +31,6 @@ @st.cache_resource(ttl="1h") def load_document(uploaded_files: List[UploadedFile]) -> List[Document]: # Read documents - docs = [] temp_dir = tempfile.TemporaryDirectory() for file in uploaded_files: temp_filepath = os.path.join(temp_dir.name, file.name) @@ -37,8 +38,7 @@ def load_document(uploaded_files: List[UploadedFile]) -> List[Document]: f.write(file.getvalue()) reader = SimpleDirectoryReader(input_dir=temp_dir.name) - docs = reader.load_data() - return docs + return reader.load_data() if uploaded_files: diff --git a/pyproject.toml b/pyproject.toml index 7e9401aaa03db..774b899e0bed5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,8 @@ [tool.mypy] -ignore_missing_imports = "True" -disallow_untyped_defs = "True" -exclude = ["notebooks", "build", "examples"] +disallow_untyped_defs = true +# Remove venv skip when integrated with pre-commit +exclude = ["build", "examples", "notebooks", "venv"] +ignore_missing_imports = true [tool.ruff] exclude = [