@suss/adapter-python 0.5.5 → 0.5.6

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/index.cjs CHANGED
@@ -151,8 +151,28 @@ var STATEMENT_BINDERS = {
151
151
  class_definition: bindClassDefinition,
152
152
  expression_statement: bindExpressionStatement,
153
153
  global_statement: bindGlobalStatement,
154
- nonlocal_statement: bindNonlocalStatement
154
+ nonlocal_statement: bindNonlocalStatement,
155
+ delete_statement: bindDeleteStatement
155
156
  };
157
+ function bindDeleteStatement(stmt, scope) {
158
+ const unbind = (node) => {
159
+ if (node === null) {
160
+ return;
161
+ }
162
+ if (node.type === "identifier") {
163
+ scope.bindings.delete(node.text);
164
+ return;
165
+ }
166
+ if (node.type === "expression_list") {
167
+ for (const child of node.namedChildren) {
168
+ unbind(child);
169
+ }
170
+ }
171
+ };
172
+ for (const child of stmt.namedChildren) {
173
+ unbind(child);
174
+ }
175
+ }
156
176
  function bindStatement(stmt, scope, ctx) {
157
177
  const binder = STATEMENT_BINDERS[stmt.type];
158
178
  binder?.(stmt, scope, ctx);
@@ -18079,20 +18099,34 @@ function isInsideAnyRoot(dir, roots) {
18079
18099
  function candidatesUnderRoot(root, dotted) {
18080
18100
  if (dotted === "") {
18081
18101
  const initFile = import_node_path.default.join(root, "__init__.py");
18082
- return import_node_fs.default.existsSync(initFile) ? [initFile] : [];
18102
+ return existsWithExactCase(initFile, 1) ? [initFile] : [];
18083
18103
  }
18084
- const base = import_node_path.default.join(root, ...dotted.split("."));
18104
+ const segments = dotted.split(".");
18105
+ const base = import_node_path.default.join(root, ...segments);
18085
18106
  const found = [];
18086
18107
  const moduleFile = `${base}.py`;
18087
- if (import_node_fs.default.existsSync(moduleFile)) {
18108
+ if (existsWithExactCase(moduleFile, segments.length)) {
18088
18109
  found.push(moduleFile);
18089
18110
  }
18090
18111
  const packageFile = import_node_path.default.join(base, "__init__.py");
18091
- if (import_node_fs.default.existsSync(packageFile)) {
18112
+ if (existsWithExactCase(packageFile, segments.length + 1)) {
18092
18113
  found.push(packageFile);
18093
18114
  }
18094
18115
  return found;
18095
18116
  }
18117
+ function existsWithExactCase(file2, trailingSegments) {
18118
+ if (!import_node_fs.default.existsSync(file2)) {
18119
+ return false;
18120
+ }
18121
+ let real;
18122
+ try {
18123
+ real = import_node_fs.default.realpathSync.native(file2);
18124
+ } catch {
18125
+ return false;
18126
+ }
18127
+ const tail = (p) => p.split(import_node_path.default.sep).slice(-trailingSegments).join(import_node_path.default.sep);
18128
+ return tail(real) === tail(file2);
18129
+ }
18096
18130
  function resolveAbsoluteModule(dotted, options) {
18097
18131
  const byRoot = [];
18098
18132
  for (const root of options.roots) {
package/dist/index.js CHANGED
@@ -97,8 +97,28 @@ var STATEMENT_BINDERS = {
97
97
  class_definition: bindClassDefinition,
98
98
  expression_statement: bindExpressionStatement,
99
99
  global_statement: bindGlobalStatement,
100
- nonlocal_statement: bindNonlocalStatement
100
+ nonlocal_statement: bindNonlocalStatement,
101
+ delete_statement: bindDeleteStatement
101
102
  };
103
+ function bindDeleteStatement(stmt, scope) {
104
+ const unbind = (node) => {
105
+ if (node === null) {
106
+ return;
107
+ }
108
+ if (node.type === "identifier") {
109
+ scope.bindings.delete(node.text);
110
+ return;
111
+ }
112
+ if (node.type === "expression_list") {
113
+ for (const child of node.namedChildren) {
114
+ unbind(child);
115
+ }
116
+ }
117
+ };
118
+ for (const child of stmt.namedChildren) {
119
+ unbind(child);
120
+ }
121
+ }
102
122
  function bindStatement(stmt, scope, ctx) {
103
123
  const binder = STATEMENT_BINDERS[stmt.type];
104
124
  binder?.(stmt, scope, ctx);
@@ -18035,20 +18055,34 @@ function isInsideAnyRoot(dir, roots) {
18035
18055
  function candidatesUnderRoot(root, dotted) {
18036
18056
  if (dotted === "") {
18037
18057
  const initFile = path.join(root, "__init__.py");
18038
- return fs.existsSync(initFile) ? [initFile] : [];
18058
+ return existsWithExactCase(initFile, 1) ? [initFile] : [];
18039
18059
  }
18040
- const base = path.join(root, ...dotted.split("."));
18060
+ const segments = dotted.split(".");
18061
+ const base = path.join(root, ...segments);
18041
18062
  const found = [];
18042
18063
  const moduleFile = `${base}.py`;
18043
- if (fs.existsSync(moduleFile)) {
18064
+ if (existsWithExactCase(moduleFile, segments.length)) {
18044
18065
  found.push(moduleFile);
18045
18066
  }
18046
18067
  const packageFile = path.join(base, "__init__.py");
18047
- if (fs.existsSync(packageFile)) {
18068
+ if (existsWithExactCase(packageFile, segments.length + 1)) {
18048
18069
  found.push(packageFile);
18049
18070
  }
18050
18071
  return found;
18051
18072
  }
18073
+ function existsWithExactCase(file2, trailingSegments) {
18074
+ if (!fs.existsSync(file2)) {
18075
+ return false;
18076
+ }
18077
+ let real;
18078
+ try {
18079
+ real = fs.realpathSync.native(file2);
18080
+ } catch {
18081
+ return false;
18082
+ }
18083
+ const tail = (p) => p.split(path.sep).slice(-trailingSegments).join(path.sep);
18084
+ return tail(real) === tail(file2);
18085
+ }
18052
18086
  function resolveAbsoluteModule(dotted, options) {
18053
18087
  const byRoot = [];
18054
18088
  for (const root of options.roots) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suss/adapter-python",
3
- "version": "0.5.5",
3
+ "version": "0.5.6",
4
4
  "type": "module",
5
5
  "description": "Python language adapter for suss — parses source with tree-sitter (WASM), resolves names with a lexical binder, and emits raw extractions for the suss pipeline.",
6
6
  "keywords": [
@@ -47,9 +47,9 @@
47
47
  "typecheck": "tsc --noEmit"
48
48
  },
49
49
  "dependencies": {
50
- "@suss/behavioral-ir": "0.5.5",
51
- "@suss/datalog": "0.5.5",
52
- "@suss/extractor": "0.5.5",
50
+ "@suss/behavioral-ir": "0.5.6",
51
+ "@suss/datalog": "0.5.6",
52
+ "@suss/extractor": "0.5.6",
53
53
  "web-tree-sitter": "^0.26.11"
54
54
  },
55
55
  "devDependencies": {