contextl 1.2.45 → 1.2.47
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 +1 -1
- package/python/import_parser.py +16 -3
- package/python/query_engine.py +4 -0
- package/python/scanner.py +1 -1
package/package.json
CHANGED
package/python/import_parser.py
CHANGED
|
@@ -593,10 +593,23 @@ def _find_file_in_repo(
|
|
|
593
593
|
py_idx = cand + "/__init__.py"
|
|
594
594
|
if py_idx in file_index:
|
|
595
595
|
return py_idx
|
|
596
|
-
|
|
596
|
+
|
|
597
|
+
suffix_ext = "/" + py_ext
|
|
598
|
+
suffix_idx = "/" + py_idx
|
|
599
|
+
matches = []
|
|
600
|
+
|
|
597
601
|
for path in file_index:
|
|
598
|
-
if path.endswith(
|
|
599
|
-
|
|
602
|
+
if path.endswith(suffix_ext) or path == py_ext:
|
|
603
|
+
matches.append(path)
|
|
604
|
+
elif path.endswith(suffix_idx) or path == py_idx:
|
|
605
|
+
matches.append(path)
|
|
606
|
+
|
|
607
|
+
if matches:
|
|
608
|
+
if source_file:
|
|
609
|
+
matches.sort(key=lambda p: (p.count("/"), _path_distance(source_file, p), 0 if p.endswith("__init__.py") else 1))
|
|
610
|
+
else:
|
|
611
|
+
matches.sort(key=lambda p: (p.count("/"), 0 if p.endswith("__init__.py") else 1))
|
|
612
|
+
return matches[0]
|
|
600
613
|
|
|
601
614
|
# Fallback for Python cross-language imports (e.g. from tests to .ts/.js core logic)
|
|
602
615
|
for ext in [".ts", ".tsx", ".js", ".jsx", ".java", ".go", ".rs", ".cpp", ".cc", ".cxx", ".h", ".hpp", ".c"]:
|
package/python/query_engine.py
CHANGED
|
@@ -111,10 +111,14 @@ COMMON_ABBREVS = {
|
|
|
111
111
|
"mid": "middleware"
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
REVERSE_ABBREVS = {v: k for k, v in COMMON_ABBREVS.items()}
|
|
115
|
+
|
|
114
116
|
def _is_match(term: str, target: str) -> bool:
|
|
115
117
|
term_canon = COMMON_ABBREVS.get(term, term)
|
|
116
118
|
if term_canon in target or target in term_canon or target.startswith(term_canon) or term_canon.startswith(target):
|
|
117
119
|
return True
|
|
120
|
+
if target == REVERSE_ABBREVS.get(term_canon):
|
|
121
|
+
return True
|
|
118
122
|
return False
|
|
119
123
|
|
|
120
124
|
|
package/python/scanner.py
CHANGED
|
@@ -18,7 +18,7 @@ ignore_dirs = {
|
|
|
18
18
|
".git", "node_modules", "__pycache__", "venv", ".venv",
|
|
19
19
|
"env", ".env", ".next", ".nuxt", "out", "build", "dist",
|
|
20
20
|
"coverage", ".nyc_output", ".pytest_cache", "npm", "pypi",
|
|
21
|
-
"vendor", "target", ".cargo", "Pods", "third_party"
|
|
21
|
+
"vendor", "target", ".cargo", "Pods", "third_party", "deps"
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
def _should_ignore(path: str) -> bool:
|