fix linting errors
This commit is contained in:
@@ -16,9 +16,7 @@ import numpy as np
|
||||
import tiktoken
|
||||
|
||||
from lightrag.prompt import PROMPTS
|
||||
from typing import List
|
||||
import csv
|
||||
import io
|
||||
|
||||
|
||||
class UnlimitedSemaphore:
|
||||
"""A context manager that allows unlimited access."""
|
||||
@@ -237,16 +235,14 @@ def truncate_list_by_token_size(list_data: list, key: callable, max_token_size:
|
||||
return list_data
|
||||
|
||||
|
||||
|
||||
|
||||
def list_of_list_to_csv(data: List[List[str]]) -> str:
|
||||
output = io.StringIO()
|
||||
writer = csv.writer(
|
||||
output,
|
||||
quoting=csv.QUOTE_ALL, # Quote all fields
|
||||
escapechar='\\', # Use backslash as escape character
|
||||
quotechar='"', # Use double quotes
|
||||
lineterminator='\n' # Explicit line terminator
|
||||
quoting=csv.QUOTE_ALL, # Quote all fields
|
||||
escapechar="\\", # Use backslash as escape character
|
||||
quotechar='"', # Use double quotes
|
||||
lineterminator="\n", # Explicit line terminator
|
||||
)
|
||||
writer.writerows(data)
|
||||
return output.getvalue()
|
||||
@@ -254,16 +250,16 @@ def list_of_list_to_csv(data: List[List[str]]) -> str:
|
||||
|
||||
def csv_string_to_list(csv_string: str) -> List[List[str]]:
|
||||
# Clean the string by removing NUL characters
|
||||
cleaned_string = csv_string.replace('\0', '')
|
||||
|
||||
cleaned_string = csv_string.replace("\0", "")
|
||||
|
||||
output = io.StringIO(cleaned_string)
|
||||
reader = csv.reader(
|
||||
output,
|
||||
quoting=csv.QUOTE_ALL, # Match the writer configuration
|
||||
escapechar='\\', # Use backslash as escape character
|
||||
quotechar='"', # Use double quotes
|
||||
quoting=csv.QUOTE_ALL, # Match the writer configuration
|
||||
escapechar="\\", # Use backslash as escape character
|
||||
quotechar='"', # Use double quotes
|
||||
)
|
||||
|
||||
|
||||
try:
|
||||
return [row for row in reader]
|
||||
except csv.Error as e:
|
||||
|
Reference in New Issue
Block a user