contextl 1.2.31 → 1.2.33
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 +11 -20
- package/python/standalone.py +1 -1
package/package.json
CHANGED
package/python/import_parser.py
CHANGED
|
@@ -836,24 +836,7 @@ def parse_imports(scan_result: ScanResult) -> ParseResult:
|
|
|
836
836
|
if scanned_file.extension == ".py" and not _TS_AVAILABLE:
|
|
837
837
|
pass # regex already handles this above
|
|
838
838
|
elif scanned_file.extension == ".py" and _TS_AVAILABLE:
|
|
839
|
-
# tree-sitter gives us just the module name; add symbol-level candidates
|
|
840
|
-
# to match the legacy behaviour that resolves "scanner.ScannedFile" → scanner.py
|
|
841
|
-
extra: list[str] = []
|
|
842
|
-
for match in PYTHON_FROM_IMPORT_PATTERN.finditer(source_code):
|
|
843
|
-
base = match.group(1)
|
|
844
|
-
symbols_str = match.group(2) or match.group(3)
|
|
845
|
-
if symbols_str:
|
|
846
|
-
symbols_str = symbols_str.replace('(', '').replace(')', '').replace('\\', '').strip()
|
|
847
|
-
for sym in symbols_str.split(','):
|
|
848
|
-
sym = sym.split(' as ')[0].strip()
|
|
849
|
-
if sym and sym != '*':
|
|
850
|
-
extra.append(f"{base}.{sym}")
|
|
851
|
-
# Merge without duplicates
|
|
852
|
-
seen = set(raw_imports)
|
|
853
|
-
for e in extra:
|
|
854
|
-
if e not in seen:
|
|
855
|
-
raw_imports.append(e)
|
|
856
|
-
seen.add(e)
|
|
839
|
+
pass # tree-sitter gives us just the module name; add symbol-level candidates (legacy removed)
|
|
857
840
|
|
|
858
841
|
for raw in raw_imports:
|
|
859
842
|
if _is_external(raw, scanned_file.extension, alias_map):
|
|
@@ -977,6 +960,7 @@ def _skeleton_python(root: "Node", source_bytes: bytes) -> dict:
|
|
|
977
960
|
name = ""
|
|
978
961
|
bases: list[str] = []
|
|
979
962
|
methods: list[dict] = []
|
|
963
|
+
nested_classes: list[dict] = []
|
|
980
964
|
props: list[dict] = []
|
|
981
965
|
|
|
982
966
|
for child in node.children:
|
|
@@ -998,9 +982,16 @@ def _skeleton_python(root: "Node", source_bytes: bytes) -> dict:
|
|
|
998
982
|
if sub.type == "function_definition":
|
|
999
983
|
fn_node = sub
|
|
1000
984
|
break
|
|
1001
|
-
|
|
985
|
+
elif sub.type == "class_definition":
|
|
986
|
+
nested_classes.append(visit_class(sub))
|
|
987
|
+
fn_node = None
|
|
988
|
+
break
|
|
989
|
+
if fn_node is not None:
|
|
990
|
+
methods.append(visit_function(fn_node, is_method=True))
|
|
991
|
+
elif stmt.type == "class_definition":
|
|
992
|
+
nested_classes.append(visit_class(stmt))
|
|
1002
993
|
|
|
1003
|
-
entry: dict = {"name": name, "bases": bases, "methods": methods, "properties": props}
|
|
994
|
+
entry: dict = {"name": name, "bases": bases, "methods": methods, "nested_classes": nested_classes, "properties": props}
|
|
1004
995
|
return entry
|
|
1005
996
|
|
|
1006
997
|
def visit_function(node: "Node", is_method: bool = False) -> dict:
|
package/python/standalone.py
CHANGED
|
@@ -18,7 +18,7 @@ ENTRY_POINT_MARKERS = {
|
|
|
18
18
|
"route.ts", "route.js",
|
|
19
19
|
"globals.css", "global.css", "tailwind.css",
|
|
20
20
|
"index.ts", "index.js", "index.tsx", "index.jsx",
|
|
21
|
-
"main.ts", "main.js", "main.py",
|
|
21
|
+
"main.ts", "main.js", "main.py", "main.go", "main.rs", "main.c", "main.cpp", "main.cc", "main.java",
|
|
22
22
|
"app.ts", "app.js", "app.tsx", "app.jsx", "app.py",
|
|
23
23
|
"mcp_server.py", "server.ts", "server.js", "server.py",
|
|
24
24
|
"__main__.py", "__init__.py", "setup.py", "conftest.py",
|