ucn 3.7.33 → 3.7.34

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.
@@ -982,6 +982,30 @@ function findInstanceAttributeTypes(code, parser) {
982
982
  const initBody = child.childForFieldName('body');
983
983
  if (!initBody) continue;
984
984
 
985
+ // Build parameter type map from __init__ annotations
986
+ // e.g. def __init__(self, market: MarketDataFetcher = None) → {market: MarketDataFetcher}
987
+ const paramTypes = new Map();
988
+ const params = child.childForFieldName('parameters');
989
+ if (params) {
990
+ for (let p = 0; p < params.childCount; p++) {
991
+ const param = params.child(p);
992
+ // typed_parameter or typed_default_parameter
993
+ if (param.type === 'typed_parameter' || param.type === 'typed_default_parameter') {
994
+ const pName = param.childForFieldName('name') || param.child(0);
995
+ const pType = param.childForFieldName('type');
996
+ if (pName && pType) {
997
+ const typeIdent = pType.type === 'type' ? pType.firstChild : pType;
998
+ if (typeIdent?.type === 'identifier') {
999
+ const tn = typeIdent.text;
1000
+ if (!PRIMITIVE_TYPES.has(tn) && tn[0] >= 'A' && tn[0] <= 'Z') {
1001
+ paramTypes.set(pName.text, tn);
1002
+ }
1003
+ }
1004
+ }
1005
+ }
1006
+ }
1007
+ }
1008
+
985
1009
  traverseTree(initBody, (stmt) => {
986
1010
  if (stmt.type !== 'expression_statement') return true;
987
1011
 
@@ -1004,6 +1028,9 @@ function findInstanceAttributeTypes(code, parser) {
1004
1028
  const typeName = extractConstructorName(rhs);
1005
1029
  if (typeName) {
1006
1030
  attrTypes.set(attrName, typeName);
1031
+ } else if (rhs.type === 'identifier' && paramTypes.has(rhs.text)) {
1032
+ // self.X = param where param has type annotation
1033
+ attrTypes.set(attrName, paramTypes.get(rhs.text));
1007
1034
  }
1008
1035
 
1009
1036
  return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ucn",
3
- "version": "3.7.33",
3
+ "version": "3.7.34",
4
4
  "mcpName": "io.github.mleoca/ucn",
5
5
  "description": "Universal Code Navigator — AST-based call graph analysis for AI agents. Find callers, trace impact, detect dead code across JS/TS, Python, Go, Rust, Java, and HTML. CLI, MCP server, and agent skill.",
6
6
  "main": "index.js",