@typespec/emitter-framework 0.18.0 → 0.18.1-dev.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.
Files changed (24) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/src/python/components/class-declaration/class-declaration.test.js +217 -217
  3. package/dist/src/python/components/class-declaration/class-member.test.js +35 -35
  4. package/dist/src/python/components/class-declaration/class-method.test.js +24 -24
  5. package/dist/src/python/components/enum-declaration/enum-declaration.test.js +45 -45
  6. package/dist/src/python/components/function-declaration/function-declaration.test.js +53 -53
  7. package/dist/src/python/components/protocol-declaration/protocol-declaration.test.js +12 -12
  8. package/dist/src/python/components/type-alias-declaration/type-alias-declaration.test.js +7 -7
  9. package/dist/src/python/components/type-declaration/type-declaration.test.js +5 -5
  10. package/dist/src/python/components/type-expression/type-expression.d.ts +1 -1
  11. package/dist/src/python/components/type-expression/type-expression.d.ts.map +1 -1
  12. package/dist/src/python/components/type-expression/type-expression.test.js +6 -6
  13. package/package.json +14 -13
  14. package/package.json.bak +4 -3
  15. package/src/python/components/class-declaration/class-declaration.test.tsx +217 -217
  16. package/src/python/components/class-declaration/class-member.test.tsx +35 -35
  17. package/src/python/components/class-declaration/class-method.test.tsx +24 -24
  18. package/src/python/components/enum-declaration/enum-declaration.test.tsx +45 -45
  19. package/src/python/components/function-declaration/function-declaration.test.tsx +53 -53
  20. package/src/python/components/protocol-declaration/protocol-declaration.test.tsx +12 -12
  21. package/src/python/components/type-alias-declaration/type-alias-declaration.test.tsx +7 -7
  22. package/src/python/components/type-declaration/type-declaration.test.tsx +5 -5
  23. package/src/python/components/type-expression/type-expression.test.tsx +6 -6
  24. package/tsconfig.json +1 -1
@@ -13,7 +13,7 @@ describe("Python Function Declaration", () => {
13
13
 
14
14
  expect(getOutput(program, [<FunctionDeclaration type={getName} />])).toRenderTo(`
15
15
  def get_name(id: str) -> str:
16
- pass
16
+ pass
17
17
 
18
18
  `);
19
19
  });
@@ -25,7 +25,7 @@ describe("Python Function Declaration", () => {
25
25
 
26
26
  expect(getOutput(program, [<FunctionDeclaration async type={getName} />])).toRenderTo(`
27
27
  async def get_name(id: str) -> str:
28
- pass
28
+ pass
29
29
 
30
30
  `);
31
31
  });
@@ -38,7 +38,7 @@ describe("Python Function Declaration", () => {
38
38
  expect(getOutput(program, [<FunctionDeclaration name="new_name" type={getName} />]))
39
39
  .toRenderTo(`
40
40
  def new_name(id: str) -> str:
41
- pass
41
+ pass
42
42
 
43
43
  `);
44
44
  });
@@ -60,7 +60,7 @@ describe("Python Function Declaration", () => {
60
60
  ]),
61
61
  ).toRenderTo(`
62
62
  def create_person(id: str, *, name: str, age: float) -> str:
63
- pass
63
+ pass
64
64
 
65
65
  `);
66
66
  });
@@ -76,7 +76,7 @@ describe("Python Function Declaration", () => {
76
76
  ]),
77
77
  ).toRenderTo(`
78
78
  def create_person(id: str, *, name, age) -> str:
79
- pass
79
+ pass
80
80
 
81
81
  `);
82
82
  });
@@ -96,7 +96,7 @@ describe("Python Function Declaration", () => {
96
96
  ]),
97
97
  ).toRenderTo(`
98
98
  def create_person(*, name, age) -> str:
99
- pass
99
+ pass
100
100
 
101
101
  `);
102
102
  });
@@ -119,7 +119,7 @@ describe("Python Function Declaration", () => {
119
119
  ]),
120
120
  ).toRenderTo(`
121
121
  def create_person(*, name: str = "alice", age: int = 30) -> str:
122
- pass
122
+ pass
123
123
 
124
124
  `);
125
125
  });
@@ -141,7 +141,7 @@ describe("Python Function Declaration", () => {
141
141
  ]),
142
142
  ).toRenderTo(`
143
143
  def create_person(id: str, *, locale: str = "en-US", limit: int = 10, verbose: bool = True) -> str:
144
- pass
144
+ pass
145
145
 
146
146
  `);
147
147
  });
@@ -159,7 +159,7 @@ describe("Python Function Declaration", () => {
159
159
  expect(getOutput(program, [<FunctionDeclaration type={createPerson} parametersModel={Foo} />]))
160
160
  .toRenderTo(`
161
161
  def create_person(name: str, age: int) -> str:
162
- pass
162
+ pass
163
163
 
164
164
  `);
165
165
  });
@@ -177,7 +177,7 @@ describe("Python Function Declaration", () => {
177
177
  expect(getOutput(program, [<FunctionDeclaration type={createPerson} parametersModel={Foo} />]))
178
178
  .toRenderTo(`
179
179
  def create_person(*, required_name: str = "alice", optional_age: int = None) -> str:
180
- pass
180
+ pass
181
181
 
182
182
  `);
183
183
  });
@@ -198,7 +198,7 @@ describe("Python Function Declaration", () => {
198
198
  ]),
199
199
  ).toRenderTo(`
200
200
  def create_person(name: str, age: int) -> str:
201
- pass
201
+ pass
202
202
 
203
203
  `);
204
204
  });
@@ -211,7 +211,7 @@ describe("Python Function Declaration", () => {
211
211
  expect(getOutput(program, [<FunctionDeclaration type={getName} returnType="ASpecialString" />]))
212
212
  .toRenderTo(`
213
213
  def get_name(id: str) -> ASpecialString:
214
- pass
214
+ pass
215
215
 
216
216
  `);
217
217
  });
@@ -228,7 +228,7 @@ describe("Python Function Declaration", () => {
228
228
  ]),
229
229
  ).toRenderTo(`
230
230
  def create_person(id: str) -> str:
231
- print("Hello World!")
231
+ print("Hello World!")
232
232
 
233
233
  `);
234
234
  });
@@ -241,11 +241,11 @@ describe("Python Function Declaration", () => {
241
241
  expect(getOutput(program, [<FunctionDeclaration type={getName} doc={"This is a test doc"} />]))
242
242
  .toRenderTo(`
243
243
  def get_name(id: str) -> str:
244
- """
245
- This is a test doc
246
- """
244
+ """
245
+ This is a test doc
246
+ """
247
247
 
248
- pass
248
+ pass
249
249
 
250
250
  `);
251
251
  });
@@ -264,13 +264,13 @@ describe("Python Function Declaration", () => {
264
264
  ]),
265
265
  ).toRenderTo(`
266
266
  def get_name(id: str) -> str:
267
- """
268
- First paragraph
267
+ """
268
+ First paragraph
269
269
 
270
- Second paragraph
271
- """
270
+ Second paragraph
271
+ """
272
272
 
273
- pass
273
+ pass
274
274
 
275
275
  `);
276
276
  });
@@ -286,13 +286,13 @@ describe("Python Function Declaration", () => {
286
286
  ]),
287
287
  ).toRenderTo(`
288
288
  def get_name(id: str) -> str:
289
- """
290
- First paragraph
289
+ """
290
+ First paragraph
291
291
 
292
- Second paragraph
293
- """
292
+ Second paragraph
293
+ """
294
294
 
295
- pass
295
+ pass
296
296
 
297
297
  `);
298
298
  });
@@ -308,13 +308,13 @@ describe("Python Function Declaration", () => {
308
308
  ]),
309
309
  ).toRenderTo(`
310
310
  def get_name(id: str) -> str:
311
- """
312
- First paragraph
311
+ """
312
+ First paragraph
313
313
 
314
- Second paragraph
315
- """
314
+ Second paragraph
315
+ """
316
316
 
317
- pass
317
+ pass
318
318
 
319
319
  `);
320
320
  });
@@ -327,12 +327,12 @@ describe("Python Function Declaration", () => {
327
327
  expect(getOutput(program, [<FunctionDeclaration type={getName} doc={"Line 1\nLine 2"} />]))
328
328
  .toRenderTo(`
329
329
  def get_name(id: str) -> str:
330
- """
331
- Line 1
332
- Line 2
333
- """
330
+ """
331
+ Line 1
332
+ Line 2
333
+ """
334
334
 
335
- pass
335
+ pass
336
336
 
337
337
  `);
338
338
  });
@@ -344,7 +344,7 @@ describe("Python Function Declaration", () => {
344
344
 
345
345
  expect(getOutput(program, [<FunctionDeclaration type={ping} />])).toRenderTo(`
346
346
  def ping() -> str:
347
- pass
347
+ pass
348
348
 
349
349
  `);
350
350
  });
@@ -356,7 +356,7 @@ describe("Python Function Declaration", () => {
356
356
 
357
357
  expect(getOutput(program, [<FunctionDeclaration type={ping} />])).toRenderTo(`
358
358
  def ping() -> None:
359
- pass
359
+ pass
360
360
 
361
361
  `);
362
362
  });
@@ -370,11 +370,11 @@ describe("Python Function Declaration", () => {
370
370
  from typing import TYPE_CHECKING
371
371
 
372
372
  if TYPE_CHECKING:
373
- from typing import Never
373
+ from typing import Never
374
374
 
375
375
 
376
376
  def abort() -> Never:
377
- pass
377
+ pass
378
378
 
379
379
  `);
380
380
  });
@@ -386,7 +386,7 @@ describe("Python Function Declaration", () => {
386
386
 
387
387
  expect(getOutput(program, [<FunctionDeclaration type={get} />])).toRenderTo(`
388
388
  def get() -> int | str:
389
- pass
389
+ pass
390
390
 
391
391
  `);
392
392
  });
@@ -398,7 +398,7 @@ describe("Python Function Declaration", () => {
398
398
 
399
399
  expect(getOutput(program, [<FunctionDeclaration type={createPerson} />])).toRenderTo(`
400
400
  def create_person(*, name: str = "alice", age: int = 30) -> str:
401
- pass
401
+ pass
402
402
 
403
403
  `);
404
404
  });
@@ -420,7 +420,7 @@ describe("Python Function Declaration", () => {
420
420
  ]),
421
421
  ).toRenderTo(`
422
422
  def create_person(id: str, *, version: int, locale: str = "en-US", debug: bool = False) -> str:
423
- pass
423
+ pass
424
424
 
425
425
  `);
426
426
  });
@@ -432,7 +432,7 @@ describe("Python Function Declaration", () => {
432
432
 
433
433
  expect(getOutput(program, [<FunctionDeclaration type={createPerson} />])).toRenderTo(`
434
434
  def create_person(id: str, *, locale: str = "en-US") -> str:
435
- pass
435
+ pass
436
436
 
437
437
  `);
438
438
  });
@@ -445,7 +445,7 @@ describe("Python Function Declaration", () => {
445
445
  expect(getOutput(program, [<FunctionDeclaration type={ping} parameters={["name", "age"]} />]))
446
446
  .toRenderTo(`
447
447
  def ping(name, age) -> str:
448
- pass
448
+ pass
449
449
 
450
450
  `);
451
451
  });
@@ -457,7 +457,7 @@ describe("Python Function Declaration", () => {
457
457
 
458
458
  expect(getOutput(program, [<FunctionDeclaration type={createPerson} />])).toRenderTo(`
459
459
  def create_person(id: str, name: str, age: int) -> str:
460
- pass
460
+ pass
461
461
 
462
462
  `);
463
463
  });
@@ -479,7 +479,7 @@ describe("Python Function Declaration", () => {
479
479
  ]),
480
480
  ).toRenderTo(`
481
481
  def create_person(id: str, name: str, *, email, notify: bool = False) -> str:
482
- pass
482
+ pass
483
483
 
484
484
  `);
485
485
  });
@@ -495,7 +495,7 @@ describe("Python Function Declaration", () => {
495
495
 
496
496
  expect(getOutput(program, [<FunctionDeclaration type={search} />])).toRenderTo(`
497
497
  def search(*, limit: int = 10, offset: int = 0, sort_by: str = "name") -> str:
498
- pass
498
+ pass
499
499
 
500
500
  `);
501
501
  });
@@ -508,7 +508,7 @@ describe("Python Function Declaration", () => {
508
508
  expect(getOutput(program, [<FunctionDeclaration type={search} parameters={["query"]} />]))
509
509
  .toRenderTo(`
510
510
  def search(*, query, limit: int = 10, offset: int = 0) -> str:
511
- pass
511
+ pass
512
512
 
513
513
  `);
514
514
  });
@@ -535,7 +535,7 @@ describe("Python Function Declaration", () => {
535
535
  ]),
536
536
  ).toRenderTo(`
537
537
  def complex_op(required1: str, required2: int, *, additional_required, optional1: str = "default", optional2: int = 42, additional_optional: bool = True) -> str:
538
- pass
538
+ pass
539
539
 
540
540
  `);
541
541
  });
@@ -556,7 +556,7 @@ describe("Python Function Declaration", () => {
556
556
  ]),
557
557
  ).toRenderTo(`
558
558
  def get_user(id: str, *, include_deleted: bool = False) -> str:
559
- pass
559
+ pass
560
560
 
561
561
  `);
562
562
  });
@@ -578,7 +578,7 @@ describe("Python Function Declaration", () => {
578
578
  ]),
579
579
  ).toRenderTo(`
580
580
  def ping(*, timeout: int = 30, retries: int = 3) -> str:
581
- pass
581
+ pass
582
582
 
583
583
  `);
584
584
  });
@@ -22,14 +22,14 @@ describe("Python ProtocolDeclaration", () => {
22
22
 
23
23
 
24
24
  class GetName(Protocol):
25
- def __call__(self, id: str) -> str:
26
- ...
25
+ def __call__(self, id: str) -> str:
26
+ ...
27
27
 
28
28
 
29
29
 
30
30
  class GetOtherName(Protocol):
31
- def __call__(self, id: str) -> str:
32
- ...
31
+ def __call__(self, id: str) -> str:
32
+ ...
33
33
 
34
34
 
35
35
  `);
@@ -49,8 +49,8 @@ describe("Python ProtocolDeclaration", () => {
49
49
 
50
50
 
51
51
  class GetName(Protocol):
52
- def __call__(self, id: str):
53
- ...
52
+ def __call__(self, id: str):
53
+ ...
54
54
 
55
55
 
56
56
  `);
@@ -69,11 +69,11 @@ describe("Python ProtocolDeclaration", () => {
69
69
 
70
70
 
71
71
  class Greeter(Protocol):
72
- def get_name(self, id: str) -> str:
73
- ...
72
+ def get_name(self, id: str) -> str:
73
+ ...
74
74
 
75
- def get_other_name(self, id: str) -> str:
76
- ...
75
+ def get_other_name(self, id: str) -> str:
76
+ ...
77
77
 
78
78
 
79
79
  `);
@@ -95,8 +95,8 @@ describe("Python ProtocolDeclaration", () => {
95
95
 
96
96
 
97
97
  class GetName(Protocol):
98
- def __call__(self, id: str) -> str:
99
- ...
98
+ def __call__(self, id: str) -> str:
99
+ ...
100
100
 
101
101
 
102
102
 
@@ -17,7 +17,7 @@ describe("Python Declaration equivalency to Type Alias", () => {
17
17
  from typing import TYPE_CHECKING
18
18
 
19
19
  if TYPE_CHECKING:
20
- from typing import TypeAlias
20
+ from typing import TypeAlias
21
21
 
22
22
 
23
23
  my_date: TypeAlias = datetime`);
@@ -36,7 +36,7 @@ describe("Python Declaration equivalency to Type Alias", () => {
36
36
  from typing import TYPE_CHECKING
37
37
 
38
38
  if TYPE_CHECKING:
39
- from typing import TypeAlias
39
+ from typing import TypeAlias
40
40
 
41
41
 
42
42
  # Type to represent a date
@@ -57,7 +57,7 @@ describe("Python Declaration equivalency to Type Alias", () => {
57
57
  from typing import TYPE_CHECKING
58
58
 
59
59
  if TYPE_CHECKING:
60
- from typing import TypeAlias
60
+ from typing import TypeAlias
61
61
 
62
62
 
63
63
  # Overridden Doc
@@ -75,7 +75,7 @@ describe("Python Declaration equivalency to Type Alias", () => {
75
75
  from typing import TYPE_CHECKING
76
76
 
77
77
  if TYPE_CHECKING:
78
- from typing import TypeAlias
78
+ from typing import TypeAlias
79
79
 
80
80
 
81
81
  my_date: TypeAlias = datetime`);
@@ -92,7 +92,7 @@ describe("Python Declaration equivalency to Type Alias", () => {
92
92
  from typing import TYPE_CHECKING
93
93
 
94
94
  if TYPE_CHECKING:
95
- from typing import TypeAlias
95
+ from typing import TypeAlias
96
96
 
97
97
 
98
98
  my_date: TypeAlias = datetime`);
@@ -109,7 +109,7 @@ describe("Python Declaration equivalency to Type Alias", () => {
109
109
  from typing import TYPE_CHECKING
110
110
 
111
111
  if TYPE_CHECKING:
112
- from typing import TypeAlias
112
+ from typing import TypeAlias
113
113
 
114
114
 
115
115
  my_date: TypeAlias = datetime`);
@@ -129,7 +129,7 @@ describe("Python Declaration equivalency to Type Alias", () => {
129
129
  from typing import TYPE_CHECKING
130
130
 
131
131
  if TYPE_CHECKING:
132
- from typing import TypeAlias
132
+ from typing import TypeAlias
133
133
 
134
134
 
135
135
  handle_request: TypeAlias = Callable[[str], str]`);
@@ -21,9 +21,9 @@ describe("Python TypeDeclaration dispatcher", () => {
21
21
 
22
22
 
23
23
  class Foo(IntEnum):
24
- ONE = 1
25
- TWO = 2
26
- THREE = 3
24
+ ONE = 1
25
+ TWO = 2
26
+ THREE = 3
27
27
 
28
28
 
29
29
  `);
@@ -40,7 +40,7 @@ describe("Python TypeDeclaration dispatcher", () => {
40
40
  from typing import TYPE_CHECKING
41
41
 
42
42
  if TYPE_CHECKING:
43
- from typing import TypeAlias
43
+ from typing import TypeAlias
44
44
 
45
45
 
46
46
  my_date: TypeAlias = datetime`);
@@ -56,7 +56,7 @@ describe("Python TypeDeclaration dispatcher", () => {
56
56
  from typing import TYPE_CHECKING
57
57
 
58
58
  if TYPE_CHECKING:
59
- from typing import TypeAlias
59
+ from typing import TypeAlias
60
60
 
61
61
 
62
62
  items: TypeAlias = list[int]`);
@@ -158,8 +158,8 @@ describe("handles UnionVariant types", () => {
158
158
 
159
159
 
160
160
  class Color(StrEnum):
161
- RED = "red"
162
- BLUE = "blue"
161
+ RED = "red"
162
+ BLUE = "blue"
163
163
 
164
164
 
165
165
  Literal[Color.RED]
@@ -192,8 +192,8 @@ describe("handles UnionVariant types", () => {
192
192
 
193
193
 
194
194
  class Status(IntEnum):
195
- ACTIVE = 1
196
- INACTIVE = 0
195
+ ACTIVE = 1
196
+ INACTIVE = 0
197
197
 
198
198
 
199
199
  Literal[Status.ACTIVE]
@@ -243,8 +243,8 @@ describe("handles UnionVariant types", () => {
243
243
 
244
244
 
245
245
  class Result(StrEnum):
246
- SUCCESS = "success"
247
- FAILURE = "failure"
246
+ SUCCESS = "success"
247
+ FAILURE = "failure"
248
248
 
249
249
 
250
250
  Literal[Result.SUCCESS]
package/tsconfig.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "outDir": "dist",
17
17
  "rootDir": "./",
18
18
  "verbatimModuleSyntax": true,
19
- "types": ["@alloy-js/core/testing/matchers"]
19
+ "types": ["node", "@alloy-js/core/testing/matchers"]
20
20
  },
21
21
  "include": ["src/**/*.ts", "src/**/*.tsx", "test/**/*.ts", "test/**/*.tsx"],
22
22
  "exclude": ["node_modules", "dist"]