contextl 1.2.32 → 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 -23
- package/python/standalone.py +1 -1
package/package.json
CHANGED
package/python/import_parser.py
CHANGED
|
@@ -836,27 +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
|
-
if base.endswith("."):
|
|
851
|
-
extra.append(f"{base}{sym}")
|
|
852
|
-
else:
|
|
853
|
-
extra.append(f"{base}.{sym}")
|
|
854
|
-
# Merge without duplicates
|
|
855
|
-
seen = set(raw_imports)
|
|
856
|
-
for e in extra:
|
|
857
|
-
if e not in seen:
|
|
858
|
-
raw_imports.append(e)
|
|
859
|
-
seen.add(e)
|
|
839
|
+
pass # tree-sitter gives us just the module name; add symbol-level candidates (legacy removed)
|
|
860
840
|
|
|
861
841
|
for raw in raw_imports:
|
|
862
842
|
if _is_external(raw, scanned_file.extension, alias_map):
|
|
@@ -980,6 +960,7 @@ def _skeleton_python(root: "Node", source_bytes: bytes) -> dict:
|
|
|
980
960
|
name = ""
|
|
981
961
|
bases: list[str] = []
|
|
982
962
|
methods: list[dict] = []
|
|
963
|
+
nested_classes: list[dict] = []
|
|
983
964
|
props: list[dict] = []
|
|
984
965
|
|
|
985
966
|
for child in node.children:
|
|
@@ -1001,9 +982,16 @@ def _skeleton_python(root: "Node", source_bytes: bytes) -> dict:
|
|
|
1001
982
|
if sub.type == "function_definition":
|
|
1002
983
|
fn_node = sub
|
|
1003
984
|
break
|
|
1004
|
-
|
|
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))
|
|
1005
993
|
|
|
1006
|
-
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}
|
|
1007
995
|
return entry
|
|
1008
996
|
|
|
1009
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",
|