@typespec/emitter-framework 0.18.1-dev.0 → 0.18.1-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.
- 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 +15 -14
- package/package.json.bak +6 -5
- 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
|
@@ -21,14 +21,14 @@ describe("Python Class Members", () => {
|
|
|
21
21
|
from typing import TYPE_CHECKING
|
|
22
22
|
|
|
23
23
|
if TYPE_CHECKING:
|
|
24
|
-
|
|
24
|
+
from typing import Optional
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
@dataclass(kw_only=True)
|
|
28
28
|
class MyModel:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
name: str = "default"
|
|
30
|
+
description: Optional[str] = "optional with default"
|
|
31
|
+
empty_string: str = ""
|
|
32
32
|
|
|
33
33
|
`,
|
|
34
34
|
);
|
|
@@ -49,14 +49,14 @@ describe("Python Class Members", () => {
|
|
|
49
49
|
from typing import TYPE_CHECKING
|
|
50
50
|
|
|
51
51
|
if TYPE_CHECKING:
|
|
52
|
-
|
|
52
|
+
from typing import Optional
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
@dataclass(kw_only=True)
|
|
56
56
|
class BooleanModel:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
is_active: bool = True
|
|
58
|
+
is_deleted: bool = False
|
|
59
|
+
optional: Optional[bool] = True
|
|
60
60
|
|
|
61
61
|
`,
|
|
62
62
|
);
|
|
@@ -78,9 +78,9 @@ describe("Python Class Members", () => {
|
|
|
78
78
|
|
|
79
79
|
@dataclass(kw_only=True)
|
|
80
80
|
class ArrayModel:
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
tags: list[str] = ["tag1", "tag2"]
|
|
82
|
+
empty_array: list[int] = []
|
|
83
|
+
numbers: list[int] = [1, 2, 3]
|
|
84
84
|
|
|
85
85
|
`,
|
|
86
86
|
);
|
|
@@ -104,11 +104,11 @@ describe("Python Class Members", () => {
|
|
|
104
104
|
|
|
105
105
|
@dataclass(kw_only=True)
|
|
106
106
|
class IntegerModel:
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
count: int = 42
|
|
108
|
+
big_number: int = 1000000
|
|
109
|
+
small_number: int = 127
|
|
110
|
+
unsigned_value: int = 100
|
|
111
|
+
safe_int_value: int = 999
|
|
112
112
|
|
|
113
113
|
`,
|
|
114
114
|
);
|
|
@@ -149,23 +149,23 @@ describe("Python Class Members", () => {
|
|
|
149
149
|
from typing import TYPE_CHECKING
|
|
150
150
|
|
|
151
151
|
if TYPE_CHECKING:
|
|
152
|
-
|
|
152
|
+
from decimal import Decimal
|
|
153
153
|
|
|
154
154
|
|
|
155
155
|
@dataclass(kw_only=True)
|
|
156
156
|
class NumericDefaults:
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
157
|
+
float_base: float = 1.5
|
|
158
|
+
float32_value: float = 2.5
|
|
159
|
+
float64_value: float = 3.5
|
|
160
|
+
custom_float_value: float = 4.5
|
|
161
|
+
float_int: float = 10.0
|
|
162
|
+
float32_int: float = 20.0
|
|
163
|
+
float64_int: float = 30.0
|
|
164
|
+
decimal_base: Decimal = 100.25
|
|
165
|
+
decimal128_value: Decimal = 200.75
|
|
166
|
+
custom_decimal_value: Decimal = 300.125
|
|
167
|
+
decimal_int: Decimal = 400.0
|
|
168
|
+
decimal128_int: Decimal = 500.0
|
|
169
169
|
|
|
170
170
|
`,
|
|
171
171
|
);
|
|
@@ -188,16 +188,16 @@ describe("Python Class Members", () => {
|
|
|
188
188
|
from typing import TYPE_CHECKING
|
|
189
189
|
|
|
190
190
|
if TYPE_CHECKING:
|
|
191
|
-
|
|
191
|
+
from decimal import Decimal
|
|
192
192
|
|
|
193
193
|
|
|
194
194
|
@dataclass(kw_only=True)
|
|
195
195
|
class MixedNumeric:
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
196
|
+
int_value: int = 100
|
|
197
|
+
int64_value: int = 100
|
|
198
|
+
float_value: float = 100.0
|
|
199
|
+
float64_value: float = 100.0
|
|
200
|
+
decimal_value: Decimal = 100.0
|
|
201
201
|
|
|
202
202
|
`,
|
|
203
203
|
);
|
|
@@ -21,8 +21,8 @@ describe("interface methods with a `type` prop", () => {
|
|
|
21
21
|
]),
|
|
22
22
|
).toRenderTo(`
|
|
23
23
|
class BasicInterface:
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
async def get_name(self, id: str) -> str:
|
|
25
|
+
pass
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
`);
|
|
@@ -41,9 +41,9 @@ describe("interface methods with a `type` prop", () => {
|
|
|
41
41
|
]),
|
|
42
42
|
).toRenderTo(`
|
|
43
43
|
class BasicInterface:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
@classmethod
|
|
45
|
+
async def get_name(cls, id: str) -> str:
|
|
46
|
+
pass
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
`);
|
|
@@ -62,9 +62,9 @@ describe("interface methods with a `type` prop", () => {
|
|
|
62
62
|
]),
|
|
63
63
|
).toRenderTo(`
|
|
64
64
|
class BasicInterface:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
@staticmethod
|
|
66
|
+
async def get_name(id: str) -> str:
|
|
67
|
+
pass
|
|
68
68
|
|
|
69
69
|
|
|
70
70
|
`);
|
|
@@ -83,8 +83,8 @@ describe("interface methods with a `type` prop", () => {
|
|
|
83
83
|
]),
|
|
84
84
|
).toRenderTo(`
|
|
85
85
|
class BasicInterface:
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
async def get_name(self, id: str) -> str:
|
|
87
|
+
pass
|
|
88
88
|
|
|
89
89
|
|
|
90
90
|
`);
|
|
@@ -103,8 +103,8 @@ describe("interface methods with a `type` prop", () => {
|
|
|
103
103
|
]),
|
|
104
104
|
).toRenderTo(`
|
|
105
105
|
class BasicInterface:
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
def get_name(self, id: str, *, foo: str) -> str:
|
|
107
|
+
pass
|
|
108
108
|
|
|
109
109
|
|
|
110
110
|
`);
|
|
@@ -123,8 +123,8 @@ describe("interface methods with a `type` prop", () => {
|
|
|
123
123
|
]),
|
|
124
124
|
).toRenderTo(`
|
|
125
125
|
class BasicInterface:
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
def get_name(self, id: str, *, foo: str) -> str:
|
|
127
|
+
pass
|
|
128
128
|
|
|
129
129
|
|
|
130
130
|
`);
|
|
@@ -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, *, foo: str, bar: float) -> str:
|
|
154
|
+
pass
|
|
155
155
|
|
|
156
156
|
|
|
157
157
|
`);
|
|
@@ -177,8 +177,8 @@ describe("interface methods with a `type` prop", () => {
|
|
|
177
177
|
]),
|
|
178
178
|
).toRenderTo(`
|
|
179
179
|
class BasicInterface:
|
|
180
|
-
|
|
181
|
-
|
|
180
|
+
def get_name(self, *, foo: str = "default", bar: float = 42) -> str:
|
|
181
|
+
pass
|
|
182
182
|
|
|
183
183
|
|
|
184
184
|
`);
|
|
@@ -197,8 +197,8 @@ describe("interface methods with a `type` prop", () => {
|
|
|
197
197
|
]),
|
|
198
198
|
).toRenderTo(`
|
|
199
199
|
class BasicInterface:
|
|
200
|
-
|
|
201
|
-
|
|
200
|
+
def get_name(self, id: str) -> ASpecialString:
|
|
201
|
+
pass
|
|
202
202
|
|
|
203
203
|
|
|
204
204
|
`);
|
|
@@ -217,8 +217,8 @@ describe("interface methods with a `type` prop", () => {
|
|
|
217
217
|
]),
|
|
218
218
|
).toRenderTo(`
|
|
219
219
|
class BasicInterface:
|
|
220
|
-
|
|
221
|
-
|
|
220
|
+
def get_name_custom(self, id: str) -> str:
|
|
221
|
+
pass
|
|
222
222
|
|
|
223
223
|
|
|
224
224
|
`);
|
|
@@ -241,8 +241,8 @@ describe("interface methods without a `type` prop", () => {
|
|
|
241
241
|
]),
|
|
242
242
|
).toRenderTo(`
|
|
243
243
|
class BasicInterface:
|
|
244
|
-
|
|
245
|
-
|
|
244
|
+
def plain_method(self, param1: string) -> number:
|
|
245
|
+
pass
|
|
246
246
|
|
|
247
247
|
|
|
248
248
|
`);
|
|
@@ -22,9 +22,9 @@ describe("Python Enum Declaration", () => {
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
class Foo(IntEnum):
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
ONE = 1
|
|
26
|
+
TWO = 2
|
|
27
|
+
THREE = 3
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
`);
|
|
@@ -49,16 +49,16 @@ describe("Python Enum Declaration", () => {
|
|
|
49
49
|
|
|
50
50
|
|
|
51
51
|
class Foo(IntEnum):
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
"""
|
|
53
|
+
This is a test enum
|
|
54
|
+
"""
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
ONE = 1
|
|
57
|
+
"""
|
|
58
|
+
This is one
|
|
59
|
+
"""
|
|
60
|
+
TWO = 2
|
|
61
|
+
THREE = 3
|
|
62
62
|
|
|
63
63
|
|
|
64
64
|
`);
|
|
@@ -85,16 +85,16 @@ describe("Python Enum Declaration", () => {
|
|
|
85
85
|
|
|
86
86
|
|
|
87
87
|
class Foo(IntEnum):
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
"""
|
|
89
|
+
This is an explicit doc
|
|
90
|
+
"""
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
92
|
+
ONE = 1
|
|
93
|
+
"""
|
|
94
|
+
This is one
|
|
95
|
+
"""
|
|
96
|
+
TWO = 2
|
|
97
|
+
THREE = 3
|
|
98
98
|
|
|
99
99
|
|
|
100
100
|
`);
|
|
@@ -115,9 +115,9 @@ describe("Python Enum Declaration", () => {
|
|
|
115
115
|
|
|
116
116
|
|
|
117
117
|
class Foo(IntEnum):
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
ONE = 1
|
|
119
|
+
TWO = 2
|
|
120
|
+
THREE = 3
|
|
121
121
|
|
|
122
122
|
|
|
123
123
|
`);
|
|
@@ -145,9 +145,9 @@ describe("Python Enum Declaration", () => {
|
|
|
145
145
|
|
|
146
146
|
|
|
147
147
|
class Foo(IntEnum):
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
148
|
+
ONE = 1
|
|
149
|
+
TWO = 2
|
|
150
|
+
THREE = 3
|
|
151
151
|
|
|
152
152
|
|
|
153
153
|
Foo
|
|
@@ -177,9 +177,9 @@ describe("Python Enum Declaration", () => {
|
|
|
177
177
|
|
|
178
178
|
|
|
179
179
|
class Foo(IntEnum):
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
180
|
+
ONE = 1
|
|
181
|
+
TWO = 2
|
|
182
|
+
THREE = 3
|
|
183
183
|
|
|
184
184
|
|
|
185
185
|
Foo
|
|
@@ -203,9 +203,9 @@ describe("Python Enum Declaration", () => {
|
|
|
203
203
|
|
|
204
204
|
|
|
205
205
|
class StatusCode(IntEnum):
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
206
|
+
SUCCESS = 200
|
|
207
|
+
NOT_FOUND = 404
|
|
208
|
+
SERVER_ERROR = 500
|
|
209
209
|
|
|
210
210
|
|
|
211
211
|
`);
|
|
@@ -226,9 +226,9 @@ describe("Python Enum Declaration", () => {
|
|
|
226
226
|
|
|
227
227
|
|
|
228
228
|
class Color(StrEnum):
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
229
|
+
RED = "red"
|
|
230
|
+
GREEN = "green"
|
|
231
|
+
BLUE = "blue"
|
|
232
232
|
|
|
233
233
|
|
|
234
234
|
`);
|
|
@@ -256,9 +256,9 @@ describe("Python Enum Declaration", () => {
|
|
|
256
256
|
|
|
257
257
|
|
|
258
258
|
class Color(StrEnum):
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
259
|
+
RED = "This is red"
|
|
260
|
+
GREEN = "This is green"
|
|
261
|
+
BLUE = "This is blue"
|
|
262
262
|
|
|
263
263
|
|
|
264
264
|
Color.RED
|
|
@@ -284,9 +284,9 @@ describe("Python Enum Declaration", () => {
|
|
|
284
284
|
|
|
285
285
|
|
|
286
286
|
class Mixed(Enum):
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
287
|
+
STRING_VALUE = "hello"
|
|
288
|
+
NUMERIC_VALUE = 42
|
|
289
|
+
AUTO_VALUE = auto()
|
|
290
290
|
|
|
291
291
|
|
|
292
292
|
`);
|
|
@@ -308,9 +308,9 @@ describe("Python Enum Declaration", () => {
|
|
|
308
308
|
|
|
309
309
|
|
|
310
310
|
class EnumWithoutValues(Enum):
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
311
|
+
SOME_VALUE = auto()
|
|
312
|
+
ANOTHER_VALUE = auto()
|
|
313
|
+
YET_ANOTHER_VALUE = auto()
|
|
314
314
|
|
|
315
315
|
|
|
316
316
|
`);
|