@alloy-js/python 0.5.0-dev.1 → 0.5.0-dev.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 (166) hide show
  1. package/dist/dev/src/components/SourceFile.js +44 -32
  2. package/dist/dev/src/components/SourceFile.js.map +1 -1
  3. package/dist/dev/test/callsignatures.test.js +471 -297
  4. package/dist/dev/test/callsignatures.test.js.map +1 -1
  5. package/dist/dev/test/class-method-declaration.test.js +21 -10
  6. package/dist/dev/test/class-method-declaration.test.js.map +1 -1
  7. package/dist/dev/test/classdeclarations.test.js +459 -393
  8. package/dist/dev/test/classdeclarations.test.js.map +1 -1
  9. package/dist/dev/test/classinstantiations.test.js +201 -168
  10. package/dist/dev/test/classinstantiations.test.js.map +1 -1
  11. package/dist/dev/test/constructordeclaration.test.js +22 -11
  12. package/dist/dev/test/constructordeclaration.test.js.map +1 -1
  13. package/dist/dev/test/dataclassdeclarations.test.js +322 -368
  14. package/dist/dev/test/dataclassdeclarations.test.js.map +1 -1
  15. package/dist/dev/test/decoratorlist.test.js +96 -49
  16. package/dist/dev/test/decoratorlist.test.js.map +1 -1
  17. package/dist/dev/test/dundermethoddeclaration.test.js +22 -11
  18. package/dist/dev/test/dundermethoddeclaration.test.js.map +1 -1
  19. package/dist/dev/test/enums.test.js +218 -184
  20. package/dist/dev/test/enums.test.js.map +1 -1
  21. package/dist/dev/test/externals.test.js +57 -45
  22. package/dist/dev/test/externals.test.js.map +1 -1
  23. package/dist/dev/test/factories.test.js +124 -50
  24. package/dist/dev/test/factories.test.js.map +1 -1
  25. package/dist/dev/test/functioncallexpressions.test.js +199 -164
  26. package/dist/dev/test/functioncallexpressions.test.js.map +1 -1
  27. package/dist/dev/test/functiondeclaration.test.js +439 -272
  28. package/dist/dev/test/functiondeclaration.test.js.map +1 -1
  29. package/dist/dev/test/imports.test.js +273 -221
  30. package/dist/dev/test/imports.test.js.map +1 -1
  31. package/dist/dev/test/memberexpressions.test.js +1237 -972
  32. package/dist/dev/test/memberexpressions.test.js.map +1 -1
  33. package/dist/dev/test/methoddeclaration.test.js +142 -78
  34. package/dist/dev/test/methoddeclaration.test.js.map +1 -1
  35. package/dist/dev/test/namepolicies.test.js +130 -94
  36. package/dist/dev/test/namepolicies.test.js.map +1 -1
  37. package/dist/dev/test/propertydeclaration.test.js +88 -59
  38. package/dist/dev/test/propertydeclaration.test.js.map +1 -1
  39. package/dist/dev/test/pydanticclassdeclarations.test.js +299 -347
  40. package/dist/dev/test/pydanticclassdeclarations.test.js.map +1 -1
  41. package/dist/dev/test/pydocs.test.js +888 -715
  42. package/dist/dev/test/pydocs.test.js.map +1 -1
  43. package/dist/dev/test/references.test.js +42 -35
  44. package/dist/dev/test/references.test.js.map +1 -1
  45. package/dist/dev/test/sourcefiles.test.js +1109 -841
  46. package/dist/dev/test/sourcefiles.test.js.map +1 -1
  47. package/dist/dev/test/staticmethoddeclaration.test.js +21 -10
  48. package/dist/dev/test/staticmethoddeclaration.test.js.map +1 -1
  49. package/dist/dev/test/type-checking-imports.test.js +408 -359
  50. package/dist/dev/test/type-checking-imports.test.js.map +1 -1
  51. package/dist/dev/test/typereference.test.js +55 -40
  52. package/dist/dev/test/typereference.test.js.map +1 -1
  53. package/dist/dev/test/uniontypeexpression.test.js +222 -146
  54. package/dist/dev/test/uniontypeexpression.test.js.map +1 -1
  55. package/dist/dev/test/utils.js +39 -77
  56. package/dist/dev/test/utils.js.map +1 -1
  57. package/dist/dev/test/values.test.js +237 -101
  58. package/dist/dev/test/values.test.js.map +1 -1
  59. package/dist/dev/test/variables.test.js +321 -203
  60. package/dist/dev/test/variables.test.js.map +1 -1
  61. package/dist/dev/test/vitest.setup.js +2 -0
  62. package/dist/dev/test/vitest.setup.js.map +1 -0
  63. package/dist/src/components/SourceFile.d.ts +2 -2
  64. package/dist/src/components/SourceFile.d.ts.map +1 -1
  65. package/dist/src/components/SourceFile.js +12 -0
  66. package/dist/src/components/SourceFile.js.map +1 -1
  67. package/dist/test/callsignatures.test.js +346 -272
  68. package/dist/test/callsignatures.test.js.map +1 -1
  69. package/dist/test/class-method-declaration.test.js +7 -4
  70. package/dist/test/class-method-declaration.test.js.map +1 -1
  71. package/dist/test/classdeclarations.test.js +302 -288
  72. package/dist/test/classdeclarations.test.js.map +1 -1
  73. package/dist/test/classinstantiations.test.js +112 -103
  74. package/dist/test/classinstantiations.test.js.map +1 -1
  75. package/dist/test/constructordeclaration.test.js +7 -4
  76. package/dist/test/constructordeclaration.test.js.map +1 -1
  77. package/dist/test/dataclassdeclarations.test.js +134 -184
  78. package/dist/test/dataclassdeclarations.test.js.map +1 -1
  79. package/dist/test/decoratorlist.test.js +59 -36
  80. package/dist/test/decoratorlist.test.js.map +1 -1
  81. package/dist/test/dundermethoddeclaration.test.js +7 -4
  82. package/dist/test/dundermethoddeclaration.test.js.map +1 -1
  83. package/dist/test/enums.test.js +161 -159
  84. package/dist/test/enums.test.js.map +1 -1
  85. package/dist/test/externals.test.js +24 -24
  86. package/dist/test/externals.test.js.map +1 -1
  87. package/dist/test/factories.test.js +75 -33
  88. package/dist/test/factories.test.js.map +1 -1
  89. package/dist/test/functioncallexpressions.test.js +117 -106
  90. package/dist/test/functioncallexpressions.test.js.map +1 -1
  91. package/dist/test/functiondeclaration.test.js +247 -180
  92. package/dist/test/functiondeclaration.test.js.map +1 -1
  93. package/dist/test/imports.test.js +171 -143
  94. package/dist/test/imports.test.js.map +1 -1
  95. package/dist/test/memberexpressions.test.js +582 -453
  96. package/dist/test/memberexpressions.test.js.map +1 -1
  97. package/dist/test/methoddeclaration.test.js +66 -46
  98. package/dist/test/methoddeclaration.test.js.map +1 -1
  99. package/dist/test/namepolicies.test.js +90 -78
  100. package/dist/test/namepolicies.test.js.map +1 -1
  101. package/dist/test/propertydeclaration.test.js +25 -20
  102. package/dist/test/propertydeclaration.test.js.map +1 -1
  103. package/dist/test/pydanticclassdeclarations.test.js +134 -190
  104. package/dist/test/pydanticclassdeclarations.test.js.map +1 -1
  105. package/dist/test/pydocs.test.js +573 -532
  106. package/dist/test/pydocs.test.js.map +1 -1
  107. package/dist/test/references.test.js +31 -28
  108. package/dist/test/references.test.js.map +1 -1
  109. package/dist/test/sourcefiles.test.js +700 -580
  110. package/dist/test/sourcefiles.test.js.map +1 -1
  111. package/dist/test/staticmethoddeclaration.test.js +7 -4
  112. package/dist/test/staticmethoddeclaration.test.js.map +1 -1
  113. package/dist/test/type-checking-imports.test.js +297 -284
  114. package/dist/test/type-checking-imports.test.js.map +1 -1
  115. package/dist/test/typereference.test.js +29 -22
  116. package/dist/test/typereference.test.js.map +1 -1
  117. package/dist/test/uniontypeexpression.test.js +124 -88
  118. package/dist/test/uniontypeexpression.test.js.map +1 -1
  119. package/dist/test/utils.d.ts +10 -17
  120. package/dist/test/utils.d.ts.map +1 -1
  121. package/dist/test/utils.js +32 -74
  122. package/dist/test/utils.js.map +1 -1
  123. package/dist/test/values.test.js +135 -67
  124. package/dist/test/values.test.js.map +1 -1
  125. package/dist/test/variables.test.js +201 -151
  126. package/dist/test/variables.test.js.map +1 -1
  127. package/dist/test/vitest.setup.d.ts +2 -0
  128. package/dist/test/vitest.setup.d.ts.map +1 -0
  129. package/dist/test/vitest.setup.js +2 -0
  130. package/dist/test/vitest.setup.js.map +1 -0
  131. package/dist/tsconfig.tsbuildinfo +1 -1
  132. package/docs/api/components/SourceFile.md +20 -8
  133. package/package.json +2 -2
  134. package/src/components/SourceFile.tsx +6 -1
  135. package/temp/api.json +16 -2
  136. package/test/callsignatures.test.tsx +309 -283
  137. package/test/class-method-declaration.test.tsx +3 -4
  138. package/test/classdeclarations.test.tsx +263 -248
  139. package/test/classinstantiations.test.tsx +115 -109
  140. package/test/constructordeclaration.test.tsx +9 -6
  141. package/test/dataclassdeclarations.test.tsx +243 -361
  142. package/test/decoratorlist.test.tsx +78 -59
  143. package/test/dundermethoddeclaration.test.tsx +3 -4
  144. package/test/enums.test.tsx +65 -81
  145. package/test/externals.test.tsx +25 -25
  146. package/test/factories.test.tsx +64 -22
  147. package/test/functioncallexpressions.test.tsx +123 -109
  148. package/test/functiondeclaration.test.tsx +209 -148
  149. package/test/imports.test.tsx +119 -91
  150. package/test/memberexpressions.test.tsx +265 -207
  151. package/test/methoddeclaration.test.tsx +84 -63
  152. package/test/namepolicies.test.tsx +69 -69
  153. package/test/propertydeclaration.test.tsx +7 -8
  154. package/test/pydanticclassdeclarations.test.tsx +355 -487
  155. package/test/pydocs.test.tsx +531 -579
  156. package/test/references.test.tsx +24 -23
  157. package/test/sourcefiles.test.tsx +527 -492
  158. package/test/staticmethoddeclaration.test.tsx +3 -4
  159. package/test/type-checking-imports.test.tsx +206 -218
  160. package/test/typereference.test.tsx +15 -12
  161. package/test/uniontypeexpression.test.tsx +74 -61
  162. package/test/utils.tsx +26 -110
  163. package/test/values.test.tsx +82 -32
  164. package/test/variables.test.tsx +162 -142
  165. package/test/vitest.setup.ts +1 -0
  166. package/vitest.config.ts +3 -0
@@ -1,380 +1,454 @@
1
1
  import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
- import { d } from "@alloy-js/core/testing";
3
2
  import { describe, expect, it } from "vitest";
4
3
  import * as py from "../src/index.js";
5
- import { toSourceText } from "./utils.js";
4
+ import { TestOutput } from "./utils.js";
6
5
  describe("Call Signature Parameters", () => {
7
6
  it("renders simple function parameters", () => {
8
- const result = toSourceText([_$createComponent(py.CallSignatureParameters, {
9
- parameters: ["a", "b"]
10
- })]);
11
- expect(result).toRenderTo(d`
7
+ expect(_$createComponent(TestOutput, {
8
+ get children() {
9
+ return _$createComponent(py.CallSignatureParameters, {
10
+ parameters: ["a", "b"]
11
+ });
12
+ }
13
+ })).toRenderTo(`
12
14
  a, b
13
15
  `);
14
16
  });
15
17
  it("renders ParameterDescriptor parameters", () => {
16
- const result = toSourceText([_$createComponent(py.CallSignatureParameters, {
17
- parameters: [{
18
- name: "a"
19
- }, {
20
- name: "b"
21
- }]
22
- })]);
23
- expect(result).toRenderTo(d`
18
+ expect(_$createComponent(TestOutput, {
19
+ get children() {
20
+ return _$createComponent(py.CallSignatureParameters, {
21
+ parameters: [{
22
+ name: "a"
23
+ }, {
24
+ name: "b"
25
+ }]
26
+ });
27
+ }
28
+ })).toRenderTo(`
24
29
  a, b
25
30
  `);
26
31
  });
27
32
  it("renders ParameterDescriptor parameters with types", () => {
28
- const result = toSourceText([_$createComponent(py.CallSignatureParameters, {
29
- parameters: [{
30
- name: "a",
31
- type: "int"
32
- }, {
33
- name: "b",
34
- type: "str"
35
- }]
36
- })]);
37
- expect(result).toRenderTo(d`
33
+ expect(_$createComponent(TestOutput, {
34
+ get children() {
35
+ return _$createComponent(py.CallSignatureParameters, {
36
+ parameters: [{
37
+ name: "a",
38
+ type: "int"
39
+ }, {
40
+ name: "b",
41
+ type: "str"
42
+ }]
43
+ });
44
+ }
45
+ })).toRenderTo(`
38
46
  a: int, b: str
39
47
  `);
40
48
  });
41
49
  it("renders optional ParameterDescriptor parameters with types", () => {
42
- const result = toSourceText([_$createComponent(py.CallSignatureParameters, {
43
- parameters: [{
44
- name: "a",
45
- type: "int",
46
- default: null
47
- }, {
48
- name: "b",
49
- type: "str",
50
- default: null
51
- }]
52
- })]);
53
- expect(result).toRenderTo(d`
50
+ expect(_$createComponent(TestOutput, {
51
+ get children() {
52
+ return _$createComponent(py.CallSignatureParameters, {
53
+ parameters: [{
54
+ name: "a",
55
+ type: "int",
56
+ default: null
57
+ }, {
58
+ name: "b",
59
+ type: "str",
60
+ default: null
61
+ }]
62
+ });
63
+ }
64
+ })).toRenderTo(`
54
65
  a: int = None, b: str = None
55
66
  `);
56
67
  });
57
68
  it("renders optional ParameterDescriptor parameters default", () => {
58
- const result = toSourceText([_$createComponent(py.CallSignatureParameters, {
59
- parameters: [{
60
- name: "a",
61
- default: 5
62
- }, {
63
- name: "b",
64
- default: "hello"
65
- }]
66
- })]);
67
- expect(result).toRenderTo(d`
69
+ expect(_$createComponent(TestOutput, {
70
+ get children() {
71
+ return _$createComponent(py.CallSignatureParameters, {
72
+ parameters: [{
73
+ name: "a",
74
+ default: 5
75
+ }, {
76
+ name: "b",
77
+ default: "hello"
78
+ }]
79
+ });
80
+ }
81
+ })).toRenderTo(`
68
82
  a=5, b="hello"
69
83
  `);
70
84
  });
71
85
  it("renders optional ParameterDescriptor parameters with types and default", () => {
72
- const result = toSourceText([_$createComponent(py.CallSignatureParameters, {
73
- parameters: [{
74
- name: "a",
75
- type: "int",
76
- default: 5
77
- }, {
78
- name: "b",
79
- type: "str",
80
- default: "hello"
81
- }]
82
- })]);
83
- expect(result).toRenderTo(d`
86
+ expect(_$createComponent(TestOutput, {
87
+ get children() {
88
+ return _$createComponent(py.CallSignatureParameters, {
89
+ parameters: [{
90
+ name: "a",
91
+ type: "int",
92
+ default: 5
93
+ }, {
94
+ name: "b",
95
+ type: "str",
96
+ default: "hello"
97
+ }]
98
+ });
99
+ }
100
+ })).toRenderTo(`
84
101
  a: int = 5, b: str = "hello"
85
102
  `);
86
103
  });
87
104
  it("renders keyword-only parameters with * marker", () => {
88
- const result = toSourceText([_$createComponent(py.CallSignatureParameters, {
89
- parameters: [{
90
- name: "a",
91
- type: "str"
92
- }, "*", {
93
- name: "b",
94
- type: "int",
95
- default: 10
96
- }, {
97
- name: "c",
98
- type: "bool",
99
- default: true
100
- }]
101
- })]);
102
- expect(result).toRenderTo(d`
105
+ expect(_$createComponent(TestOutput, {
106
+ get children() {
107
+ return _$createComponent(py.CallSignatureParameters, {
108
+ parameters: [{
109
+ name: "a",
110
+ type: "str"
111
+ }, "*", {
112
+ name: "b",
113
+ type: "int",
114
+ default: 10
115
+ }, {
116
+ name: "c",
117
+ type: "bool",
118
+ default: true
119
+ }]
120
+ });
121
+ }
122
+ })).toRenderTo(`
103
123
  a: str, *, b: int = 10, c: bool = True
104
124
  `);
105
125
  });
106
126
  it("renders only keyword-only parameters with * marker at start", () => {
107
- const result = toSourceText([_$createComponent(py.CallSignatureParameters, {
108
- parameters: ["*", {
109
- name: "a",
110
- type: "str",
111
- default: "hello"
112
- }, {
113
- name: "b",
114
- type: "int",
115
- default: 42
116
- }]
117
- })]);
118
- expect(result).toRenderTo(d`
127
+ expect(_$createComponent(TestOutput, {
128
+ get children() {
129
+ return _$createComponent(py.CallSignatureParameters, {
130
+ parameters: ["*", {
131
+ name: "a",
132
+ type: "str",
133
+ default: "hello"
134
+ }, {
135
+ name: "b",
136
+ type: "int",
137
+ default: 42
138
+ }]
139
+ });
140
+ }
141
+ })).toRenderTo(`
119
142
  *, a: str = "hello", b: int = 42
120
143
  `);
121
144
  });
122
145
  });
123
146
  describe("Call Signature", () => {
124
147
  it("renders a call signature with strings", () => {
125
- const result = toSourceText([_$createComponent(py.CallSignature, {
126
- parameters: ["a", "b"]
127
- })]);
128
- expect(result).toRenderTo(d`
148
+ expect(_$createComponent(TestOutput, {
149
+ get children() {
150
+ return _$createComponent(py.CallSignature, {
151
+ parameters: ["a", "b"]
152
+ });
153
+ }
154
+ })).toRenderTo(`
129
155
  (a, b)
130
156
  `);
131
157
  });
132
158
  it("renders a call signature with parameter descriptors", () => {
133
- const result = toSourceText([_$createComponent(py.CallSignature, {
134
- parameters: [{
135
- name: "a"
136
- }, {
137
- name: "b"
138
- }]
139
- })]);
140
- expect(result).toRenderTo(d`
159
+ expect(_$createComponent(TestOutput, {
160
+ get children() {
161
+ return _$createComponent(py.CallSignature, {
162
+ parameters: [{
163
+ name: "a"
164
+ }, {
165
+ name: "b"
166
+ }]
167
+ });
168
+ }
169
+ })).toRenderTo(`
141
170
  (a, b)
142
171
  `);
143
172
  });
144
173
  it("renders a call signature with mixed strings and parameter descriptors", () => {
145
- const result = toSourceText([_$createComponent(py.CallSignature, {
146
- parameters: ["a", {
147
- name: "b"
148
- }]
149
- })]);
150
- expect(result).toRenderTo(d`
174
+ expect(_$createComponent(TestOutput, {
175
+ get children() {
176
+ return _$createComponent(py.CallSignature, {
177
+ parameters: ["a", {
178
+ name: "b"
179
+ }]
180
+ });
181
+ }
182
+ })).toRenderTo(`
151
183
  (a, b)
152
184
  `);
153
185
  });
154
186
  it("renders a simple call signature with args and kwargs", () => {
155
- const result = toSourceText([_$createComponent(py.CallSignature, {
156
- parameters: [{
157
- name: "a"
158
- }, {
159
- name: "b"
160
- }],
161
- args: true,
162
- kwargs: true
163
- })]);
164
- expect(result).toRenderTo(d`
187
+ expect(_$createComponent(TestOutput, {
188
+ get children() {
189
+ return _$createComponent(py.CallSignature, {
190
+ parameters: [{
191
+ name: "a"
192
+ }, {
193
+ name: "b"
194
+ }],
195
+ args: true,
196
+ kwargs: true
197
+ });
198
+ }
199
+ })).toRenderTo(`
165
200
  (a, b, *args, **kwargs)
166
201
  `);
167
202
  });
168
203
  it("renders a simple call signature with type parameters", () => {
169
- const result = toSourceText([_$createComponent(py.CallSignature, {
170
- parameters: [{
171
- name: "a"
172
- }, {
173
- name: "b"
174
- }],
175
- typeParameters: ["T", "U"]
176
- })]);
177
- expect(result).toRenderTo(d`
204
+ expect(_$createComponent(TestOutput, {
205
+ get children() {
206
+ return _$createComponent(py.CallSignature, {
207
+ parameters: [{
208
+ name: "a"
209
+ }, {
210
+ name: "b"
211
+ }],
212
+ typeParameters: ["T", "U"]
213
+ });
214
+ }
215
+ })).toRenderTo(`
178
216
  [T, U](a, b)
179
217
  `);
180
218
  });
181
219
  it("renders a simple call signature with return type", () => {
182
- const result = toSourceText([_$createComponent(py.CallSignature, {
183
- parameters: [{
184
- name: "a"
185
- }, {
186
- name: "b"
187
- }],
188
- returnType: "int"
189
- })]);
190
- expect(result).toRenderTo(d`
220
+ expect(_$createComponent(TestOutput, {
221
+ get children() {
222
+ return _$createComponent(py.CallSignature, {
223
+ parameters: [{
224
+ name: "a"
225
+ }, {
226
+ name: "b"
227
+ }],
228
+ returnType: "int"
229
+ });
230
+ }
231
+ })).toRenderTo(`
191
232
  (a, b) -> int
192
233
  `);
193
234
  });
194
235
  });
195
236
  describe("Call Signature - Parameter Descriptors", () => {
196
237
  it("renders a call signature with parameter descriptors", () => {
197
- const result = toSourceText([_$createComponent(py.CallSignature, {
198
- parameters: [{
199
- name: "a",
200
- type: "int"
201
- }, {
202
- name: "b",
203
- type: "str"
204
- }]
205
- })]);
206
- expect(result).toRenderTo(d`
238
+ expect(_$createComponent(TestOutput, {
239
+ get children() {
240
+ return _$createComponent(py.CallSignature, {
241
+ parameters: [{
242
+ name: "a",
243
+ type: "int"
244
+ }, {
245
+ name: "b",
246
+ type: "str"
247
+ }]
248
+ });
249
+ }
250
+ })).toRenderTo(`
207
251
  (a: int, b: str)
208
252
  `);
209
253
  });
210
254
  it("renders a call signature with parameter descriptors, args and kwargs", () => {
211
- const result = toSourceText([_$createComponent(py.CallSignature, {
212
- parameters: [{
213
- name: "a",
214
- type: "int"
215
- }, {
216
- name: "b",
217
- type: "str"
218
- }],
219
- args: true,
220
- kwargs: true
221
- })]);
222
- expect(result).toRenderTo(d`
255
+ expect(_$createComponent(TestOutput, {
256
+ get children() {
257
+ return _$createComponent(py.CallSignature, {
258
+ parameters: [{
259
+ name: "a",
260
+ type: "int"
261
+ }, {
262
+ name: "b",
263
+ type: "str"
264
+ }],
265
+ args: true,
266
+ kwargs: true
267
+ });
268
+ }
269
+ })).toRenderTo(`
223
270
  (a: int, b: str, *args, **kwargs)
224
271
  `);
225
272
  });
226
273
  it("renders a call signature with parameter descriptors and return type", () => {
227
- const result = toSourceText([_$createComponent(py.CallSignature, {
228
- parameters: [{
229
- name: "a",
230
- type: "int"
231
- }, {
232
- name: "b",
233
- type: "str"
234
- }],
235
- returnType: "int"
236
- })]);
237
- expect(result).toRenderTo(d`
274
+ expect(_$createComponent(TestOutput, {
275
+ get children() {
276
+ return _$createComponent(py.CallSignature, {
277
+ parameters: [{
278
+ name: "a",
279
+ type: "int"
280
+ }, {
281
+ name: "b",
282
+ type: "str"
283
+ }],
284
+ returnType: "int"
285
+ });
286
+ }
287
+ })).toRenderTo(`
238
288
  (a: int, b: str) -> int
239
289
  `);
240
290
  });
241
291
  it("renders a call signature with parameter descriptors for a class function", () => {
242
- const result = toSourceText([_$createComponent(py.CallSignature, {
243
- parameters: [{
244
- name: "a",
245
- type: "int"
246
- }, {
247
- name: "b",
248
- type: "str"
249
- }]
250
- })]);
251
- expect(result).toRenderTo(d`
292
+ expect(_$createComponent(TestOutput, {
293
+ get children() {
294
+ return _$createComponent(py.CallSignature, {
295
+ parameters: [{
296
+ name: "a",
297
+ type: "int"
298
+ }, {
299
+ name: "b",
300
+ type: "str"
301
+ }]
302
+ });
303
+ }
304
+ })).toRenderTo(`
252
305
  (a: int, b: str)
253
306
  `);
254
307
  });
255
308
  it("renders a call signature with all", () => {
256
- const result = toSourceText([_$createComponent(py.CallSignature, {
257
- parameters: [{
258
- name: "a",
259
- type: "int"
260
- }, {
261
- name: "b",
262
- type: "str"
263
- }],
264
- args: true,
265
- kwargs: true,
266
- returnType: "int"
267
- })]);
268
- expect(result).toRenderTo(d`
309
+ expect(_$createComponent(TestOutput, {
310
+ get children() {
311
+ return _$createComponent(py.CallSignature, {
312
+ parameters: [{
313
+ name: "a",
314
+ type: "int"
315
+ }, {
316
+ name: "b",
317
+ type: "str"
318
+ }],
319
+ args: true,
320
+ kwargs: true,
321
+ returnType: "int"
322
+ });
323
+ }
324
+ })).toRenderTo(`
269
325
  (a: int, b: str, *args, **kwargs) -> int
270
326
  `);
271
327
  });
272
328
  it("renders a more complex call signature with parameter descriptors", () => {
273
- const result = toSourceText([_$createComponent(py.CallSignature, {
274
- typeParameters: ["T", "U"],
275
- parameters: [{
276
- name: "a",
277
- type: "int"
278
- }, {
279
- name: "b",
280
- type: "str",
281
- default: "default_value"
282
- }],
283
- returnType: "int"
284
- })]);
285
- expect(result).toRenderTo(d`
329
+ expect(_$createComponent(TestOutput, {
330
+ get children() {
331
+ return _$createComponent(py.CallSignature, {
332
+ typeParameters: ["T", "U"],
333
+ parameters: [{
334
+ name: "a",
335
+ type: "int"
336
+ }, {
337
+ name: "b",
338
+ type: "str",
339
+ default: "default_value"
340
+ }],
341
+ returnType: "int"
342
+ });
343
+ }
344
+ })).toRenderTo(`
286
345
  [T, U](a: int, b: str = "default_value") -> int
287
346
  `);
288
347
  });
289
348
  it("renders a call signature with keyword-only parameters using * marker", () => {
290
- const result = toSourceText([_$createComponent(py.CallSignature, {
291
- parameters: [{
292
- name: "id",
293
- type: "str"
294
- }, "*", {
295
- name: "locale",
296
- type: "str",
297
- default: "en-US"
298
- }, {
299
- name: "debug",
300
- type: "bool",
301
- default: false
302
- }],
303
- returnType: "str"
304
- })]);
305
- expect(result).toRenderTo(d`
349
+ expect(_$createComponent(TestOutput, {
350
+ get children() {
351
+ return _$createComponent(py.CallSignature, {
352
+ parameters: [{
353
+ name: "id",
354
+ type: "str"
355
+ }, "*", {
356
+ name: "locale",
357
+ type: "str",
358
+ default: "en-US"
359
+ }, {
360
+ name: "debug",
361
+ type: "bool",
362
+ default: false
363
+ }],
364
+ returnType: "str"
365
+ });
366
+ }
367
+ })).toRenderTo(`
306
368
  (id: str, *, locale: str = "en-US", debug: bool = False) -> str
307
369
  `);
308
370
  });
309
371
  it("renders a call signature with only keyword-only parameters", () => {
310
- const result = toSourceText([_$createComponent(py.CallSignature, {
311
- parameters: ["*", {
312
- name: "name",
313
- type: "str",
314
- default: "alice"
315
- }, {
316
- name: "age",
317
- type: "int",
318
- default: 30
319
- }],
320
- returnType: "None"
321
- })]);
322
- expect(result).toRenderTo(d`
372
+ expect(_$createComponent(TestOutput, {
373
+ get children() {
374
+ return _$createComponent(py.CallSignature, {
375
+ parameters: ["*", {
376
+ name: "name",
377
+ type: "str",
378
+ default: "alice"
379
+ }, {
380
+ name: "age",
381
+ type: "int",
382
+ default: 30
383
+ }],
384
+ returnType: "None"
385
+ });
386
+ }
387
+ })).toRenderTo(`
323
388
  (*, name: str = "alice", age: int = 30) -> None
324
389
  `);
325
390
  });
326
391
  it("renders a call signature with positional, keyword-only, and *args/**kwargs", () => {
327
- const result = toSourceText([_$createComponent(py.CallSignature, {
328
- parameters: [{
329
- name: "a",
330
- type: "int"
331
- }, "*", {
332
- name: "b",
333
- type: "str",
334
- default: "hello"
335
- }],
336
- args: true,
337
- kwargs: true,
338
- returnType: "None"
339
- })]);
340
- expect(result).toRenderTo(d`
392
+ expect(_$createComponent(TestOutput, {
393
+ get children() {
394
+ return _$createComponent(py.CallSignature, {
395
+ parameters: [{
396
+ name: "a",
397
+ type: "int"
398
+ }, "*", {
399
+ name: "b",
400
+ type: "str",
401
+ default: "hello"
402
+ }],
403
+ args: true,
404
+ kwargs: true,
405
+ returnType: "None"
406
+ });
407
+ }
408
+ })).toRenderTo(`
341
409
  (a: int, *, b: str = "hello", *args, **kwargs) -> None
342
410
  `);
343
411
  });
344
412
  it("renders a call signature with positional-only parameters using / marker", () => {
345
- const result = toSourceText([_$createComponent(py.CallSignature, {
346
- parameters: [{
347
- name: "a",
348
- type: "int"
349
- }, {
350
- name: "b",
351
- type: "str"
352
- }, "/", {
353
- name: "c",
354
- type: "bool"
355
- }],
356
- returnType: "None"
357
- })]);
358
- expect(result).toRenderTo(d`
413
+ expect(_$createComponent(TestOutput, {
414
+ get children() {
415
+ return _$createComponent(py.CallSignature, {
416
+ parameters: [{
417
+ name: "a",
418
+ type: "int"
419
+ }, {
420
+ name: "b",
421
+ type: "str"
422
+ }, "/", {
423
+ name: "c",
424
+ type: "bool"
425
+ }],
426
+ returnType: "None"
427
+ });
428
+ }
429
+ })).toRenderTo(`
359
430
  (a: int, b: str, /, c: bool) -> None
360
431
  `);
361
432
  });
362
433
  it("renders a call signature with positional-only, regular, and keyword-only parameters", () => {
363
- const result = toSourceText([_$createComponent(py.CallSignature, {
364
- parameters: [{
365
- name: "a",
366
- type: "int"
367
- }, "/", {
368
- name: "b",
369
- type: "str"
370
- }, "*", {
371
- name: "c",
372
- type: "bool",
373
- default: true
374
- }],
375
- returnType: "None"
376
- })]);
377
- expect(result).toRenderTo(d`
434
+ expect(_$createComponent(TestOutput, {
435
+ get children() {
436
+ return _$createComponent(py.CallSignature, {
437
+ parameters: [{
438
+ name: "a",
439
+ type: "int"
440
+ }, "/", {
441
+ name: "b",
442
+ type: "str"
443
+ }, "*", {
444
+ name: "c",
445
+ type: "bool",
446
+ default: true
447
+ }],
448
+ returnType: "None"
449
+ });
450
+ }
451
+ })).toRenderTo(`
378
452
  (a: int, /, b: str, *, c: bool = True) -> None
379
453
  `);
380
454
  });