python2ts 0.2.0 → 0.2.1
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/LICENSE +21 -0
- package/dist/{chunk-M4HMEUNQ.js → chunk-VYG6GDWU.js} +29 -1
- package/dist/chunk-VYG6GDWU.js.map +1 -0
- package/dist/cli/index.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +13 -13
- package/dist/chunk-M4HMEUNQ.js.map +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sebastian Software GmbH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -326,6 +326,7 @@ function transformPythonType(node, ctx) {
|
|
|
326
326
|
case "ClassVar":
|
|
327
327
|
return typeArgs.length > 0 ? first : "unknown";
|
|
328
328
|
// Callable is handled specially before the switch via transformCallableType
|
|
329
|
+
/* v8 ignore start -- rare typing module types @preserve */
|
|
329
330
|
case "Iterable":
|
|
330
331
|
return typeArgs.length > 0 ? `Iterable<${first}>` : "Iterable<unknown>";
|
|
331
332
|
case "Iterator":
|
|
@@ -340,6 +341,8 @@ function transformPythonType(node, ctx) {
|
|
|
340
341
|
return typeArgs.length > 0 ? `Promise<${last}>` : "Promise<unknown>";
|
|
341
342
|
case "Type":
|
|
342
343
|
return typeArgs.length > 0 ? `new (...args: unknown[]) => ${first}` : "new (...args: unknown[]) => unknown";
|
|
344
|
+
/* v8 ignore stop */
|
|
345
|
+
/* v8 ignore start -- Literal type edge cases @preserve */
|
|
343
346
|
case "Literal": {
|
|
344
347
|
const literalValues = typeArgs.map((arg) => {
|
|
345
348
|
if (/^-?\d+(\.\d+)?$/.test(arg)) {
|
|
@@ -352,10 +355,13 @@ function transformPythonType(node, ctx) {
|
|
|
352
355
|
});
|
|
353
356
|
return literalValues.join(" | ");
|
|
354
357
|
}
|
|
358
|
+
/* v8 ignore stop */
|
|
359
|
+
/* v8 ignore next 3 -- generic fallback for custom types @preserve */
|
|
355
360
|
default:
|
|
356
361
|
return typeArgs.length > 0 ? `${baseName}<${typeArgs.join(", ")}>` : baseName;
|
|
357
362
|
}
|
|
358
363
|
}
|
|
364
|
+
/* v8 ignore start -- rare type annotation patterns @preserve */
|
|
359
365
|
case "BinaryExpression": {
|
|
360
366
|
const children = getChildren(node);
|
|
361
367
|
const left = children[0];
|
|
@@ -380,6 +386,8 @@ function transformPythonType(node, ctx) {
|
|
|
380
386
|
}
|
|
381
387
|
return "unknown";
|
|
382
388
|
}
|
|
389
|
+
/* v8 ignore stop */
|
|
390
|
+
/* v8 ignore next 2 -- fallback for unhandled type nodes @preserve */
|
|
383
391
|
default:
|
|
384
392
|
return getNodeText(node, ctx.source);
|
|
385
393
|
}
|
|
@@ -715,6 +723,7 @@ function transformNode(node, ctx) {
|
|
|
715
723
|
return transformAssertStatement(node, ctx);
|
|
716
724
|
case "YieldStatement":
|
|
717
725
|
return transformYieldStatement(node, ctx);
|
|
726
|
+
/* v8 ignore next 2 -- fallback for unknown AST nodes @preserve */
|
|
718
727
|
default:
|
|
719
728
|
return getNodeText(node, ctx.source);
|
|
720
729
|
}
|
|
@@ -953,6 +962,7 @@ function transformBinaryExpression(node, ctx) {
|
|
|
953
962
|
return `repeatValue(${rightCode}, ${leftCode})`;
|
|
954
963
|
}
|
|
955
964
|
return `(${leftCode} * ${rightCode})`;
|
|
965
|
+
/* v8 ignore next 2 -- pass-through for standard operators @preserve */
|
|
956
966
|
default:
|
|
957
967
|
return `(${leftCode} ${opText} ${rightCode})`;
|
|
958
968
|
}
|
|
@@ -993,6 +1003,7 @@ function transformUnaryExpression(node, ctx) {
|
|
|
993
1003
|
switch (opText) {
|
|
994
1004
|
case "not":
|
|
995
1005
|
return `(!${operandCode})`;
|
|
1006
|
+
/* v8 ignore next 2 -- pass-through for unary operators like - and + @preserve */
|
|
996
1007
|
default:
|
|
997
1008
|
return `(${opText}${operandCode})`;
|
|
998
1009
|
}
|
|
@@ -1355,6 +1366,7 @@ function transformCallExpression(node, ctx) {
|
|
|
1355
1366
|
case "capwords":
|
|
1356
1367
|
ctx.usesRuntime.add("string/capWords");
|
|
1357
1368
|
return `capWords(${args})`;
|
|
1369
|
+
/* v8 ignore next 3 -- pass-through for user-defined functions @preserve */
|
|
1358
1370
|
default:
|
|
1359
1371
|
return `${transformNode(callee, ctx)}(${args})`;
|
|
1360
1372
|
}
|
|
@@ -1606,6 +1618,7 @@ function transformMethodCall(callee, args, ctx) {
|
|
|
1606
1618
|
case "issuperset":
|
|
1607
1619
|
ctx.usesRuntime.add("set");
|
|
1608
1620
|
return `set.issuperset(${objCode}, ${args})`;
|
|
1621
|
+
/* v8 ignore next 2 -- unknown method, let caller handle @preserve */
|
|
1609
1622
|
default:
|
|
1610
1623
|
return null;
|
|
1611
1624
|
}
|
|
@@ -2012,6 +2025,7 @@ function transformComplexPattern(pattern, subject, ctx) {
|
|
|
2012
2025
|
}
|
|
2013
2026
|
return { condition: "true", bindings: [`const ${varName} = ${subject};`] };
|
|
2014
2027
|
}
|
|
2028
|
+
/* v8 ignore next 3 -- fallback for unknown match patterns @preserve */
|
|
2015
2029
|
default:
|
|
2016
2030
|
return { condition: `${subject} === ${getNodeText(pattern, ctx.source)}`, bindings: [] };
|
|
2017
2031
|
}
|
|
@@ -2202,6 +2216,7 @@ function transformMatchPatternSimple(node, ctx) {
|
|
|
2202
2216
|
}
|
|
2203
2217
|
case "CapturePattern":
|
|
2204
2218
|
return getNodeText(node, ctx.source);
|
|
2219
|
+
/* v8 ignore next 2 -- fallback for unknown case patterns @preserve */
|
|
2205
2220
|
default:
|
|
2206
2221
|
return getNodeText(node, ctx.source);
|
|
2207
2222
|
}
|
|
@@ -4451,4 +4466,17 @@ export {
|
|
|
4451
4466
|
generateAsync,
|
|
4452
4467
|
transpileAsync
|
|
4453
4468
|
};
|
|
4454
|
-
|
|
4469
|
+
/* v8 ignore next 3 -- malformed type annotation fallback @preserve */
|
|
4470
|
+
/* v8 ignore next 3 -- defensive: empty targets/values can't occur with valid Python @preserve */
|
|
4471
|
+
/* v8 ignore next -- @preserve */
|
|
4472
|
+
/* v8 ignore next 3 -- defensive: walrus operator always has name and value @preserve */
|
|
4473
|
+
/* v8 ignore next -- defensive: checked exprs.length >= 3 above @preserve */
|
|
4474
|
+
/* v8 ignore next 4 -- defensive: items from parser are never null @preserve */
|
|
4475
|
+
/* v8 ignore next 3 -- defensive: subscript always has brackets @preserve */
|
|
4476
|
+
/* v8 ignore next 3 -- defensive: slice detection already checked for colons @preserve */
|
|
4477
|
+
/* v8 ignore next 2 -- del obj.attr edge case @preserve */
|
|
4478
|
+
/* v8 ignore next -- fallback for complex del targets @preserve */
|
|
4479
|
+
/* v8 ignore next -- bare yield statement @preserve */
|
|
4480
|
+
/* v8 ignore next 2 -- fallback for future/unknown runtime functions @preserve */
|
|
4481
|
+
/* v8 ignore start -- async wrappers tested via CLI @preserve */
|
|
4482
|
+
//# sourceMappingURL=chunk-VYG6GDWU.js.map
|