text-splitters: Ruff autofixes (#31858)

Auto-fixes from ruff with rule `ALL`
This commit is contained in:
Christophe Bornet
2025-07-07 16:06:08 +02:00
committed by GitHub
parent 8aed3b61a9
commit 451c90fefa
16 changed files with 121 additions and 123 deletions

View File

@@ -64,15 +64,14 @@ class RecursiveJsonSplitter:
if isinstance(data, dict):
# Process each key-value pair in the dictionary
return {k: self._list_to_dict_preprocessing(v) for k, v in data.items()}
elif isinstance(data, list):
if isinstance(data, list):
# Convert the list to a dictionary with index-based keys
return {
str(i): self._list_to_dict_preprocessing(item)
for i, item in enumerate(data)
}
else:
# Base case: the item is neither a dict nor a list, so return it unchanged
return data
# Base case: the item is neither a dict nor a list, so return it unchanged
return data
def _json_split(
self,
@@ -85,7 +84,7 @@ class RecursiveJsonSplitter:
chunks = chunks if chunks is not None else [{}]
if isinstance(data, dict):
for key, value in data.items():
new_path = current_path + [key]
new_path = [*current_path, key]
chunk_size = self._json_size(chunks[-1])
size = self._json_size({key: value})
remaining = self.max_chunk_size - chunk_size