Quellcode durchsuchen

chore: fix invalid escape sequences by applying W605 rule (#4851)

Bowen Liang vor 10 Monaten
Ursprung
Commit
b234710af9

+ 6 - 6
api/core/splitter/text_splitter.py

@@ -701,7 +701,7 @@ class RecursiveCharacterTextSplitter(TextSplitter):
                 # Split along section titles
                 "\n=+\n",
                 "\n-+\n",
-                "\n\*+\n",
+                "\n\\*+\n",
                 # Split along directive markers
                 "\n\n.. *\n\n",
                 # Split by the normal type of lines
@@ -800,7 +800,7 @@ class RecursiveCharacterTextSplitter(TextSplitter):
                 # End of code block
                 "```\n",
                 # Horizontal lines
-                "\n\*\*\*+\n",
+                "\n\\*\\*\\*+\n",
                 "\n---+\n",
                 "\n___+\n",
                 # Note that this splitter doesn't handle horizontal lines defined
@@ -813,10 +813,10 @@ class RecursiveCharacterTextSplitter(TextSplitter):
         elif language == Language.LATEX:
             return [
                 # First, try to split along Latex sections
-                "\n\\\chapter{",
-                "\n\\\section{",
-                "\n\\\subsection{",
-                "\n\\\subsubsection{",
+                "\n\\\\chapter{",
+                "\n\\\\section{",
+                "\n\\\\subsection{",
+                "\n\\\\subsubsection{",
                 # Now split by environments
                 "\n\\\begin{enumerate}",
                 "\n\\\begin{itemize}",

+ 1 - 0
api/pyproject.toml

@@ -15,6 +15,7 @@ select = [
     "UP",   # pyupgrade rules
     "RUF019", # unnecessary-key-check
     "S506", # unsafe-yaml-load
+    "W605", # invalid-escape-sequence
 ]
 ignore = [
     "F403", # undefined-local-with-import-star

+ 1 - 1
api/services/workflow/workflow_converter.py

@@ -305,7 +305,7 @@ class WorkflowConverter:
             }
 
             request_body_json = json.dumps(request_body)
-            request_body_json = request_body_json.replace('\{\{', '{{').replace('\}\}', '}}')
+            request_body_json = request_body_json.replace(r'\{\{', '{{').replace(r'\}\}', '}}')
 
             http_request_node = {
                 "id": f"http_request_{index}",