diff --git a/poetry.lock b/poetry.lock index a6a944ea..15c517c2 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.5 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "aiohappyeyeballs" @@ -4136,4 +4136,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.0" python-versions = ">=3.12,<3.13" -content-hash = "801027fa4f63b683c6f240e24d0be8e95dd8edc539a17493f76dcfe8fdb18985" +content-hash = "41213658db6d6645acd2b7ce6b7918db02fa16da0946130dcb0c583983f7d724" diff --git a/pyproject.toml b/pyproject.toml index c3154f52..5e6cfb02 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,6 +40,7 @@ onnxruntime = "==1.20.1" onnx = "==1.17.0" spacy = "<3.8.0" en-core-web-sm = {url = "https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.8.0/en_core_web_sm-3.8.0-py3-none-any.whl"} +regex = "==2024.11.6" [tool.poetry.group.dev.dependencies] pytest = "==8.3.4" diff --git a/src/codegate/api/v1_processing.py b/src/codegate/api/v1_processing.py index 0dbce577..6606a882 100644 --- a/src/codegate/api/v1_processing.py +++ b/src/codegate/api/v1_processing.py @@ -1,10 +1,10 @@ import asyncio import json -import re from collections import defaultdict from typing import AsyncGenerator, Dict, List, Optional, Tuple import cachetools.func +import regex as re import requests import structlog diff --git a/src/codegate/clients/detector.py b/src/codegate/clients/detector.py index 8c928ad3..acb75c24 100644 --- a/src/codegate/clients/detector.py +++ b/src/codegate/clients/detector.py @@ -1,8 +1,8 @@ -import re from abc import ABC, abstractmethod from functools import wraps from typing import List, Optional +import regex as re import structlog from fastapi import Request diff --git a/src/codegate/db/fim_cache.py b/src/codegate/db/fim_cache.py index a0b3e9e4..22e95315 100644 --- a/src/codegate/db/fim_cache.py +++ b/src/codegate/db/fim_cache.py @@ -1,9 +1,9 @@ import datetime import hashlib import json -import re from typing import Dict, List, Optional +import regex as re import structlog from pydantic import BaseModel @@ -21,6 +21,11 @@ class CachedFim(BaseModel): initial_id: str +# Regular expression to match file paths in FIM messages. +# Compiled regex to improve performance. +filepath_matcher = re.compile(r"^(#|//|