@marimo-team/islands 0.21.1-dev13 → 0.21.1-dev14

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/dist/main.js CHANGED
@@ -70724,7 +70724,7 @@ Image URL: ${r.imageUrl}`)), contextToXml({
70724
70724
  return Logger.warn("Failed to get version from mount config"), null;
70725
70725
  }
70726
70726
  }
70727
- const marimoVersionAtom = atom(getVersionFromMountConfig() || "0.21.1-dev13"), showCodeInRunModeAtom = atom(true);
70727
+ const marimoVersionAtom = atom(getVersionFromMountConfig() || "0.21.1-dev14"), showCodeInRunModeAtom = atom(true);
70728
70728
  atom(null);
70729
70729
  var import_compiler_runtime$89 = require_compiler_runtime();
70730
70730
  function useKeydownOnElement(e, r) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/islands",
3
- "version": "0.21.1-dev13",
3
+ "version": "0.21.1-dev14",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -1115,6 +1115,60 @@ class Foo:
1115
1115
  `);
1116
1116
  });
1117
1117
 
1118
+ test("should not highlight attribute access matching a for-loop variable", () => {
1119
+ // When `tool` is used as a for-loop variable, `mcp.tool` (attribute access)
1120
+ // should NOT have `tool` highlighted — it's a property, not a variable reference.
1121
+ expect(
1122
+ runHighlight(
1123
+ ["mcp", "client"],
1124
+ `
1125
+ @mcp.tool
1126
+ def roll_dice():
1127
+ pass
1128
+
1129
+ async with client:
1130
+ for tool in await client.list_tools():
1131
+ print(tool)
1132
+ `,
1133
+ ),
1134
+ ).toMatchInlineSnapshot(`
1135
+ "
1136
+ @mcp.tool
1137
+ ^^^
1138
+ def roll_dice():
1139
+ pass
1140
+
1141
+ async with client:
1142
+ ^^^^^^
1143
+ for tool in await client.list_tools():
1144
+ ^^^^^^
1145
+ print(tool)
1146
+ "
1147
+ `);
1148
+ });
1149
+
1150
+ test("should not highlight property name matching a global variable", () => {
1151
+ // `tool` is a global variable, but `mcp.tool` should not highlight `tool`
1152
+ // because it's a property access, not a variable reference.
1153
+ expect(
1154
+ runHighlight(
1155
+ ["mcp", "tool"],
1156
+ `
1157
+ @mcp.tool
1158
+ def roll_dice():
1159
+ pass
1160
+ `,
1161
+ ),
1162
+ ).toMatchInlineSnapshot(`
1163
+ "
1164
+ @mcp.tool
1165
+ ^^^
1166
+ def roll_dice():
1167
+ pass
1168
+ "
1169
+ `);
1170
+ });
1171
+
1118
1172
  test("class property self-reference", () => {
1119
1173
  expect(
1120
1174
  runHighlight(
@@ -462,6 +462,7 @@ export function findReactiveVariables(options: {
462
462
  ): boolean {
463
463
  return (
464
464
  allVariableNames.has(varName) &&
465
+ !isPropertyAccess(cursor) &&
465
466
  !isKeywordArgumentName(cursor) &&
466
467
  !isAssignmentTarget(cursor)
467
468
  );
@@ -529,6 +530,19 @@ function isAssignmentTarget(cursor: TreeCursor): boolean {
529
530
  return false;
530
531
  }
531
532
 
533
+ /** Checks whether a `VariableName` is a property access (e.g. `tool` in `mcp.tool`). */
534
+ function isPropertyAccess(cursor: TreeCursor): boolean {
535
+ // Check if the previous sibling is a "." node, which means this
536
+ // VariableName is a property access rather than a standalone variable.
537
+ // This handles both MemberExpression (e.g. `obj.attr`) and Decorator
538
+ // (e.g. `@mcp.tool`) where the parser emits flat sibling nodes.
539
+ const temp = cursor.node.cursor();
540
+ if (temp.prevSibling() && temp.name === ".") {
541
+ return true;
542
+ }
543
+ return false;
544
+ }
545
+
532
546
  /**
533
547
  * Checks if the syntax tree contains any syntax errors.
534
548
  * If there are errors, we shouldn't show reactive variable highlighting.