@typespec/emitter-framework 0.18.1-dev.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.
- package/.turbo/turbo-build.log +1 -1
- package/dist/src/python/components/class-declaration/class-declaration.test.js +217 -217
- package/dist/src/python/components/class-declaration/class-member.test.js +35 -35
- package/dist/src/python/components/class-declaration/class-method.test.js +24 -24
- package/dist/src/python/components/enum-declaration/enum-declaration.test.js +45 -45
- package/dist/src/python/components/function-declaration/function-declaration.test.js +53 -53
- package/dist/src/python/components/protocol-declaration/protocol-declaration.test.js +12 -12
- package/dist/src/python/components/type-alias-declaration/type-alias-declaration.test.js +7 -7
- package/dist/src/python/components/type-declaration/type-declaration.test.js +5 -5
- package/dist/src/python/components/type-expression/type-expression.d.ts +1 -1
- package/dist/src/python/components/type-expression/type-expression.d.ts.map +1 -1
- package/dist/src/python/components/type-expression/type-expression.test.js +6 -6
- package/package.json +13 -12
- package/package.json.bak +4 -3
- package/src/python/components/class-declaration/class-declaration.test.tsx +217 -217
- package/src/python/components/class-declaration/class-member.test.tsx +35 -35
- package/src/python/components/class-declaration/class-method.test.tsx +24 -24
- package/src/python/components/enum-declaration/enum-declaration.test.tsx +45 -45
- package/src/python/components/function-declaration/function-declaration.test.tsx +53 -53
- package/src/python/components/protocol-declaration/protocol-declaration.test.tsx +12 -12
- package/src/python/components/type-alias-declaration/type-alias-declaration.test.tsx +7 -7
- package/src/python/components/type-declaration/type-declaration.test.tsx +5 -5
- package/src/python/components/type-expression/type-expression.test.tsx +6 -6
- package/tsconfig.json +1 -1
|
@@ -24,14 +24,14 @@ describe("Python Class Members", () => {
|
|
|
24
24
|
from typing import TYPE_CHECKING
|
|
25
25
|
|
|
26
26
|
if TYPE_CHECKING:
|
|
27
|
-
|
|
27
|
+
from typing import Optional
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
@dataclass(kw_only=True)
|
|
31
31
|
class MyModel:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
name: str = "default"
|
|
33
|
+
description: Optional[str] = "optional with default"
|
|
34
|
+
empty_string: str = ""
|
|
35
35
|
|
|
36
36
|
`);
|
|
37
37
|
});
|
|
@@ -53,14 +53,14 @@ describe("Python Class Members", () => {
|
|
|
53
53
|
from typing import TYPE_CHECKING
|
|
54
54
|
|
|
55
55
|
if TYPE_CHECKING:
|
|
56
|
-
|
|
56
|
+
from typing import Optional
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
@dataclass(kw_only=True)
|
|
60
60
|
class BooleanModel:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
is_active: bool = True
|
|
62
|
+
is_deleted: bool = False
|
|
63
|
+
optional: Optional[bool] = True
|
|
64
64
|
|
|
65
65
|
`);
|
|
66
66
|
});
|
|
@@ -83,9 +83,9 @@ describe("Python Class Members", () => {
|
|
|
83
83
|
|
|
84
84
|
@dataclass(kw_only=True)
|
|
85
85
|
class ArrayModel:
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
tags: list[str] = ["tag1", "tag2"]
|
|
87
|
+
empty_array: list[int] = []
|
|
88
|
+
numbers: list[int] = [1, 2, 3]
|
|
89
89
|
|
|
90
90
|
`);
|
|
91
91
|
});
|
|
@@ -110,11 +110,11 @@ describe("Python Class Members", () => {
|
|
|
110
110
|
|
|
111
111
|
@dataclass(kw_only=True)
|
|
112
112
|
class IntegerModel:
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
113
|
+
count: int = 42
|
|
114
|
+
big_number: int = 1000000
|
|
115
|
+
small_number: int = 127
|
|
116
|
+
unsigned_value: int = 100
|
|
117
|
+
safe_int_value: int = 999
|
|
118
118
|
|
|
119
119
|
`);
|
|
120
120
|
});
|
|
@@ -156,23 +156,23 @@ describe("Python Class Members", () => {
|
|
|
156
156
|
from typing import TYPE_CHECKING
|
|
157
157
|
|
|
158
158
|
if TYPE_CHECKING:
|
|
159
|
-
|
|
159
|
+
from decimal import Decimal
|
|
160
160
|
|
|
161
161
|
|
|
162
162
|
@dataclass(kw_only=True)
|
|
163
163
|
class NumericDefaults:
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
164
|
+
float_base: float = 1.5
|
|
165
|
+
float32_value: float = 2.5
|
|
166
|
+
float64_value: float = 3.5
|
|
167
|
+
custom_float_value: float = 4.5
|
|
168
|
+
float_int: float = 10.0
|
|
169
|
+
float32_int: float = 20.0
|
|
170
|
+
float64_int: float = 30.0
|
|
171
|
+
decimal_base: Decimal = 100.25
|
|
172
|
+
decimal128_value: Decimal = 200.75
|
|
173
|
+
custom_decimal_value: Decimal = 300.125
|
|
174
|
+
decimal_int: Decimal = 400.0
|
|
175
|
+
decimal128_int: Decimal = 500.0
|
|
176
176
|
|
|
177
177
|
`);
|
|
178
178
|
});
|
|
@@ -196,16 +196,16 @@ describe("Python Class Members", () => {
|
|
|
196
196
|
from typing import TYPE_CHECKING
|
|
197
197
|
|
|
198
198
|
if TYPE_CHECKING:
|
|
199
|
-
|
|
199
|
+
from decimal import Decimal
|
|
200
200
|
|
|
201
201
|
|
|
202
202
|
@dataclass(kw_only=True)
|
|
203
203
|
class MixedNumeric:
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
204
|
+
int_value: int = 100
|
|
205
|
+
int64_value: int = 100
|
|
206
|
+
float_value: float = 100.0
|
|
207
|
+
float64_value: float = 100.0
|
|
208
|
+
decimal_value: Decimal = 100.0
|
|
209
209
|
|
|
210
210
|
`);
|
|
211
211
|
});
|
|
@@ -25,8 +25,8 @@ describe("interface methods with a `type` prop", () => {
|
|
|
25
25
|
}
|
|
26
26
|
})])).toRenderTo(`
|
|
27
27
|
class BasicInterface:
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
async def get_name(self, id: str) -> str:
|
|
29
|
+
pass
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
`);
|
|
@@ -49,9 +49,9 @@ describe("interface methods with a `type` prop", () => {
|
|
|
49
49
|
}
|
|
50
50
|
})])).toRenderTo(`
|
|
51
51
|
class BasicInterface:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
@classmethod
|
|
53
|
+
async def get_name(cls, id: str) -> str:
|
|
54
|
+
pass
|
|
55
55
|
|
|
56
56
|
|
|
57
57
|
`);
|
|
@@ -74,9 +74,9 @@ describe("interface methods with a `type` prop", () => {
|
|
|
74
74
|
}
|
|
75
75
|
})])).toRenderTo(`
|
|
76
76
|
class BasicInterface:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
@staticmethod
|
|
78
|
+
async def get_name(id: str) -> str:
|
|
79
|
+
pass
|
|
80
80
|
|
|
81
81
|
|
|
82
82
|
`);
|
|
@@ -98,8 +98,8 @@ describe("interface methods with a `type` prop", () => {
|
|
|
98
98
|
}
|
|
99
99
|
})])).toRenderTo(`
|
|
100
100
|
class BasicInterface:
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
async def get_name(self, id: str) -> str:
|
|
102
|
+
pass
|
|
103
103
|
|
|
104
104
|
|
|
105
105
|
`);
|
|
@@ -124,8 +124,8 @@ describe("interface methods with a `type` prop", () => {
|
|
|
124
124
|
}
|
|
125
125
|
})])).toRenderTo(`
|
|
126
126
|
class BasicInterface:
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
def get_name(self, id: str, *, foo: str) -> str:
|
|
128
|
+
pass
|
|
129
129
|
|
|
130
130
|
|
|
131
131
|
`);
|
|
@@ -150,8 +150,8 @@ describe("interface methods with a `type` prop", () => {
|
|
|
150
150
|
}
|
|
151
151
|
})])).toRenderTo(`
|
|
152
152
|
class BasicInterface:
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
def get_name(self, id: str, *, foo: str) -> str:
|
|
154
|
+
pass
|
|
155
155
|
|
|
156
156
|
|
|
157
157
|
`);
|
|
@@ -180,8 +180,8 @@ describe("interface methods with a `type` prop", () => {
|
|
|
180
180
|
}
|
|
181
181
|
})])).toRenderTo(`
|
|
182
182
|
class BasicInterface:
|
|
183
|
-
|
|
184
|
-
|
|
183
|
+
def get_name(self, *, foo: str, bar: float) -> str:
|
|
184
|
+
pass
|
|
185
185
|
|
|
186
186
|
|
|
187
187
|
`);
|
|
@@ -218,8 +218,8 @@ describe("interface methods with a `type` prop", () => {
|
|
|
218
218
|
}
|
|
219
219
|
})])).toRenderTo(`
|
|
220
220
|
class BasicInterface:
|
|
221
|
-
|
|
222
|
-
|
|
221
|
+
def get_name(self, *, foo: str = "default", bar: float = 42) -> str:
|
|
222
|
+
pass
|
|
223
223
|
|
|
224
224
|
|
|
225
225
|
`);
|
|
@@ -241,8 +241,8 @@ describe("interface methods with a `type` prop", () => {
|
|
|
241
241
|
}
|
|
242
242
|
})])).toRenderTo(`
|
|
243
243
|
class BasicInterface:
|
|
244
|
-
|
|
245
|
-
|
|
244
|
+
def get_name(self, id: str) -> ASpecialString:
|
|
245
|
+
pass
|
|
246
246
|
|
|
247
247
|
|
|
248
248
|
`);
|
|
@@ -264,8 +264,8 @@ describe("interface methods with a `type` prop", () => {
|
|
|
264
264
|
}
|
|
265
265
|
})])).toRenderTo(`
|
|
266
266
|
class BasicInterface:
|
|
267
|
-
|
|
268
|
-
|
|
267
|
+
def get_name_custom(self, id: str) -> str:
|
|
268
|
+
pass
|
|
269
269
|
|
|
270
270
|
|
|
271
271
|
`);
|
|
@@ -288,8 +288,8 @@ describe("interface methods without a `type` prop", () => {
|
|
|
288
288
|
}
|
|
289
289
|
})])).toRenderTo(`
|
|
290
290
|
class BasicInterface:
|
|
291
|
-
|
|
292
|
-
|
|
291
|
+
def plain_method(self, param1: string) -> number:
|
|
292
|
+
pass
|
|
293
293
|
|
|
294
294
|
|
|
295
295
|
`);
|
|
@@ -26,9 +26,9 @@ describe("Python Enum Declaration", () => {
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
class Foo(IntEnum):
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
ONE = 1
|
|
30
|
+
TWO = 2
|
|
31
|
+
THREE = 3
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
`);
|
|
@@ -56,16 +56,16 @@ describe("Python Enum Declaration", () => {
|
|
|
56
56
|
|
|
57
57
|
|
|
58
58
|
class Foo(IntEnum):
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
"""
|
|
60
|
+
This is a test enum
|
|
61
|
+
"""
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
ONE = 1
|
|
64
|
+
"""
|
|
65
|
+
This is one
|
|
66
|
+
"""
|
|
67
|
+
TWO = 2
|
|
68
|
+
THREE = 3
|
|
69
69
|
|
|
70
70
|
|
|
71
71
|
`);
|
|
@@ -94,16 +94,16 @@ describe("Python Enum Declaration", () => {
|
|
|
94
94
|
|
|
95
95
|
|
|
96
96
|
class Foo(IntEnum):
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
"""
|
|
98
|
+
This is an explicit doc
|
|
99
|
+
"""
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
101
|
+
ONE = 1
|
|
102
|
+
"""
|
|
103
|
+
This is one
|
|
104
|
+
"""
|
|
105
|
+
TWO = 2
|
|
106
|
+
THREE = 3
|
|
107
107
|
|
|
108
108
|
|
|
109
109
|
`);
|
|
@@ -127,9 +127,9 @@ describe("Python Enum Declaration", () => {
|
|
|
127
127
|
|
|
128
128
|
|
|
129
129
|
class Foo(IntEnum):
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
ONE = 1
|
|
131
|
+
TWO = 2
|
|
132
|
+
THREE = 3
|
|
133
133
|
|
|
134
134
|
|
|
135
135
|
`);
|
|
@@ -157,9 +157,9 @@ describe("Python Enum Declaration", () => {
|
|
|
157
157
|
|
|
158
158
|
|
|
159
159
|
class Foo(IntEnum):
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
160
|
+
ONE = 1
|
|
161
|
+
TWO = 2
|
|
162
|
+
THREE = 3
|
|
163
163
|
|
|
164
164
|
|
|
165
165
|
Foo
|
|
@@ -189,9 +189,9 @@ describe("Python Enum Declaration", () => {
|
|
|
189
189
|
|
|
190
190
|
|
|
191
191
|
class Foo(IntEnum):
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
192
|
+
ONE = 1
|
|
193
|
+
TWO = 2
|
|
194
|
+
THREE = 3
|
|
195
195
|
|
|
196
196
|
|
|
197
197
|
Foo
|
|
@@ -218,9 +218,9 @@ describe("Python Enum Declaration", () => {
|
|
|
218
218
|
|
|
219
219
|
|
|
220
220
|
class StatusCode(IntEnum):
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
221
|
+
SUCCESS = 200
|
|
222
|
+
NOT_FOUND = 404
|
|
223
|
+
SERVER_ERROR = 500
|
|
224
224
|
|
|
225
225
|
|
|
226
226
|
`);
|
|
@@ -244,9 +244,9 @@ describe("Python Enum Declaration", () => {
|
|
|
244
244
|
|
|
245
245
|
|
|
246
246
|
class Color(StrEnum):
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
247
|
+
RED = "red"
|
|
248
|
+
GREEN = "green"
|
|
249
|
+
BLUE = "blue"
|
|
250
250
|
|
|
251
251
|
|
|
252
252
|
`);
|
|
@@ -274,9 +274,9 @@ describe("Python Enum Declaration", () => {
|
|
|
274
274
|
|
|
275
275
|
|
|
276
276
|
class Color(StrEnum):
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
277
|
+
RED = "This is red"
|
|
278
|
+
GREEN = "This is green"
|
|
279
|
+
BLUE = "This is blue"
|
|
280
280
|
|
|
281
281
|
|
|
282
282
|
Color.RED
|
|
@@ -305,9 +305,9 @@ describe("Python Enum Declaration", () => {
|
|
|
305
305
|
|
|
306
306
|
|
|
307
307
|
class Mixed(Enum):
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
308
|
+
STRING_VALUE = "hello"
|
|
309
|
+
NUMERIC_VALUE = 42
|
|
310
|
+
AUTO_VALUE = auto()
|
|
311
311
|
|
|
312
312
|
|
|
313
313
|
`);
|
|
@@ -332,9 +332,9 @@ describe("Python Enum Declaration", () => {
|
|
|
332
332
|
|
|
333
333
|
|
|
334
334
|
class EnumWithoutValues(Enum):
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
335
|
+
SOME_VALUE = auto()
|
|
336
|
+
ANOTHER_VALUE = auto()
|
|
337
|
+
YET_ANOTHER_VALUE = auto()
|
|
338
338
|
|
|
339
339
|
|
|
340
340
|
`);
|