contextl 1.2.28 → 1.2.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -19,8 +19,11 @@ from import_parser import parse_imports
|
|
|
19
19
|
from graph_builder import build_graph, RepoGraph
|
|
20
20
|
|
|
21
21
|
|
|
22
|
+
import re
|
|
23
|
+
|
|
22
24
|
# Heuristics for detecting test files by path/name
|
|
23
25
|
TEST_MARKERS = ("test", "spec", "__tests__", "__mocks__")
|
|
26
|
+
_TEST_PATTERN = re.compile(r'(?<![a-z0-9])(?:' + '|'.join(re.escape(m) for m in TEST_MARKERS) + r')(?![a-z0-9])', re.IGNORECASE)
|
|
24
27
|
|
|
25
28
|
|
|
26
29
|
@dataclass
|
|
@@ -104,8 +107,7 @@ class ImpactReport:
|
|
|
104
107
|
|
|
105
108
|
|
|
106
109
|
def _is_test_file(path: str) -> bool:
|
|
107
|
-
|
|
108
|
-
return any(marker in lowered for marker in TEST_MARKERS)
|
|
110
|
+
return bool(_TEST_PATTERN.search(path))
|
|
109
111
|
|
|
110
112
|
|
|
111
113
|
def analyze_impact(
|
package/python/query_engine.py
CHANGED
|
@@ -101,8 +101,7 @@ def _keyword_score(query_terms: list[str], file_path: str, idf_weights: dict[str
|
|
|
101
101
|
matched.append(term)
|
|
102
102
|
# Substring or abbreviation match on filename
|
|
103
103
|
elif len(term) >= 2 and any(
|
|
104
|
-
term in ft or ft in term or ft.startswith(term) or term.startswith(ft)
|
|
105
|
-
all(c in iter(ft) for c in term)
|
|
104
|
+
term in ft or ft in term or ft.startswith(term) or term.startswith(ft)
|
|
106
105
|
for ft in filename_toks
|
|
107
106
|
):
|
|
108
107
|
score += 3.0 * idf_weights.get(term, 1.0)
|
|
@@ -114,8 +113,7 @@ def _keyword_score(query_terms: list[str], file_path: str, idf_weights: dict[str
|
|
|
114
113
|
matched.append(term)
|
|
115
114
|
# Substring or abbreviation match on path
|
|
116
115
|
elif len(term) >= 2 and any(
|
|
117
|
-
term in pt or pt in term or pt.startswith(term) or term.startswith(pt)
|
|
118
|
-
all(c in iter(pt) for c in term)
|
|
116
|
+
term in pt or pt in term or pt.startswith(term) or term.startswith(pt)
|
|
119
117
|
for pt in path_toks
|
|
120
118
|
):
|
|
121
119
|
score += 1.5 * idf_weights.get(term, 1.0)
|