rapydscript-ns 0.8.2 → 0.8.4

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.
Files changed (141) hide show
  1. package/.agignore +1 -1
  2. package/.github/workflows/ci.yml +38 -38
  3. package/=template.pyj +5 -5
  4. package/CHANGELOG.md +39 -0
  5. package/HACKING.md +103 -103
  6. package/LICENSE +24 -24
  7. package/PYTHON_DIFFERENCES_REPORT.md +291 -0
  8. package/PYTHON_FEATURE_COVERAGE.md +106 -15
  9. package/README.md +831 -52
  10. package/TODO.md +4 -286
  11. package/add-toc-to-readme +2 -2
  12. package/bin/export +75 -75
  13. package/bin/rapydscript +70 -70
  14. package/bin/web-repl-export +102 -102
  15. package/build +2 -2
  16. package/language-service/index.js +4623 -0
  17. package/language-service/language-service.d.ts +40 -0
  18. package/package.json +9 -7
  19. package/publish.py +37 -37
  20. package/release/baselib-plain-pretty.js +2006 -229
  21. package/release/baselib-plain-ugly.js +70 -3
  22. package/release/compiler.js +11554 -3870
  23. package/release/signatures.json +31 -29
  24. package/session.vim +4 -4
  25. package/setup.cfg +2 -2
  26. package/src/ast.pyj +93 -1
  27. package/src/baselib-builtins.pyj +99 -2
  28. package/src/baselib-containers.pyj +107 -4
  29. package/src/baselib-errors.pyj +44 -0
  30. package/src/baselib-internal.pyj +124 -5
  31. package/src/baselib-itertools.pyj +97 -97
  32. package/src/baselib-str.pyj +32 -1
  33. package/src/compiler.pyj +36 -36
  34. package/src/errors.pyj +30 -30
  35. package/src/lib/aes.pyj +646 -646
  36. package/src/lib/collections.pyj +1 -1
  37. package/src/lib/copy.pyj +120 -0
  38. package/src/lib/elementmaker.pyj +83 -83
  39. package/src/lib/encodings.pyj +126 -126
  40. package/src/lib/gettext.pyj +569 -569
  41. package/src/lib/itertools.pyj +580 -580
  42. package/src/lib/math.pyj +193 -193
  43. package/src/lib/numpy.pyj +10 -10
  44. package/src/lib/operator.pyj +11 -11
  45. package/src/lib/pythonize.pyj +20 -20
  46. package/src/lib/random.pyj +118 -118
  47. package/src/lib/re.pyj +470 -470
  48. package/src/lib/react.pyj +74 -0
  49. package/src/lib/traceback.pyj +63 -63
  50. package/src/lib/uuid.pyj +77 -77
  51. package/src/monaco-language-service/analyzer.js +131 -9
  52. package/src/monaco-language-service/builtins.js +17 -2
  53. package/src/monaco-language-service/completions.js +170 -1
  54. package/src/monaco-language-service/diagnostics.js +25 -3
  55. package/src/monaco-language-service/dts.js +550 -550
  56. package/src/monaco-language-service/index.js +17 -0
  57. package/src/monaco-language-service/scope.js +3 -0
  58. package/src/output/classes.pyj +128 -11
  59. package/src/output/codegen.pyj +17 -3
  60. package/src/output/comments.pyj +45 -45
  61. package/src/output/exceptions.pyj +201 -105
  62. package/src/output/functions.pyj +13 -16
  63. package/src/output/jsx.pyj +164 -0
  64. package/src/output/literals.pyj +28 -2
  65. package/src/output/loops.pyj +0 -9
  66. package/src/output/modules.pyj +2 -5
  67. package/src/output/operators.pyj +22 -2
  68. package/src/output/statements.pyj +2 -2
  69. package/src/output/stream.pyj +1 -13
  70. package/src/output/treeshake.pyj +182 -182
  71. package/src/output/utils.pyj +72 -72
  72. package/src/parse.pyj +434 -114
  73. package/src/string_interpolation.pyj +72 -72
  74. package/src/tokenizer.pyj +29 -0
  75. package/src/unicode_aliases.pyj +576 -576
  76. package/src/utils.pyj +192 -192
  77. package/test/_import_one.pyj +37 -37
  78. package/test/_import_two/__init__.pyj +11 -11
  79. package/test/_import_two/level2/deep.pyj +4 -4
  80. package/test/_import_two/other.pyj +6 -6
  81. package/test/_import_two/sub.pyj +13 -13
  82. package/test/aes_vectors.pyj +421 -421
  83. package/test/annotations.pyj +80 -80
  84. package/test/baselib.pyj +4 -4
  85. package/test/classes.pyj +56 -17
  86. package/test/collections.pyj +5 -5
  87. package/test/decorators.pyj +77 -77
  88. package/test/docstrings.pyj +39 -39
  89. package/test/elementmaker_test.pyj +45 -45
  90. package/test/functions.pyj +151 -151
  91. package/test/generators.pyj +41 -41
  92. package/test/generic.pyj +370 -370
  93. package/test/imports.pyj +72 -72
  94. package/test/internationalization.pyj +73 -73
  95. package/test/lint.pyj +164 -164
  96. package/test/loops.pyj +85 -85
  97. package/test/numpy.pyj +734 -734
  98. package/test/omit_function_metadata.pyj +20 -20
  99. package/test/python_compat.pyj +326 -0
  100. package/test/python_features.pyj +129 -29
  101. package/test/regexp.pyj +55 -55
  102. package/test/repl.pyj +121 -121
  103. package/test/scoped_flags.pyj +76 -76
  104. package/test/slice.pyj +105 -0
  105. package/test/str.pyj +25 -0
  106. package/test/unit/fixtures/fibonacci_expected.js +1 -1
  107. package/test/unit/index.js +2296 -71
  108. package/test/unit/language-service-builtins.js +70 -0
  109. package/test/unit/language-service-bundle.js +5 -5
  110. package/test/unit/language-service-completions.js +180 -0
  111. package/test/unit/language-service-dts.js +543 -543
  112. package/test/unit/language-service-hover.js +455 -455
  113. package/test/unit/language-service-index.js +350 -0
  114. package/test/unit/language-service-scope.js +255 -0
  115. package/test/unit/language-service.js +625 -4
  116. package/test/unit/run-language-service.js +1 -0
  117. package/test/unit/web-repl.js +437 -0
  118. package/tools/build-language-service.js +2 -2
  119. package/tools/cli.js +547 -547
  120. package/tools/compile.js +219 -219
  121. package/tools/compiler.js +0 -24
  122. package/tools/completer.js +131 -131
  123. package/tools/embedded_compiler.js +251 -251
  124. package/tools/export.js +3 -37
  125. package/tools/gettext.js +185 -185
  126. package/tools/ini.js +65 -65
  127. package/tools/msgfmt.js +187 -187
  128. package/tools/repl.js +223 -223
  129. package/tools/test.js +118 -118
  130. package/tools/utils.js +128 -128
  131. package/tools/web_repl.js +95 -95
  132. package/try +41 -41
  133. package/web-repl/env.js +196 -74
  134. package/web-repl/index.html +163 -163
  135. package/web-repl/main.js +252 -254
  136. package/web-repl/prism.css +139 -139
  137. package/web-repl/prism.js +113 -113
  138. package/web-repl/rapydscript.js +227 -139
  139. package/web-repl/sha1.js +25 -25
  140. package/hack_demo.pyj +0 -112
  141. package/web-repl/language-service.js +0 -4187
package/TODO.md CHANGED
@@ -1,296 +1,14 @@
1
1
 
2
2
  ### libraries
3
3
 
4
- - bitburner - handle missed await / concurrency errors gracefully?
5
- - two space tabs
6
-
7
- - fix error from vuln report
8
- - https://socket.dev/npm/package/rapydscript-ns/alerts/0.8.1?tab=dependencies
9
- - https://snyk.io/test/github/ficocelliguy/rapydscript-ns
4
+ - simple way to turn on all python opt-in options
10
5
 
11
6
  - omit_function_metadata breaks imports - it needs to be changed to only affect imported modules, maybe?
12
7
 
13
- - vscode plugin based on language service
14
-
15
- - export .t.ds for language service
16
-
17
- - add opt-out for python truthyness
18
- - add web-repl flag for python truthiness?
19
- - include python truthiness in compiler call
20
-
21
- - update changelist for 8.0
22
-
23
- I would like you to add support for [ Python's extended subscript syntax where commas inside [] implicitly form a tuple ] to rapydscript. It should have the same syntax as the Python implementation, and be transpiled into equivalent javascript. Please ensure with unit tests that it transpiles and the output JS runs correctly, and that the language service correctly handles it in parsed code. Please make sure it works in the web-repl too. Please also update the README to mention this support.
24
-
25
-
26
-
27
-
28
- Python Feature Gap Report: RapydScript-NS
29
-
30
- Summary
31
-
32
- RapydScript-NS covers the vast majority of Python 2/3 core syntax well. The gaps fall into four categories: modern Python syntax, OOP/protocol features, standard library modules, and semantic
33
- differences.
34
-
35
- ---
36
- 1. Modern Python Syntax (Not Supported)
37
-
38
- ┌───────────────────────────────────────────────┬────────────────┬──────────────────────────────────────────────────────────────┐
39
- │ Feature │ Python Version │ Notes │
40
- ├───────────────────────────────────────────────┼────────────────┼──────────────────────────────────────────────────────────────┤
41
- │ match/case (structural pattern matching) │ 3.10+ │ -tested │
42
- ├───────────────────────────────────────────────┼────────────────┼──────────────────────────────────────────────────────────────┤
43
- │ Walrus operator := │ 3.8+ │ -tested │
44
- ├───────────────────────────────────────────────┼────────────────┼──────────────────────────────────────────────────────────────┤
45
- │ lambda keyword │ all │ -tested │
46
- ├───────────────────────────────────────────────┼────────────────┼──────────────────────────────────────────────────────────────┤
47
- │ Variable type annotations x: int = 1 │ 3.6+ │ -tested │
48
- ├───────────────────────────────────────────────┼────────────────┼──────────────────────────────────────────────────────────────┤
49
- │ Positional-only parameters (def f(a, /, b):) │ 3.8+ │ -tested │
50
- ├───────────────────────────────────────────────┼────────────────┼──────────────────────────────────────────────────────────────┤
51
- │ Keyword-only parameters (def f(a, *, b):) │ 3.0+ │ -tested │
52
- ├───────────────────────────────────────────────┼────────────────┼──────────────────────────────────────────────────────────────┤
53
- │ Starred assignment a, *b, c = [1,2,3,4,5] │ 3.0+ │ -tested │
54
- ├───────────────────────────────────────────────┼────────────────┼──────────────────────────────────────────────────────────────┤
55
- │ Dict merge literal {**d1, **d2} │ 3.5+ │ -tested │
56
- ├───────────────────────────────────────────────┼────────────────┼──────────────────────────────────────────────────────────────┤
57
- │ Parenthesized with (multi-context) │ 3.10+ │ - doesn't make sense in a web context │
58
- ├───────────────────────────────────────────────┼────────────────┼──────────────────────────────────────────────────────────────┤
59
- │ Exception chaining raise X from Y │ 3.0+ │ - done │
60
- ├───────────────────────────────────────────────┼────────────────┼──────────────────────────────────────────────────────────────┤
61
- │ except* (exception groups) │ 3.11+ │ No support │
62
- ├───────────────────────────────────────────────┼────────────────┼──────────────────────────────────────────────────────────────┤
63
- │ Nested comprehensions (for a in b for c in d) │ all │ -tested │
64
- ├───────────────────────────────────────────────┼────────────────┼──────────────────────────────────────────────────────────────┤
65
- │ Complex number literals 3+4j │ all │ No j suffix │
66
- ├───────────────────────────────────────────────┼────────────────┼──────────────────────────────────────────────────────────────┤
67
- │ Ellipsis literal ... as expression │ all │ -tested │
68
- ├───────────────────────────────────────────────┼────────────────┼──────────────────────────────────────────────────────────────┤
69
- │ b'...' bytes literals │ all │ No b prefix; encoding module exists but no native bytes type │
70
- └───────────────────────────────────────────────┴────────────────┴──────────────────────────────────────────────────────────────┘
71
-
72
- ---
73
- 2. OOP and Dunder Protocol Gaps
74
-
75
- Not Supported at All
76
-
77
- ┌─────────────────────────────────────────┬─────────────────────────────────────────────────────────────────┐
78
- │ Feature │ Notes │
79
- ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────┤
80
- │ super() │ -tested │
81
- ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────┤
82
- │ __new__ │ No alternative constructor support │
83
- ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────┤
84
- │ __del__ │ No destructor/finalizer │
85
- ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────┤
86
- │ __hash__ │ Explicitly noted as not implemented; set/dict uses === identity │
87
- ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────┤
88
- │ __bool__ │ Empty [] and {} are truthy in JS (differs from Python) │
89
- ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────┤
90
- │ __call__ │ Objects cannot be made callable via dunder │
91
- ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────┤
92
- │ __getattr__ / __setattr__ / __delattr__ │ No attribute access interception │
93
- ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────┤
94
- │ __getattribute__ │ No attribute lookup overriding │
95
- ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────┤
96
- │ __format__ │ No custom format() behavior │
97
- ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────┤
98
- │ __slots__ │ No slot declarations │
99
- ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────┤
100
- │ __class_getitem__ │ No MyClass[T] generic syntax support │
101
- ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────┤
102
- │ __init_subclass__ │ No subclass hooks │
103
- ├─────────────────────────────────────────┼─────────────────────────────────────────────────────────────────┤
104
- │ classmethod decorator │ Not tested/documented (may partially work via @staticmethod) │
105
- └─────────────────────────────────────────┴─────────────────────────────────────────────────────────────────┘
106
-
107
- Arithmetic/Comparison Operator Overloading
108
-
109
- All of these dunder methods are not dispatched — operators always use JS native semantics:
110
-
111
- __add__, __radd__, __sub__, __mul__, __truediv__, __floordiv__, __mod__, __pow__, __lt__, __le__, __gt__, __ge__, __ne__, __neg__, __pos__, __abs__, __invert__, __lshift__, __rshift__, __and__,
112
- __or__, __xor__
113
-
114
- (Only __eq__, __contains__, __iter__, __len__, __enter__, __exit__, __repr__, __str__ are dispatched)
115
-
116
- Nested Classes
117
-
118
- Noted in test file (test/classes.pyj) as "not yet fully implemented."
119
-
120
- Abstract Base Classes (ABCs)
121
-
122
- No abc module, no @abstractmethod, no Protocol support.
123
-
124
- ---
125
- 3. Built-in Functions Missing
126
-
127
- ┌──────────────────────────┬────────────────────────────────────────────────┐
128
- │ Function │ Notes │
129
- ├──────────────────────────┼────────────────────────────────────────────────┤
130
- │ super() │ tested │
131
- ├──────────────────────────┼────────────────────────────────────────────────┤
132
- │ issubclass() │ Not implemented │
133
- ├──────────────────────────┼────────────────────────────────────────────────┤
134
- │ hash() │ Not implemented │
135
- ├──────────────────────────┼────────────────────────────────────────────────┤
136
- │ format(value, spec) │ Not listed; str.format() works │
137
- ├──────────────────────────┼────────────────────────────────────────────────┤
138
- │ vars() │ Not listed │
139
- ├──────────────────────────┼────────────────────────────────────────────────┤
140
- │ locals() │ Not listed │
141
- ├──────────────────────────┼────────────────────────────────────────────────┤
142
- │ globals() │ Not listed │
143
- ├──────────────────────────┼────────────────────────────────────────────────┤
144
- │ exec() │ Not listed (JS eval works directly via v'...') │
145
- ├──────────────────────────┼────────────────────────────────────────────────┤
146
- │ eval() │ Not listed │
147
- ├──────────────────────────┼────────────────────────────────────────────────┤
148
- │ compile() │ N/A │
149
- ├──────────────────────────┼────────────────────────────────────────────────┤
150
- │ __import__() │ Not supported │
151
- ├──────────────────────────┼────────────────────────────────────────────────┤
152
- │ input() │ Not built in │
153
- ├──────────────────────────┼────────────────────────────────────────────────┤
154
- │ open() │ Not built in │
155
- ├──────────────────────────┼────────────────────────────────────────────────┤
156
- │ bytes() / bytearray() │ Not built in │
157
- ├──────────────────────────┼────────────────────────────────────────────────┤
158
- │ memoryview() │ N/A (browser context) │
159
- ├──────────────────────────┼────────────────────────────────────────────────┤
160
- │ zip(..., strict=True) │ strict kwarg not supported │
161
- ├──────────────────────────┼────────────────────────────────────────────────┤
162
- │ enumerate(x, start=N) │ start parameter may not be supported │
163
- ├──────────────────────────┼────────────────────────────────────────────────┤
164
- │ all() / any() │ tested │
165
- ├──────────────────────────┼────────────────────────────────────────────────┤
166
- │ next(iter, default?) │ Not listed │
167
- ├──────────────────────────┼────────────────────────────────────────────────┤
168
- │ iter(callable, sentinel) │ Two-arg form likely not supported │
169
- ├──────────────────────────┼────────────────────────────────────────────────┤
170
- │ round(x, ndigits?) │ Not listed │
171
- ├──────────────────────────┼────────────────────────────────────────────────┤
172
- │ slice() │ Not listed as builtin object │
173
- ├──────────────────────────┼────────────────────────────────────────────────┤
174
- │ frozenset() │ Not listed │
175
- ├──────────────────────────┼────────────────────────────────────────────────┤
176
- │ complex() │ Not listed │
177
- ├──────────────────────────┼────────────────────────────────────────────────┤
178
- │ object() │ Not listed │
179
- └──────────────────────────┴────────────────────────────────────────────────┘
180
-
181
- ---
182
- 4. Standard Library Modules Missing
183
-
184
- These are Python stdlib modules with no equivalent in src/lib/:
185
-
186
- ┌─────────────┬─────────────────────────────────────────────────────────────────────────────────┐
187
- │ Module │ What's Missing │
188
- ├─────────────┼─────────────────────────────────────────────────────────────────────────────────┤
189
- │ collections │ tested │
190
- ├─────────────┼─────────────────────────────────────────────────────────────────────────────────┤
191
- │ functools │ tested │
192
- ├─────────────┼─────────────────────────────────────────────────────────────────────────────────┤
193
- │ itertools │ tested │
194
- ├─────────────┼─────────────────────────────────────────────────────────────────────────────────┤
195
- │ typing │ List, Dict, Optional, Union, Tuple, Generic, TypeVar, etc. │
196
- ├─────────────┼─────────────────────────────────────────────────────────────────────────────────┤
197
- │ dataclasses │ @dataclass, field(), asdict(), astuple() │
198
- ├─────────────┼─────────────────────────────────────────────────────────────────────────────────┤
199
- │ contextlib │ contextmanager, suppress, ExitStack, asynccontextmanager │
200
- ├─────────────┼─────────────────────────────────────────────────────────────────────────────────┤
201
- │ copy │ copy(), deepcopy() │
202
- ├─────────────┼─────────────────────────────────────────────────────────────────────────────────┤
203
- │ string │ Character constants, Template, Formatter │
204
- ├─────────────┼─────────────────────────────────────────────────────────────────────────────────┤
205
- │ json │ dumps, loads (JS JSON works directly, but no Python wrapper) │
206
- ├─────────────┼─────────────────────────────────────────────────────────────────────────────────┤
207
- │ datetime │ date, time, datetime, timedelta │
208
- ├─────────────┼─────────────────────────────────────────────────────────────────────────────────┤
209
- │ inspect │ signature, getmembers, isfunction, etc. │
210
- ├─────────────┼─────────────────────────────────────────────────────────────────────────────────┤
211
- │ asyncio │ Event loop, gather, sleep, Queue, Task wrappers │
212
- ├─────────────┼─────────────────────────────────────────────────────────────────────────────────┤
213
- │ enum │ Enum, IntEnum, Flag │
214
- ├─────────────┼─────────────────────────────────────────────────────────────────────────────────┤
215
- │ abc │ ABC, abstractmethod │
216
- ├─────────────┼─────────────────────────────────────────────────────────────────────────────────┤
217
- │ io │ StringIO, BytesIO │
218
- ├─────────────┼─────────────────────────────────────────────────────────────────────────────────┤
219
- │ struct │ Binary packing/unpacking │
220
- ├─────────────┼─────────────────────────────────────────────────────────────────────────────────┤
221
- │ hashlib │ MD5, SHA-256, etc. │
222
- ├─────────────┼─────────────────────────────────────────────────────────────────────────────────┤
223
- │ hmac │ Keyed hashing │
224
- ├─────────────┼─────────────────────────────────────────────────────────────────────────────────┤
225
- │ base64 │ (partial — encodings module exists) │
226
- ├─────────────┼─────────────────────────────────────────────────────────────────────────────────┤
227
- │ urllib │ URL parsing/encoding (no urllib.parse) │
228
- ├─────────────┼─────────────────────────────────────────────────────────────────────────────────┤
229
- │ html │ escape, unescape │
230
- ├─────────────┼─────────────────────────────────────────────────────────────────────────────────┤
231
- │ csv │ CSV parsing │
232
- ├─────────────┼─────────────────────────────────────────────────────────────────────────────────┤
233
- │ textwrap │ wrap, fill, dedent, indent │
234
- ├─────────────┼─────────────────────────────────────────────────────────────────────────────────┤
235
- │ pprint │ Pretty-printing │
236
- ├─────────────┼─────────────────────────────────────────────────────────────────────────────────┤
237
- │ logging │ Logging framework │
238
- ├─────────────┼─────────────────────────────────────────────────────────────────────────────────┤
239
- │ unittest │ Test framework (custom runner used instead) │
240
- └─────────────┴─────────────────────────────────────────────────────────────────────────────────┘
241
-
242
- ---
243
- 5. Semantic Differences (Traps)
244
-
245
- These features exist but behave differently from Python:
246
-
247
- ┌─────────────────────────┬────────────────────────────────────────────┬─────────────────────────────────────────────────────────────────────────────────┐
248
- │ Feature │ Python Behavior │ RapydScript Behavior │
249
- ├─────────────────────────┼────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────┤
250
- │ Truthiness of [] │ False │ True (JS semantics) │
251
- ├─────────────────────────┼────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────┤
252
- │ Truthiness of {} │ False │ True (JS semantics) │
253
- ├─────────────────────────┼────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────┤
254
- │ is / is not │ Object identity │ Strict equality === / !== │
255
- ├─────────────────────────┼────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────┤
256
- │ // on floats │ math.floor(a/b) │ Correct for integers; JS Math.floor used │
257
- ├─────────────────────────┼────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────┤
258
- │ % on negative numbers │ Python modulo (always positive) │ JS remainder (can be negative) │
259
- ├─────────────────────────┼────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────┤
260
- │ int / float distinction │ Separate types │ Both are JS number │
261
- ├─────────────────────────┼────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────┤
262
- │ String * repetition │ 'a' * 3 == 'aaa' │ Requires pythonize module or JS-side workaround │
263
- ├─────────────────────────┼────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────┤
264
- │ sort() / pop() │ Standard list methods │ Renamed to pysort() / pypop() │
265
- ├─────────────────────────┼────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────┤
266
- │ Method binding │ Unbound by default, self passed explicitly │ Same — but differs if you store methods in variables without bound_methods flag │
267
- ├─────────────────────────┼────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────┤
268
- │ dict key ordering │ Insertion order (3.7+) │ Depends on JS engine (V8: insertion order) │
269
- ├─────────────────────────┼────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────┤
270
- │ global scoping │ Full cross-scope declaration │ Partial — interactions with nonlocal can be confusing │
271
- ├─────────────────────────┼────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────┤
272
- │ Exception .message │ Not standard (Python uses .args[0]) │ .message is standard (JS style) │
273
- ├─────────────────────────┼────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────┤
274
- │ re module │ Full PCRE features │ No lookbehind, limited unicode, no (?(1)...) │
275
- └─────────────────────────┴────────────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────────────┘
276
-
277
- ---
278
- Priority Gaps (Most Impactful)
279
-
280
- If prioritizing what to implement next, these have the highest user impact:
8
+ - vscode plugin based on language service?
281
9
 
282
- 1. super() required for idiomatic OOP code - done
283
- 2. Operator overloading (__add__, __lt__, etc.) — blocks numerical/scientific code - done
284
- 3. __bool__ / truthiness fix — silent Python compatibility trap - done
285
- → frozenset — first medium-priority missing builtin - done
286
- 4. lambda keyword — commonly expected - done
287
- 5. all() / any() — extremely common builtins - done
288
- 6. functools.reduce / partial — core functional programming tools - done
289
- 7. collections.defaultdict / Counter — frequently used - done
290
- 8. Nested comprehensions — common Python pattern - done
291
- 9. Walrus operator := — increasingly common in modern Python - done
292
- 10. classmethod decorator — standard OOP pattern - done
10
+ - examples of using js libraries in rapydscript in readme?
293
11
 
294
12
 
13
+ I would like you to add support for [`str.expandtabs(tabsize)` ] to rapydscript. It should have the same syntax as the Python implementation, and be transpiled into equivalent javascript. Please ensure with unit tests that it transpiles and the output JS runs correctly, and that the language service correctly handles it in parsed code. Please make sure it works in the web-repl too. Please also update the README if it has any outdated info about this, and the PYTHON_FEATURE_COVERAGE report. Please also add a simple example to the bottom of the TODO document using this feature (make no other changes to that file).
295
14
 
296
-
package/add-toc-to-readme CHANGED
@@ -1,2 +1,2 @@
1
- #!/bin/sh
2
- exec node_modules/doctoc/doctoc.js --title '**Contents**' README.md
1
+ #!/bin/sh
2
+ exec node_modules/doctoc/doctoc.js --title '**Contents**' README.md
package/bin/export CHANGED
@@ -1,75 +1,75 @@
1
- #!/usr/bin/env node
2
- // vim:ft=javascript:ts=4:et
3
-
4
- "use strict";
5
-
6
- var fs = require('fs');
7
- var path = require('path');
8
- var crypto = require('crypto');
9
-
10
- var base = path.join(path.dirname(__dirname));
11
- var meta = JSON.parse(fs.readFileSync(path.join(base, 'package.json'), {'encoding':'utf-8'}));
12
- var compiler_dir = path.join(base, 'dev');
13
- if (!path_exists(path.join(compiler_dir, 'compiler.js'))) compiler_dir = path.join(base, 'release');
14
-
15
- var manifest = {}, total = 0;
16
- ['compiler.js', 'baselib-plain-pretty.js', 'baselib-plain-ugly.js'].forEach(function(x) {
17
- manifest[x] = fs.readFileSync(path.join(compiler_dir, x), {'encoding':'utf-8'});
18
- total += manifest[x].length;
19
- });
20
-
21
- ['web_repl.js', 'repl.js', 'completer.js', 'utils.js', 'gettext.js', 'msgfmt.js'].forEach(function(x) {
22
- x = 'tools/' + x;
23
- manifest[x] = fs.readFileSync(path.join(base, x), {'encoding':'utf-8'});
24
- total += manifest[x].length;
25
- });
26
-
27
-
28
- var dedup = {};
29
-
30
- function path_exists(path) {
31
- try {
32
- fs.statSync(path);
33
- return true;
34
- } catch(e) {
35
- if (e.code != 'ENOENT') throw e;
36
- }
37
- }
38
-
39
- function sha1sum(data) {
40
- var h = crypto.createHash('sha1');
41
- h.update(data);
42
- return h.digest('hex');
43
- }
44
-
45
- function process_dir(name) {
46
- var dpath = path.join(base, name);
47
- var items = fs.readdirSync(dpath);
48
- items.forEach(function (x) {
49
- var iname = name + '/' + x;
50
- var ipath = path.join(dpath, x);
51
- var s = fs.statSync(ipath);
52
- if (s.isDirectory()) return process_dir(iname);
53
- var raw = fs.readFileSync(ipath, {'encoding':'utf-8'});
54
- var sig = sha1sum(raw);
55
- if (dedup.hasOwnProperty(sig)) {
56
- manifest[iname] = [dedup[sig]];
57
- } else {
58
- manifest[iname] = raw;
59
- dedup[sig] = iname;
60
- total += s.size;
61
- }
62
- });
63
- }
64
-
65
- Object.keys(meta.dependencies).forEach(function (x) {
66
- process_dir('node_modules/' + x);
67
- });
68
- console.log('// vim:fileencoding=utf-8');
69
- console.log('(function() {');
70
- console.log('var rs_version = ' + JSON.stringify(meta.version) + ';');
71
- console.log('var data = ' + JSON.stringify(manifest) + ';');
72
- console.log();
73
- console.log(fs.readFileSync(path.join(base, 'tools', 'export.js'), {'encoding':'utf-8'}));
74
- console.log('})()');
75
- console.error('RapydScript compiler (uncompressed) size: ' + (total/(1024 * 1024)).toFixed(1) + ' MB');
1
+ #!/usr/bin/env node
2
+ // vim:ft=javascript:ts=4:et
3
+
4
+ "use strict";
5
+
6
+ var fs = require('fs');
7
+ var path = require('path');
8
+ var crypto = require('crypto');
9
+
10
+ var base = path.join(path.dirname(__dirname));
11
+ var meta = JSON.parse(fs.readFileSync(path.join(base, 'package.json'), {'encoding':'utf-8'}));
12
+ var compiler_dir = path.join(base, 'dev');
13
+ if (!path_exists(path.join(compiler_dir, 'compiler.js'))) compiler_dir = path.join(base, 'release');
14
+
15
+ var manifest = {}, total = 0;
16
+ ['compiler.js', 'baselib-plain-pretty.js', 'baselib-plain-ugly.js'].forEach(function(x) {
17
+ manifest[x] = fs.readFileSync(path.join(compiler_dir, x), {'encoding':'utf-8'});
18
+ total += manifest[x].length;
19
+ });
20
+
21
+ ['web_repl.js', 'repl.js', 'completer.js', 'utils.js', 'gettext.js', 'msgfmt.js'].forEach(function(x) {
22
+ x = 'tools/' + x;
23
+ manifest[x] = fs.readFileSync(path.join(base, x), {'encoding':'utf-8'});
24
+ total += manifest[x].length;
25
+ });
26
+
27
+
28
+ var dedup = {};
29
+
30
+ function path_exists(path) {
31
+ try {
32
+ fs.statSync(path);
33
+ return true;
34
+ } catch(e) {
35
+ if (e.code != 'ENOENT') throw e;
36
+ }
37
+ }
38
+
39
+ function sha1sum(data) {
40
+ var h = crypto.createHash('sha1');
41
+ h.update(data);
42
+ return h.digest('hex');
43
+ }
44
+
45
+ function process_dir(name) {
46
+ var dpath = path.join(base, name);
47
+ var items = fs.readdirSync(dpath);
48
+ items.forEach(function (x) {
49
+ var iname = name + '/' + x;
50
+ var ipath = path.join(dpath, x);
51
+ var s = fs.statSync(ipath);
52
+ if (s.isDirectory()) return process_dir(iname);
53
+ var raw = fs.readFileSync(ipath, {'encoding':'utf-8'});
54
+ var sig = sha1sum(raw);
55
+ if (dedup.hasOwnProperty(sig)) {
56
+ manifest[iname] = [dedup[sig]];
57
+ } else {
58
+ manifest[iname] = raw;
59
+ dedup[sig] = iname;
60
+ total += s.size;
61
+ }
62
+ });
63
+ }
64
+
65
+ Object.keys(meta.dependencies).forEach(function (x) {
66
+ process_dir('node_modules/' + x);
67
+ });
68
+ console.log('// vim:fileencoding=utf-8');
69
+ console.log('(function() {');
70
+ console.log('var rs_version = ' + JSON.stringify(meta.version) + ';');
71
+ console.log('var data = ' + JSON.stringify(manifest) + ';');
72
+ console.log();
73
+ console.log(fs.readFileSync(path.join(base, 'tools', 'export.js'), {'encoding':'utf-8'}));
74
+ console.log('})()');
75
+ console.error('RapydScript compiler (uncompressed) size: ' + (total/(1024 * 1024)).toFixed(1) + ' MB');