ci: Add script to check for pickle usage in community (#22863)

Add script to check for pickle usage in community.
This commit is contained in:
Eugene Yurtsev
2024-06-13 16:13:15 -04:00
committed by GitHub
parent 77209f315e
commit 8f7cc73817
9 changed files with 65 additions and 8 deletions

View File

@@ -152,6 +152,8 @@ class TFIDFRetriever(BaseRetriever):
# Load docs and tfidf array as pickle.
with open(path / f"{file_name}.pkl", "rb") as f:
docs, tfidf_array = pickle.load(f)
# This code path can only be triggered if the user
# passed allow_dangerous_deserialization=True
docs, tfidf_array = pickle.load(f) # ignore[pickle]: explicit-opt-in
return cls(vectorizer=vectorizer, docs=docs, tfidf_array=tfidf_array)