rapydscript-ns 0.9.1 → 0.9.2

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 (89) 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 +3 -1
  5. package/HACKING.md +103 -103
  6. package/LICENSE +24 -24
  7. package/README.md +1 -1
  8. package/TODO.md +117 -0
  9. package/add-toc-to-readme +2 -2
  10. package/bin/export +75 -75
  11. package/bin/rapydscript +70 -70
  12. package/bin/web-repl-export +102 -102
  13. package/build +2 -2
  14. package/language-service/index.js +7 -7
  15. package/language-service/language-service.d.ts +1 -1
  16. package/package.json +6 -2
  17. package/publish.py +37 -37
  18. package/release/compiler.js +245 -230
  19. package/release/signatures.json +22 -22
  20. package/session.vim +4 -4
  21. package/setup.cfg +2 -2
  22. package/src/compiler.pyj +36 -36
  23. package/src/errors.pyj +30 -30
  24. package/src/lib/aes.pyj +646 -646
  25. package/src/lib/copy.pyj +120 -120
  26. package/src/lib/elementmaker.pyj +83 -83
  27. package/src/lib/encodings.pyj +126 -126
  28. package/src/lib/gettext.pyj +569 -569
  29. package/src/lib/itertools.pyj +580 -580
  30. package/src/lib/math.pyj +193 -193
  31. package/src/lib/operator.pyj +11 -11
  32. package/src/lib/pythonize.pyj +20 -20
  33. package/src/lib/random.pyj +118 -118
  34. package/src/lib/react.pyj +74 -74
  35. package/src/lib/traceback.pyj +63 -63
  36. package/src/lib/uuid.pyj +77 -77
  37. package/src/monaco-language-service/diagnostics.js +2 -2
  38. package/src/monaco-language-service/dts.js +550 -550
  39. package/src/monaco-language-service/index.js +2 -2
  40. package/src/output/comments.pyj +45 -45
  41. package/src/output/exceptions.pyj +201 -201
  42. package/src/output/jsx.pyj +164 -164
  43. package/src/output/loops.pyj +9 -0
  44. package/src/output/treeshake.pyj +182 -182
  45. package/src/output/utils.pyj +72 -72
  46. package/src/string_interpolation.pyj +72 -72
  47. package/src/unicode_aliases.pyj +576 -576
  48. package/src/utils.pyj +192 -192
  49. package/test/_import_one.pyj +37 -37
  50. package/test/_import_two/__init__.pyj +11 -11
  51. package/test/_import_two/level2/deep.pyj +4 -4
  52. package/test/_import_two/other.pyj +6 -6
  53. package/test/_import_two/sub.pyj +13 -13
  54. package/test/aes_vectors.pyj +421 -421
  55. package/test/annotations.pyj +80 -80
  56. package/test/decorators.pyj +77 -77
  57. package/test/docstrings.pyj +39 -39
  58. package/test/elementmaker_test.pyj +45 -45
  59. package/test/functions.pyj +151 -151
  60. package/test/generators.pyj +41 -41
  61. package/test/generic.pyj +370 -370
  62. package/test/imports.pyj +72 -72
  63. package/test/internationalization.pyj +73 -73
  64. package/test/lint.pyj +164 -164
  65. package/test/loops.pyj +85 -85
  66. package/test/numpy.pyj +734 -734
  67. package/test/omit_function_metadata.pyj +20 -20
  68. package/test/repl.pyj +121 -121
  69. package/test/scoped_flags.pyj +76 -76
  70. package/test/unit/index.js +66 -0
  71. package/test/unit/language-service-dts.js +543 -543
  72. package/test/unit/language-service-hover.js +455 -455
  73. package/test/unit/language-service.js +1 -1
  74. package/tools/compiler.d.ts +367 -0
  75. package/tools/completer.js +131 -131
  76. package/tools/gettext.js +185 -185
  77. package/tools/ini.js +65 -65
  78. package/tools/msgfmt.js +187 -187
  79. package/tools/repl.js +223 -223
  80. package/tools/test.js +118 -118
  81. package/tools/utils.js +128 -128
  82. package/tools/web_repl.js +95 -95
  83. package/try +41 -41
  84. package/web-repl/env.js +196 -196
  85. package/web-repl/index.html +163 -163
  86. package/web-repl/prism.css +139 -139
  87. package/web-repl/prism.js +113 -113
  88. package/web-repl/rapydscript.js +224 -224
  89. package/web-repl/sha1.js +25 -25
@@ -1,80 +1,80 @@
1
- def add(a: int, b: float):
2
- return a + b
3
-
4
- assrt.ok(add.__annotations__)
5
- assrt.equal(add.__annotations__['a'], int)
6
- assrt.equal(add.__annotations__['b'], float)
7
- assrt.equal(add.__annotations__['return'], undefined)
8
-
9
- def sum(ls: list) -> int:
10
- pass
11
-
12
- assrt.ok(not (sum.__annotations__ == undefined))
13
- assrt.deepEqual(sum.__annotations__, {
14
- 'ls': list,
15
- 'return': int
16
- })
17
-
18
- def optional(a:int=10):
19
- return a
20
-
21
- assrt.ok(not (optional.__annotations__ == undefined))
22
- assrt.equal(optional.__annotations__.a, int)
23
- assrt.equal(optional.__defaults__.a, 10)
24
-
25
- def otherexpr(a:3+4) -> [1, 2]:
26
- pass
27
-
28
- assrt.ok(not (otherexpr.__annotations__ == undefined))
29
- assrt.equal(otherexpr.__annotations__['a'], 7)
30
- assrt.deepEqual(otherexpr.__annotations__['return'], [1, 2])
31
-
32
- def basic(x:float):
33
- pass
34
-
35
- assrt.deepEqual(basic.__annotations__, {
36
- 'x': float
37
- })
38
-
39
- def kwstarargs(*args:list, **kwargs:dict) -> int:
40
- pass
41
-
42
- assrt.equal(kwstarargs.__annotations__['return'], int)
43
-
44
- def nothing():
45
- pass
46
-
47
- assrt.ok(nothing.__annotations__ == undefined)
48
- assrt.throws(def():
49
- nothing.__annotations__['return']
50
- )
51
-
52
- test = def(x: int):
53
- pass
54
-
55
- assrt.deepEqual(test.__annotations__, {
56
- 'x': int
57
- })
58
-
59
- anonreturn = def() -> 'test':
60
- pass
61
-
62
- assrt.equal(anonreturn.__annotations__['return'], 'test')
63
-
64
- assrt.equal(def asexpr(a: int):
65
- a
66
- .__annotations__['a'], int)
67
-
68
- assrt.deepEqual(def(a: int) -> float:
69
- a + 10.0
70
- .__annotations__, {
71
- 'a': int,
72
- 'return': float
73
- })
74
-
75
- class A:
76
-
77
- def f(self, a : int, b: 'x') -> float:
78
- pass
79
-
80
- assrt.deepEqual(A.prototype.f.__annotations__, {'a':int, 'b':'x', 'return': float})
1
+ def add(a: int, b: float):
2
+ return a + b
3
+
4
+ assrt.ok(add.__annotations__)
5
+ assrt.equal(add.__annotations__['a'], int)
6
+ assrt.equal(add.__annotations__['b'], float)
7
+ assrt.equal(add.__annotations__['return'], undefined)
8
+
9
+ def sum(ls: list) -> int:
10
+ pass
11
+
12
+ assrt.ok(not (sum.__annotations__ == undefined))
13
+ assrt.deepEqual(sum.__annotations__, {
14
+ 'ls': list,
15
+ 'return': int
16
+ })
17
+
18
+ def optional(a:int=10):
19
+ return a
20
+
21
+ assrt.ok(not (optional.__annotations__ == undefined))
22
+ assrt.equal(optional.__annotations__.a, int)
23
+ assrt.equal(optional.__defaults__.a, 10)
24
+
25
+ def otherexpr(a:3+4) -> [1, 2]:
26
+ pass
27
+
28
+ assrt.ok(not (otherexpr.__annotations__ == undefined))
29
+ assrt.equal(otherexpr.__annotations__['a'], 7)
30
+ assrt.deepEqual(otherexpr.__annotations__['return'], [1, 2])
31
+
32
+ def basic(x:float):
33
+ pass
34
+
35
+ assrt.deepEqual(basic.__annotations__, {
36
+ 'x': float
37
+ })
38
+
39
+ def kwstarargs(*args:list, **kwargs:dict) -> int:
40
+ pass
41
+
42
+ assrt.equal(kwstarargs.__annotations__['return'], int)
43
+
44
+ def nothing():
45
+ pass
46
+
47
+ assrt.ok(nothing.__annotations__ == undefined)
48
+ assrt.throws(def():
49
+ nothing.__annotations__['return']
50
+ )
51
+
52
+ test = def(x: int):
53
+ pass
54
+
55
+ assrt.deepEqual(test.__annotations__, {
56
+ 'x': int
57
+ })
58
+
59
+ anonreturn = def() -> 'test':
60
+ pass
61
+
62
+ assrt.equal(anonreturn.__annotations__['return'], 'test')
63
+
64
+ assrt.equal(def asexpr(a: int):
65
+ a
66
+ .__annotations__['a'], int)
67
+
68
+ assrt.deepEqual(def(a: int) -> float:
69
+ a + 10.0
70
+ .__annotations__, {
71
+ 'a': int,
72
+ 'return': float
73
+ })
74
+
75
+ class A:
76
+
77
+ def f(self, a : int, b: 'x') -> float:
78
+ pass
79
+
80
+ assrt.deepEqual(A.prototype.f.__annotations__, {'a':int, 'b':'x', 'return': float})
@@ -1,77 +1,77 @@
1
- # vim:fileencoding=utf-8
2
- # License: BSD Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
3
-
4
- def double(f):
5
- return def (x):
6
- return 2 * f(x)
7
-
8
- def triple(f):
9
- return def(x):
10
- return 3 * f(x)
11
-
12
- @double
13
- def half(x):
14
- return x // 2
15
-
16
- @double
17
- def f1(x):
18
- return x
19
-
20
- @double
21
- @triple
22
- def f2(x):
23
- return x
24
-
25
- def append_one(f):
26
- return def(x):
27
- ans = f(x)
28
- ans.push(1)
29
- return ans
30
-
31
- def append_two(f):
32
- return def(x):
33
- ans = f(x)
34
- ans.push(2)
35
- return ans
36
-
37
- @append_two
38
- @append_one
39
- def f3():
40
- return []
41
-
42
- o = {'double':double}
43
-
44
- @o.double
45
- def f4():
46
- return 1
47
-
48
- assrt.equal(2, half(2))
49
- assrt.equal(4, f1(2))
50
- assrt.equal(12, f2(2))
51
- assrt.equal(2, f4())
52
- assrt.deepEqual([1, 2], f3())
53
-
54
- def multiply(amt):
55
-
56
- def wrapper(f):
57
- return def ():
58
- return amt * f()
59
-
60
- return wrapper
61
-
62
- @multiply(2)
63
- def two():
64
- return 1
65
-
66
- @multiply(3)
67
- def three():
68
- return 1
69
-
70
- @multiply(2)
71
- @multiply(2)
72
- def four():
73
- return 1
74
-
75
- assrt.equal(2, two())
76
- assrt.equal(3, three())
77
- assrt.equal(4, four())
1
+ # vim:fileencoding=utf-8
2
+ # License: BSD Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
3
+
4
+ def double(f):
5
+ return def (x):
6
+ return 2 * f(x)
7
+
8
+ def triple(f):
9
+ return def(x):
10
+ return 3 * f(x)
11
+
12
+ @double
13
+ def half(x):
14
+ return x // 2
15
+
16
+ @double
17
+ def f1(x):
18
+ return x
19
+
20
+ @double
21
+ @triple
22
+ def f2(x):
23
+ return x
24
+
25
+ def append_one(f):
26
+ return def(x):
27
+ ans = f(x)
28
+ ans.push(1)
29
+ return ans
30
+
31
+ def append_two(f):
32
+ return def(x):
33
+ ans = f(x)
34
+ ans.push(2)
35
+ return ans
36
+
37
+ @append_two
38
+ @append_one
39
+ def f3():
40
+ return []
41
+
42
+ o = {'double':double}
43
+
44
+ @o.double
45
+ def f4():
46
+ return 1
47
+
48
+ assrt.equal(2, half(2))
49
+ assrt.equal(4, f1(2))
50
+ assrt.equal(12, f2(2))
51
+ assrt.equal(2, f4())
52
+ assrt.deepEqual([1, 2], f3())
53
+
54
+ def multiply(amt):
55
+
56
+ def wrapper(f):
57
+ return def ():
58
+ return amt * f()
59
+
60
+ return wrapper
61
+
62
+ @multiply(2)
63
+ def two():
64
+ return 1
65
+
66
+ @multiply(3)
67
+ def three():
68
+ return 1
69
+
70
+ @multiply(2)
71
+ @multiply(2)
72
+ def four():
73
+ return 1
74
+
75
+ assrt.equal(2, two())
76
+ assrt.equal(3, three())
77
+ assrt.equal(4, four())
@@ -1,39 +1,39 @@
1
- # vim:fileencoding=utf-8
2
- # License: BSD Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
3
- # globals: ρσ_module_doc__
4
-
5
- import _import_one
6
-
7
- def f():
8
- " A basic docstring "
9
- pass
10
-
11
- assrt.equal(f.__doc__, 'A basic docstring')
12
- assrt.equal(_import_one.__doc__, 'Module level ds1\n\nModule level ds2\nline2\n\nModule level ds 3')
13
-
14
- def g():
15
- '''
16
- A more complex docstring:
17
- xxx
18
- yyyy
19
-
20
- the end
21
- '''
22
- pass
23
-
24
- assrt.equal(g.__doc__, 'A more complex docstring:\n xxx\n yyyy\n\nthe end')
25
-
26
- class D:
27
- ' Docstring for a class '
28
-
29
- def method(self):
30
- 'ds for a method'
31
- pass
32
-
33
- assrt.equal(D().__doc__, 'Docstring for a class')
34
- assrt.equal(D().method.__doc__, 'ds for a method')
35
-
36
- x = def():
37
- 'xxx'
38
-
39
- assrt.equal(x.__doc__, 'xxx')
1
+ # vim:fileencoding=utf-8
2
+ # License: BSD Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
3
+ # globals: ρσ_module_doc__
4
+
5
+ import _import_one
6
+
7
+ def f():
8
+ " A basic docstring "
9
+ pass
10
+
11
+ assrt.equal(f.__doc__, 'A basic docstring')
12
+ assrt.equal(_import_one.__doc__, 'Module level ds1\n\nModule level ds2\nline2\n\nModule level ds 3')
13
+
14
+ def g():
15
+ '''
16
+ A more complex docstring:
17
+ xxx
18
+ yyyy
19
+
20
+ the end
21
+ '''
22
+ pass
23
+
24
+ assrt.equal(g.__doc__, 'A more complex docstring:\n xxx\n yyyy\n\nthe end')
25
+
26
+ class D:
27
+ ' Docstring for a class '
28
+
29
+ def method(self):
30
+ 'ds for a method'
31
+ pass
32
+
33
+ assrt.equal(D().__doc__, 'Docstring for a class')
34
+ assrt.equal(D().method.__doc__, 'ds for a method')
35
+
36
+ x = def():
37
+ 'xxx'
38
+
39
+ assrt.equal(x.__doc__, 'xxx')
@@ -1,45 +1,45 @@
1
- # vim:fileencoding=utf-8
2
- # License: BSD Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
3
- # globals: assrt
4
-
5
- from elementmaker import E
6
-
7
- eq = assrt.equal
8
-
9
- def dummy_elem_eq(a, b):
10
- eq(jstype(a), jstype(b))
11
- if (jstype(a) == 'string'):
12
- eq(a, b)
13
- return
14
- eq(a.attributes.length, b.attributes.length)
15
- eq(a.children.length, b.children.length)
16
- eq(a.name, b.name)
17
- for attr in a.attributes:
18
- eq(a[attr], b[attr])
19
- for i, child in enumerate(a.children):
20
- dummy_elem_eq(child, b.children[i])
21
-
22
- q = E.div('text', id='1', class_='c', data_x='x')
23
- dummy_elem_eq(q, {'name':'div', 'children':['text'], 'attributes':{'id':'1', 'class':'c', 'data-x': 'x'}})
24
-
25
- q = E.div(
26
- E.span('a'),
27
- E.span('b'),
28
- E.a(),
29
- id='1',
30
- boolean_attr=True,
31
- )
32
- dummy_elem_eq(q, {'name':'div', 'children':[
33
- {
34
- 'name':'span',
35
- 'children':['a'], 'attributes': {}
36
- },
37
- {
38
- 'name':'span',
39
- 'children':['b'], 'attributes': {}
40
- },
41
- {
42
- 'name':'a',
43
- 'children':[], 'attributes': {}
44
- },
45
- ], 'attributes':{'id':'1', 'boolean-attr':'boolean-attr'}})
1
+ # vim:fileencoding=utf-8
2
+ # License: BSD Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
3
+ # globals: assrt
4
+
5
+ from elementmaker import E
6
+
7
+ eq = assrt.equal
8
+
9
+ def dummy_elem_eq(a, b):
10
+ eq(jstype(a), jstype(b))
11
+ if (jstype(a) == 'string'):
12
+ eq(a, b)
13
+ return
14
+ eq(a.attributes.length, b.attributes.length)
15
+ eq(a.children.length, b.children.length)
16
+ eq(a.name, b.name)
17
+ for attr in a.attributes:
18
+ eq(a[attr], b[attr])
19
+ for i, child in enumerate(a.children):
20
+ dummy_elem_eq(child, b.children[i])
21
+
22
+ q = E.div('text', id='1', class_='c', data_x='x')
23
+ dummy_elem_eq(q, {'name':'div', 'children':['text'], 'attributes':{'id':'1', 'class':'c', 'data-x': 'x'}})
24
+
25
+ q = E.div(
26
+ E.span('a'),
27
+ E.span('b'),
28
+ E.a(),
29
+ id='1',
30
+ boolean_attr=True,
31
+ )
32
+ dummy_elem_eq(q, {'name':'div', 'children':[
33
+ {
34
+ 'name':'span',
35
+ 'children':['a'], 'attributes': {}
36
+ },
37
+ {
38
+ 'name':'span',
39
+ 'children':['b'], 'attributes': {}
40
+ },
41
+ {
42
+ 'name':'a',
43
+ 'children':[], 'attributes': {}
44
+ },
45
+ ], 'attributes':{'id':'1', 'boolean-attr':'boolean-attr'}})