Skip to content
Snippets Groups Projects
Commit ffc9788d authored by Simonas's avatar Simonas
Browse files

fix: removed helper replace.py

parent abc87834
No related branches found
No related tags found
No related merge requests found
......@@ -8,9 +8,7 @@ venv/
.idea
**/__pycache__
**/*.py[cod]
node_modules
package-lock.json
package.json
# local env files
.env*.local
......@@ -23,3 +21,8 @@ mac.env
.pytest_cache
test.py
output
node_modules
package-lock.json
package.json
```
import re
import os
def replace_type_hints(file_path):
with open(file_path, "rb") as file:
file_data = file.read()
# Decode the file data with error handling
file_data = file_data.decode("utf-8", errors="ignore")
# Regular expression pattern to find '| None' and replace with 'Optional'
file_data = re.sub(r"(\w+)\s*\|\s*None", r"Optional[\1]", file_data)
with open(file_path, "w") as file:
file.write(file_data)
# Walk through the repository and update all .py files
for root, dirs, files in os.walk("/Users/jakit/customers/aurelio/semantic-router"):
for file in files:
if file.endswith(".py"):
replace_type_hints(os.path.join(root, file))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment