@alloy-js/python 0.4.0 → 0.5.0-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/dist/dev/src/builtins/python.js +46 -0
- package/dist/dev/src/builtins/python.js.map +1 -1
- package/dist/dev/src/components/ClassDeclaration.js +19 -10
- package/dist/dev/src/components/ClassDeclaration.js.map +1 -1
- package/dist/dev/src/components/ClassMethodDeclaration.js +20 -5
- package/dist/dev/src/components/ClassMethodDeclaration.js.map +1 -1
- package/dist/dev/src/components/DataclassDeclaration.js +14 -12
- package/dist/dev/src/components/DataclassDeclaration.js.map +1 -1
- package/dist/dev/src/components/DecoratorList.js +55 -0
- package/dist/dev/src/components/DecoratorList.js.map +1 -0
- package/dist/dev/src/components/EnumDeclaration.js +21 -12
- package/dist/dev/src/components/EnumDeclaration.js.map +1 -1
- package/dist/dev/src/components/FunctionBase.js +21 -10
- package/dist/dev/src/components/FunctionBase.js.map +1 -1
- package/dist/dev/src/components/FutureStatement.js +1 -1
- package/dist/dev/src/components/MethodBase.js +16 -4
- package/dist/dev/src/components/MethodBase.js.map +1 -1
- package/dist/dev/src/components/PropertyDeclaration.js +68 -17
- package/dist/dev/src/components/PropertyDeclaration.js.map +1 -1
- package/dist/dev/src/components/PydanticClassDeclaration.js +136 -0
- package/dist/dev/src/components/PydanticClassDeclaration.js.map +1 -0
- package/dist/dev/src/components/StaticMethodDeclaration.js +19 -5
- package/dist/dev/src/components/StaticMethodDeclaration.js.map +1 -1
- package/dist/dev/src/components/index.js +1 -0
- package/dist/dev/src/components/index.js.map +1 -1
- package/dist/dev/test/classdeclarations.test.js +85 -52
- package/dist/dev/test/classdeclarations.test.js.map +1 -1
- package/dist/dev/test/dataclassdeclarations.test.js +122 -89
- package/dist/dev/test/dataclassdeclarations.test.js.map +1 -1
- package/dist/dev/test/decoratorlist.test.js +84 -0
- package/dist/dev/test/decoratorlist.test.js.map +1 -0
- package/dist/dev/test/enums.test.js +41 -10
- package/dist/dev/test/enums.test.js.map +1 -1
- package/dist/dev/test/functiondeclaration.test.js +81 -61
- package/dist/dev/test/functiondeclaration.test.js.map +1 -1
- package/dist/dev/test/methoddeclaration.test.js +117 -26
- package/dist/dev/test/methoddeclaration.test.js.map +1 -1
- package/dist/dev/test/propertydeclaration.test.js +109 -7
- package/dist/dev/test/propertydeclaration.test.js.map +1 -1
- package/dist/dev/test/pydanticclassdeclarations.test.js +1137 -0
- package/dist/dev/test/pydanticclassdeclarations.test.js.map +1 -0
- package/dist/src/builtins/python.d.ts +30 -0
- package/dist/src/builtins/python.d.ts.map +1 -1
- package/dist/src/builtins/python.js +46 -0
- package/dist/src/builtins/python.js.map +1 -1
- package/dist/src/components/ClassDeclaration.d.ts +21 -0
- package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
- package/dist/src/components/ClassDeclaration.js +6 -1
- package/dist/src/components/ClassDeclaration.js.map +1 -1
- package/dist/src/components/ClassMethodDeclaration.d.ts +5 -1
- package/dist/src/components/ClassMethodDeclaration.d.ts.map +1 -1
- package/dist/src/components/ClassMethodDeclaration.js +14 -3
- package/dist/src/components/ClassMethodDeclaration.js.map +1 -1
- package/dist/src/components/DataclassDeclaration.d.ts.map +1 -1
- package/dist/src/components/DataclassDeclaration.js +10 -4
- package/dist/src/components/DataclassDeclaration.js.map +1 -1
- package/dist/src/components/DecoratorList.d.ts +43 -0
- package/dist/src/components/DecoratorList.d.ts.map +1 -0
- package/dist/src/components/DecoratorList.js +47 -0
- package/dist/src/components/DecoratorList.js.map +1 -0
- package/dist/src/components/EnumDeclaration.d.ts +9 -0
- package/dist/src/components/EnumDeclaration.d.ts.map +1 -1
- package/dist/src/components/EnumDeclaration.js +6 -1
- package/dist/src/components/EnumDeclaration.js.map +1 -1
- package/dist/src/components/FunctionBase.d.ts +31 -1
- package/dist/src/components/FunctionBase.d.ts.map +1 -1
- package/dist/src/components/FunctionBase.js +9 -2
- package/dist/src/components/FunctionBase.js.map +1 -1
- package/dist/src/components/FutureStatement.d.ts +1 -1
- package/dist/src/components/FutureStatement.js +1 -1
- package/dist/src/components/MethodBase.d.ts.map +1 -1
- package/dist/src/components/MethodBase.js +10 -2
- package/dist/src/components/MethodBase.js.map +1 -1
- package/dist/src/components/PropertyDeclaration.d.ts +29 -0
- package/dist/src/components/PropertyDeclaration.d.ts.map +1 -1
- package/dist/src/components/PropertyDeclaration.js +48 -1
- package/dist/src/components/PropertyDeclaration.js.map +1 -1
- package/dist/src/components/PydanticClassDeclaration.d.ts +120 -0
- package/dist/src/components/PydanticClassDeclaration.d.ts.map +1 -0
- package/dist/src/components/PydanticClassDeclaration.js +116 -0
- package/dist/src/components/PydanticClassDeclaration.js.map +1 -0
- package/dist/src/components/StaticMethodDeclaration.d.ts +3 -0
- package/dist/src/components/StaticMethodDeclaration.d.ts.map +1 -1
- package/dist/src/components/StaticMethodDeclaration.js +13 -3
- package/dist/src/components/StaticMethodDeclaration.js.map +1 -1
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +1 -0
- package/dist/src/components/index.js.map +1 -1
- package/dist/test/classdeclarations.test.js +25 -0
- package/dist/test/classdeclarations.test.js.map +1 -1
- package/dist/test/dataclassdeclarations.test.js +25 -0
- package/dist/test/dataclassdeclarations.test.js.map +1 -1
- package/dist/test/decoratorlist.test.d.ts +2 -0
- package/dist/test/decoratorlist.test.d.ts.map +1 -0
- package/dist/test/decoratorlist.test.js +60 -0
- package/dist/test/decoratorlist.test.js.map +1 -0
- package/dist/test/enums.test.js +27 -0
- package/dist/test/enums.test.js.map +1 -1
- package/dist/test/functiondeclaration.test.js +16 -0
- package/dist/test/functiondeclaration.test.js.map +1 -1
- package/dist/test/methoddeclaration.test.js +67 -0
- package/dist/test/methoddeclaration.test.js.map +1 -1
- package/dist/test/propertydeclaration.test.js +71 -1
- package/dist/test/propertydeclaration.test.js.map +1 -1
- package/dist/test/pydanticclassdeclarations.test.d.ts +2 -0
- package/dist/test/pydanticclassdeclarations.test.d.ts.map +1 -0
- package/dist/test/pydanticclassdeclarations.test.js +829 -0
- package/dist/test/pydanticclassdeclarations.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docs/api/components/ClassDeclaration.md +10 -7
- package/docs/api/components/ClassEnumDeclaration.md +9 -6
- package/docs/api/components/ClassMethodDeclaration.md +7 -5
- package/docs/api/components/DataclassDeclaration.md +9 -5
- package/docs/api/components/DunderMethodDeclaration.md +7 -5
- package/docs/api/components/FunctionDeclaration.md +9 -5
- package/docs/api/components/FutureStatement.md +1 -1
- package/docs/api/components/MethodDeclaration.md +11 -6
- package/docs/api/components/PropertyDeclaration.md +11 -8
- package/docs/api/components/PydanticClassDeclaration.md +146 -0
- package/docs/api/components/StaticMethodDeclaration.md +7 -5
- package/docs/api/components/index.md +1 -0
- package/docs/api/index.md +3 -3
- package/docs/api/types/CommonFunctionProps.md +4 -3
- package/docs/api/types/PydanticModelConfigDictProps.md +32 -0
- package/docs/api/types/index.md +1 -0
- package/docs/api/variables/index.md +3 -0
- package/docs/api/variables/pydanticModule.md +27 -0
- package/docs/api/variables/pydanticSettingsModule.md +7 -0
- package/docs/api/variables/typingModule.md +9 -0
- package/package.json +6 -6
- package/src/builtins/python.ts +539 -1
- package/src/components/ClassDeclaration.tsx +23 -0
- package/src/components/ClassMethodDeclaration.tsx +9 -1
- package/src/components/DataclassDeclaration.tsx +18 -11
- package/src/components/DecoratorList.tsx +50 -0
- package/src/components/EnumDeclaration.tsx +11 -0
- package/src/components/FunctionBase.tsx +34 -3
- package/src/components/FutureStatement.tsx +1 -1
- package/src/components/MethodBase.tsx +6 -2
- package/src/components/PropertyDeclaration.tsx +48 -1
- package/src/components/PydanticClassDeclaration.tsx +222 -0
- package/src/components/StaticMethodDeclaration.tsx +7 -1
- package/src/components/index.ts +1 -0
- package/temp/api.json +1142 -84
- package/test/classdeclarations.test.tsx +27 -0
- package/test/dataclassdeclarations.test.tsx +25 -0
- package/test/decoratorlist.test.tsx +95 -0
- package/test/enums.test.tsx +29 -0
- package/test/functiondeclaration.test.tsx +17 -0
- package/test/methoddeclaration.test.tsx +70 -0
- package/test/propertydeclaration.test.tsx +66 -1
- package/test/pydanticclassdeclarations.test.tsx +836 -0
package/src/builtins/python.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SymbolCreator } from "@alloy-js/core";
|
|
2
|
-
import { createModule } from "../create-module.js";
|
|
2
|
+
import { createModule, type ModuleDescriptor } from "../create-module.js";
|
|
3
3
|
|
|
4
4
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
5
5
|
type dummy = SymbolCreator;
|
|
@@ -32,3 +32,541 @@ export const requestsModule = createModule({
|
|
|
32
32
|
models: ["Response", "Request"],
|
|
33
33
|
},
|
|
34
34
|
});
|
|
35
|
+
|
|
36
|
+
// Descriptor source captured from pydantic 2.13.4 via script
|
|
37
|
+
const pydanticDescriptor = {
|
|
38
|
+
".": [
|
|
39
|
+
"AfterValidator",
|
|
40
|
+
"AliasChoices",
|
|
41
|
+
"AliasGenerator",
|
|
42
|
+
"AliasPath",
|
|
43
|
+
"AllowInfNan",
|
|
44
|
+
"AmqpDsn",
|
|
45
|
+
"AnyHttpUrl",
|
|
46
|
+
"AnyUrl",
|
|
47
|
+
"AnyWebsocketUrl",
|
|
48
|
+
"AwareDatetime",
|
|
49
|
+
"Base64Bytes",
|
|
50
|
+
"Base64Encoder",
|
|
51
|
+
"Base64Str",
|
|
52
|
+
"Base64UrlBytes",
|
|
53
|
+
"Base64UrlStr",
|
|
54
|
+
"BaseModel",
|
|
55
|
+
"BeforeValidator",
|
|
56
|
+
"ByteSize",
|
|
57
|
+
"ClickHouseDsn",
|
|
58
|
+
"CockroachDsn",
|
|
59
|
+
"ConfigDict",
|
|
60
|
+
"DirectoryPath",
|
|
61
|
+
"Discriminator",
|
|
62
|
+
"EmailStr",
|
|
63
|
+
"EncodedBytes",
|
|
64
|
+
"EncodedStr",
|
|
65
|
+
"EncoderProtocol",
|
|
66
|
+
"Extra",
|
|
67
|
+
"FailFast",
|
|
68
|
+
"Field",
|
|
69
|
+
"FieldSerializationInfo",
|
|
70
|
+
"FilePath",
|
|
71
|
+
"FileUrl",
|
|
72
|
+
"FiniteFloat",
|
|
73
|
+
"FtpUrl",
|
|
74
|
+
"FutureDate",
|
|
75
|
+
"FutureDatetime",
|
|
76
|
+
"GetCoreSchemaHandler",
|
|
77
|
+
"GetJsonSchemaHandler",
|
|
78
|
+
"GetPydanticSchema",
|
|
79
|
+
"HttpUrl",
|
|
80
|
+
"IPvAnyAddress",
|
|
81
|
+
"IPvAnyInterface",
|
|
82
|
+
"IPvAnyNetwork",
|
|
83
|
+
"ImportString",
|
|
84
|
+
"InstanceOf",
|
|
85
|
+
"Json",
|
|
86
|
+
"JsonValue",
|
|
87
|
+
"KafkaDsn",
|
|
88
|
+
"MariaDBDsn",
|
|
89
|
+
"ModelWrapValidatorHandler",
|
|
90
|
+
"MongoDsn",
|
|
91
|
+
"MySQLDsn",
|
|
92
|
+
"NaiveDatetime",
|
|
93
|
+
"NameEmail",
|
|
94
|
+
"NatsDsn",
|
|
95
|
+
"NegativeFloat",
|
|
96
|
+
"NegativeInt",
|
|
97
|
+
"NewPath",
|
|
98
|
+
"NonNegativeFloat",
|
|
99
|
+
"NonNegativeInt",
|
|
100
|
+
"NonPositiveFloat",
|
|
101
|
+
"NonPositiveInt",
|
|
102
|
+
"OnErrorOmit",
|
|
103
|
+
"PastDate",
|
|
104
|
+
"PastDatetime",
|
|
105
|
+
"PaymentCardNumber",
|
|
106
|
+
"PlainSerializer",
|
|
107
|
+
"PlainValidator",
|
|
108
|
+
"PositiveFloat",
|
|
109
|
+
"PositiveInt",
|
|
110
|
+
"PostgresDsn",
|
|
111
|
+
"PrivateAttr",
|
|
112
|
+
"PydanticDeprecatedSince20",
|
|
113
|
+
"PydanticDeprecatedSince210",
|
|
114
|
+
"PydanticDeprecatedSince211",
|
|
115
|
+
"PydanticDeprecatedSince212",
|
|
116
|
+
"PydanticDeprecatedSince26",
|
|
117
|
+
"PydanticDeprecatedSince29",
|
|
118
|
+
"PydanticDeprecationWarning",
|
|
119
|
+
"PydanticErrorCodes",
|
|
120
|
+
"PydanticExperimentalWarning",
|
|
121
|
+
"PydanticForbiddenQualifier",
|
|
122
|
+
"PydanticImportError",
|
|
123
|
+
"PydanticInvalidForJsonSchema",
|
|
124
|
+
"PydanticSchemaGenerationError",
|
|
125
|
+
"PydanticUndefinedAnnotation",
|
|
126
|
+
"PydanticUserError",
|
|
127
|
+
"RedisDsn",
|
|
128
|
+
"RootModel",
|
|
129
|
+
"Secret",
|
|
130
|
+
"SecretBytes",
|
|
131
|
+
"SecretStr",
|
|
132
|
+
"SerializationInfo",
|
|
133
|
+
"SerializeAsAny",
|
|
134
|
+
"SerializerFunctionWrapHandler",
|
|
135
|
+
"SkipValidation",
|
|
136
|
+
"SnowflakeDsn",
|
|
137
|
+
"SocketPath",
|
|
138
|
+
"Strict",
|
|
139
|
+
"StrictBool",
|
|
140
|
+
"StrictBytes",
|
|
141
|
+
"StrictFloat",
|
|
142
|
+
"StrictInt",
|
|
143
|
+
"StrictStr",
|
|
144
|
+
"StringConstraints",
|
|
145
|
+
"Tag",
|
|
146
|
+
"TypeAdapter",
|
|
147
|
+
"UUID1",
|
|
148
|
+
"UUID3",
|
|
149
|
+
"UUID4",
|
|
150
|
+
"UUID5",
|
|
151
|
+
"UUID6",
|
|
152
|
+
"UUID7",
|
|
153
|
+
"UUID8",
|
|
154
|
+
"UrlConstraints",
|
|
155
|
+
"VERSION",
|
|
156
|
+
"ValidateAs",
|
|
157
|
+
"ValidationError",
|
|
158
|
+
"ValidationInfo",
|
|
159
|
+
"ValidatorFunctionWrapHandler",
|
|
160
|
+
"WebsocketUrl",
|
|
161
|
+
"WithJsonSchema",
|
|
162
|
+
"WrapSerializer",
|
|
163
|
+
"WrapValidator",
|
|
164
|
+
"__version__",
|
|
165
|
+
"computed_field",
|
|
166
|
+
"conbytes",
|
|
167
|
+
"condate",
|
|
168
|
+
"condecimal",
|
|
169
|
+
"confloat",
|
|
170
|
+
"confrozenset",
|
|
171
|
+
"conint",
|
|
172
|
+
"conlist",
|
|
173
|
+
"conset",
|
|
174
|
+
"constr",
|
|
175
|
+
"create_model",
|
|
176
|
+
"dataclasses",
|
|
177
|
+
"field_serializer",
|
|
178
|
+
"field_validator",
|
|
179
|
+
"model_serializer",
|
|
180
|
+
"model_validator",
|
|
181
|
+
"validate_call",
|
|
182
|
+
"validate_email",
|
|
183
|
+
"with_config",
|
|
184
|
+
],
|
|
185
|
+
alias_generators: ["to_camel", "to_pascal", "to_snake"],
|
|
186
|
+
aliases: ["AliasChoices", "AliasGenerator", "AliasPath"],
|
|
187
|
+
annotated_handlers: ["GetCoreSchemaHandler", "GetJsonSchemaHandler"],
|
|
188
|
+
color: [
|
|
189
|
+
"Any",
|
|
190
|
+
"COLORS_BY_NAME",
|
|
191
|
+
"COLORS_BY_VALUE",
|
|
192
|
+
"Callable",
|
|
193
|
+
"Color",
|
|
194
|
+
"ColorTuple",
|
|
195
|
+
"ColorType",
|
|
196
|
+
"CoreSchema",
|
|
197
|
+
"HslColorTuple",
|
|
198
|
+
"JsonSchemaValue",
|
|
199
|
+
"Optional",
|
|
200
|
+
"PydanticCustomError",
|
|
201
|
+
"PydanticDeprecatedSince20",
|
|
202
|
+
"RGBA",
|
|
203
|
+
"Union",
|
|
204
|
+
"cast",
|
|
205
|
+
"core_schema",
|
|
206
|
+
"deprecated",
|
|
207
|
+
"float_to_255",
|
|
208
|
+
"hls_to_rgb",
|
|
209
|
+
"ints_to_rgba",
|
|
210
|
+
"math",
|
|
211
|
+
"parse_color_value",
|
|
212
|
+
"parse_float_alpha",
|
|
213
|
+
"parse_hsl",
|
|
214
|
+
"parse_str",
|
|
215
|
+
"parse_tuple",
|
|
216
|
+
"r_hex_long",
|
|
217
|
+
"r_hex_short",
|
|
218
|
+
"r_hsl",
|
|
219
|
+
"r_hsl_v4_style",
|
|
220
|
+
"r_rgb",
|
|
221
|
+
"r_rgb_v4_style",
|
|
222
|
+
"rads",
|
|
223
|
+
"re",
|
|
224
|
+
"repeat_colors",
|
|
225
|
+
"rgb_to_hls",
|
|
226
|
+
],
|
|
227
|
+
config: ["ConfigDict", "with_config"],
|
|
228
|
+
dataclasses: ["dataclass", "rebuild_dataclass"],
|
|
229
|
+
errors: [
|
|
230
|
+
"PydanticErrorCodes",
|
|
231
|
+
"PydanticForbiddenQualifier",
|
|
232
|
+
"PydanticImportError",
|
|
233
|
+
"PydanticInvalidForJsonSchema",
|
|
234
|
+
"PydanticSchemaGenerationError",
|
|
235
|
+
"PydanticUndefinedAnnotation",
|
|
236
|
+
"PydanticUserError",
|
|
237
|
+
],
|
|
238
|
+
fields: ["Field", "FieldInfo", "PrivateAttr", "computed_field"],
|
|
239
|
+
functional_serializers: [
|
|
240
|
+
"Annotated",
|
|
241
|
+
"Any",
|
|
242
|
+
"AnyType",
|
|
243
|
+
"Callable",
|
|
244
|
+
"GetCoreSchemaHandler",
|
|
245
|
+
"Literal",
|
|
246
|
+
"PlainSerializer",
|
|
247
|
+
"PydanticUndefined",
|
|
248
|
+
"PydanticUndefinedAnnotation",
|
|
249
|
+
"PydanticUserError",
|
|
250
|
+
"SerializationInfo",
|
|
251
|
+
"SerializeAsAny",
|
|
252
|
+
"SerializerFunctionWrapHandler",
|
|
253
|
+
"TYPE_CHECKING",
|
|
254
|
+
"TypeAlias",
|
|
255
|
+
"TypeVar",
|
|
256
|
+
"WhenUsed",
|
|
257
|
+
"WrapSerializer",
|
|
258
|
+
"annotations",
|
|
259
|
+
"core_schema",
|
|
260
|
+
"dataclasses",
|
|
261
|
+
"field_serializer",
|
|
262
|
+
"model_serializer",
|
|
263
|
+
"overload",
|
|
264
|
+
"partial",
|
|
265
|
+
"partialmethod",
|
|
266
|
+
],
|
|
267
|
+
functional_validators: [
|
|
268
|
+
"AfterValidator",
|
|
269
|
+
"Annotated",
|
|
270
|
+
"Any",
|
|
271
|
+
"AnyType",
|
|
272
|
+
"ArbitraryTypeWarning",
|
|
273
|
+
"BeforeValidator",
|
|
274
|
+
"Callable",
|
|
275
|
+
"FieldValidatorModes",
|
|
276
|
+
"FreeModelBeforeValidator",
|
|
277
|
+
"FreeModelBeforeValidatorWithoutInfo",
|
|
278
|
+
"GetCoreSchemaHandler",
|
|
279
|
+
"InstanceOf",
|
|
280
|
+
"Literal",
|
|
281
|
+
"ModelAfterValidator",
|
|
282
|
+
"ModelAfterValidatorWithoutInfo",
|
|
283
|
+
"ModelBeforeValidator",
|
|
284
|
+
"ModelBeforeValidatorWithoutInfo",
|
|
285
|
+
"ModelWrapValidator",
|
|
286
|
+
"ModelWrapValidatorHandler",
|
|
287
|
+
"ModelWrapValidatorWithoutInfo",
|
|
288
|
+
"PlainValidator",
|
|
289
|
+
"Protocol",
|
|
290
|
+
"PydanticDeprecatedSince212",
|
|
291
|
+
"PydanticUndefined",
|
|
292
|
+
"PydanticUserError",
|
|
293
|
+
"Self",
|
|
294
|
+
"SkipValidation",
|
|
295
|
+
"TYPE_CHECKING",
|
|
296
|
+
"TypeAlias",
|
|
297
|
+
"TypeVar",
|
|
298
|
+
"Union",
|
|
299
|
+
"ValidateAs",
|
|
300
|
+
"WrapValidator",
|
|
301
|
+
"cast",
|
|
302
|
+
"core_schema",
|
|
303
|
+
"dataclasses",
|
|
304
|
+
"field_validator",
|
|
305
|
+
"model_validator",
|
|
306
|
+
"overload",
|
|
307
|
+
"partialmethod",
|
|
308
|
+
"sys",
|
|
309
|
+
"version_short",
|
|
310
|
+
"warnings",
|
|
311
|
+
],
|
|
312
|
+
json_schema: [
|
|
313
|
+
"Annotated",
|
|
314
|
+
"Any",
|
|
315
|
+
"AnyType",
|
|
316
|
+
"Callable",
|
|
317
|
+
"ComputedField",
|
|
318
|
+
"CoreModeRef",
|
|
319
|
+
"CoreRef",
|
|
320
|
+
"CoreSchema",
|
|
321
|
+
"CoreSchemaOrFieldType",
|
|
322
|
+
"Counter",
|
|
323
|
+
"DEFAULT_REF_TEMPLATE",
|
|
324
|
+
"DefsRef",
|
|
325
|
+
"Enum",
|
|
326
|
+
"Examples",
|
|
327
|
+
"GenerateJsonSchema",
|
|
328
|
+
"GetJsonSchemaHandler",
|
|
329
|
+
"Hashable",
|
|
330
|
+
"Iterable",
|
|
331
|
+
"JsonDict",
|
|
332
|
+
"JsonRef",
|
|
333
|
+
"JsonSchemaKeyT",
|
|
334
|
+
"JsonSchemaMode",
|
|
335
|
+
"JsonSchemaValue",
|
|
336
|
+
"JsonSchemaWarningKind",
|
|
337
|
+
"JsonValue",
|
|
338
|
+
"Literal",
|
|
339
|
+
"MISSING",
|
|
340
|
+
"NewType",
|
|
341
|
+
"NoDefault",
|
|
342
|
+
"Pattern",
|
|
343
|
+
"PydanticDeprecatedSince26",
|
|
344
|
+
"PydanticDeprecatedSince29",
|
|
345
|
+
"PydanticInvalidForJsonSchema",
|
|
346
|
+
"PydanticJsonSchemaWarning",
|
|
347
|
+
"PydanticOmit",
|
|
348
|
+
"PydanticSchemaGenerationError",
|
|
349
|
+
"PydanticUserError",
|
|
350
|
+
"Sequence",
|
|
351
|
+
"SkipJsonSchema",
|
|
352
|
+
"TYPE_CHECKING",
|
|
353
|
+
"TypeAlias",
|
|
354
|
+
"TypeVar",
|
|
355
|
+
"Union",
|
|
356
|
+
"WithJsonSchema",
|
|
357
|
+
"assert_never",
|
|
358
|
+
"cast",
|
|
359
|
+
"collections",
|
|
360
|
+
"core_schema",
|
|
361
|
+
"dataclasses",
|
|
362
|
+
"deepcopy",
|
|
363
|
+
"defaultdict",
|
|
364
|
+
"deprecated",
|
|
365
|
+
"final",
|
|
366
|
+
"get_literal_values",
|
|
367
|
+
"inspect",
|
|
368
|
+
"math",
|
|
369
|
+
"model_json_schema",
|
|
370
|
+
"models_json_schema",
|
|
371
|
+
"os",
|
|
372
|
+
"overload",
|
|
373
|
+
"pydantic_core",
|
|
374
|
+
"re",
|
|
375
|
+
"to_jsonable_python",
|
|
376
|
+
"warnings",
|
|
377
|
+
],
|
|
378
|
+
main: ["BaseModel", "create_model"],
|
|
379
|
+
networks: [
|
|
380
|
+
"AmqpDsn",
|
|
381
|
+
"AnyHttpUrl",
|
|
382
|
+
"AnyUrl",
|
|
383
|
+
"AnyWebsocketUrl",
|
|
384
|
+
"ClickHouseDsn",
|
|
385
|
+
"CockroachDsn",
|
|
386
|
+
"EmailStr",
|
|
387
|
+
"FileUrl",
|
|
388
|
+
"FtpUrl",
|
|
389
|
+
"HttpUrl",
|
|
390
|
+
"IPvAnyAddress",
|
|
391
|
+
"IPvAnyInterface",
|
|
392
|
+
"IPvAnyNetwork",
|
|
393
|
+
"KafkaDsn",
|
|
394
|
+
"MariaDBDsn",
|
|
395
|
+
"MongoDsn",
|
|
396
|
+
"MySQLDsn",
|
|
397
|
+
"NameEmail",
|
|
398
|
+
"NatsDsn",
|
|
399
|
+
"PostgresDsn",
|
|
400
|
+
"RedisDsn",
|
|
401
|
+
"SnowflakeDsn",
|
|
402
|
+
"UrlConstraints",
|
|
403
|
+
"WebsocketUrl",
|
|
404
|
+
"validate_email",
|
|
405
|
+
],
|
|
406
|
+
plugin: [
|
|
407
|
+
"BaseValidateHandlerProtocol",
|
|
408
|
+
"NewSchemaReturns",
|
|
409
|
+
"PydanticPluginProtocol",
|
|
410
|
+
"SchemaKind",
|
|
411
|
+
"SchemaTypePath",
|
|
412
|
+
"ValidateJsonHandlerProtocol",
|
|
413
|
+
"ValidatePythonHandlerProtocol",
|
|
414
|
+
"ValidateStringsHandlerProtocol",
|
|
415
|
+
],
|
|
416
|
+
root_model: ["RootModel"],
|
|
417
|
+
type_adapter: [
|
|
418
|
+
"Any",
|
|
419
|
+
"BaseModel",
|
|
420
|
+
"Callable",
|
|
421
|
+
"ConfigDict",
|
|
422
|
+
"CoreSchema",
|
|
423
|
+
"DEFAULT_REF_TEMPLATE",
|
|
424
|
+
"ExtraValues",
|
|
425
|
+
"FrameType",
|
|
426
|
+
"GenerateJsonSchema",
|
|
427
|
+
"Generic",
|
|
428
|
+
"IncEx",
|
|
429
|
+
"Iterable",
|
|
430
|
+
"JsonSchemaKeyT",
|
|
431
|
+
"JsonSchemaMode",
|
|
432
|
+
"JsonSchemaValue",
|
|
433
|
+
"Literal",
|
|
434
|
+
"P",
|
|
435
|
+
"ParamSpec",
|
|
436
|
+
"PluggableSchemaValidator",
|
|
437
|
+
"PydanticUndefinedAnnotation",
|
|
438
|
+
"PydanticUserError",
|
|
439
|
+
"R",
|
|
440
|
+
"SchemaSerializer",
|
|
441
|
+
"SchemaValidator",
|
|
442
|
+
"Some",
|
|
443
|
+
"T",
|
|
444
|
+
"TypeAdapter",
|
|
445
|
+
"TypeAdapterT",
|
|
446
|
+
"TypeVar",
|
|
447
|
+
"cast",
|
|
448
|
+
"create_schema_validator",
|
|
449
|
+
"final",
|
|
450
|
+
"is_dataclass",
|
|
451
|
+
"is_typeddict",
|
|
452
|
+
"overload",
|
|
453
|
+
"sys",
|
|
454
|
+
"types",
|
|
455
|
+
],
|
|
456
|
+
types: [
|
|
457
|
+
"AllowInfNan",
|
|
458
|
+
"AwareDatetime",
|
|
459
|
+
"Base64Bytes",
|
|
460
|
+
"Base64Encoder",
|
|
461
|
+
"Base64Str",
|
|
462
|
+
"Base64UrlBytes",
|
|
463
|
+
"Base64UrlStr",
|
|
464
|
+
"ByteSize",
|
|
465
|
+
"DirectoryPath",
|
|
466
|
+
"Discriminator",
|
|
467
|
+
"EncodedBytes",
|
|
468
|
+
"EncodedStr",
|
|
469
|
+
"EncoderProtocol",
|
|
470
|
+
"FailFast",
|
|
471
|
+
"FilePath",
|
|
472
|
+
"FiniteFloat",
|
|
473
|
+
"FutureDate",
|
|
474
|
+
"FutureDatetime",
|
|
475
|
+
"GetPydanticSchema",
|
|
476
|
+
"ImportString",
|
|
477
|
+
"Json",
|
|
478
|
+
"JsonValue",
|
|
479
|
+
"NaiveDatetime",
|
|
480
|
+
"NegativeFloat",
|
|
481
|
+
"NegativeInt",
|
|
482
|
+
"NewPath",
|
|
483
|
+
"NonNegativeFloat",
|
|
484
|
+
"NonNegativeInt",
|
|
485
|
+
"NonPositiveFloat",
|
|
486
|
+
"NonPositiveInt",
|
|
487
|
+
"OnErrorOmit",
|
|
488
|
+
"PastDate",
|
|
489
|
+
"PastDatetime",
|
|
490
|
+
"PaymentCardNumber",
|
|
491
|
+
"PositiveFloat",
|
|
492
|
+
"PositiveInt",
|
|
493
|
+
"Secret",
|
|
494
|
+
"SecretBytes",
|
|
495
|
+
"SecretStr",
|
|
496
|
+
"SocketPath",
|
|
497
|
+
"Strict",
|
|
498
|
+
"StrictBool",
|
|
499
|
+
"StrictBytes",
|
|
500
|
+
"StrictFloat",
|
|
501
|
+
"StrictInt",
|
|
502
|
+
"StrictStr",
|
|
503
|
+
"StringConstraints",
|
|
504
|
+
"Tag",
|
|
505
|
+
"UUID1",
|
|
506
|
+
"UUID3",
|
|
507
|
+
"UUID4",
|
|
508
|
+
"UUID5",
|
|
509
|
+
"UUID6",
|
|
510
|
+
"UUID7",
|
|
511
|
+
"UUID8",
|
|
512
|
+
"conbytes",
|
|
513
|
+
"condate",
|
|
514
|
+
"condecimal",
|
|
515
|
+
"confloat",
|
|
516
|
+
"confrozenset",
|
|
517
|
+
"conint",
|
|
518
|
+
"conlist",
|
|
519
|
+
"conset",
|
|
520
|
+
"constr",
|
|
521
|
+
],
|
|
522
|
+
validate_call_decorator: ["validate_call"],
|
|
523
|
+
version: ["VERSION", "version_info"],
|
|
524
|
+
warnings: [
|
|
525
|
+
"ArbitraryTypeWarning",
|
|
526
|
+
"PydanticDeprecatedSince20",
|
|
527
|
+
"PydanticDeprecatedSince210",
|
|
528
|
+
"PydanticDeprecatedSince211",
|
|
529
|
+
"PydanticDeprecatedSince212",
|
|
530
|
+
"PydanticDeprecatedSince26",
|
|
531
|
+
"PydanticDeprecatedSince29",
|
|
532
|
+
"PydanticDeprecationWarning",
|
|
533
|
+
"PydanticExperimentalWarning",
|
|
534
|
+
"TypedDictExtraConfigWarning",
|
|
535
|
+
"UnsupportedFieldAttributeWarning",
|
|
536
|
+
],
|
|
537
|
+
} as const satisfies ModuleDescriptor;
|
|
538
|
+
|
|
539
|
+
export const pydanticModule = createModule({
|
|
540
|
+
name: "pydantic",
|
|
541
|
+
descriptor: pydanticDescriptor,
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
/** `typing` stdlib symbols used heavily with Pydantic generics and annotations. */
|
|
545
|
+
export const typingModule = createModule({
|
|
546
|
+
name: "typing",
|
|
547
|
+
descriptor: {
|
|
548
|
+
".": [
|
|
549
|
+
"Annotated",
|
|
550
|
+
"Any",
|
|
551
|
+
"ClassVar",
|
|
552
|
+
"Generic",
|
|
553
|
+
"Literal",
|
|
554
|
+
"Optional",
|
|
555
|
+
"Protocol",
|
|
556
|
+
"TypeVar",
|
|
557
|
+
"Union",
|
|
558
|
+
// Class- and method-level decorators commonly stacked above the
|
|
559
|
+
// intrinsic `class` / `def`.
|
|
560
|
+
"final",
|
|
561
|
+
"override",
|
|
562
|
+
"runtime_checkable",
|
|
563
|
+
],
|
|
564
|
+
},
|
|
565
|
+
});
|
|
566
|
+
|
|
567
|
+
export const pydanticSettingsModule = createModule({
|
|
568
|
+
name: "pydantic_settings",
|
|
569
|
+
descriptor: {
|
|
570
|
+
".": ["BaseSettings", "SettingsConfigDict"],
|
|
571
|
+
},
|
|
572
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Children, List, Name, Show, createContentSlot } from "@alloy-js/core";
|
|
2
2
|
import { createPythonSymbol } from "../symbol-creation.js";
|
|
3
3
|
import { BaseDeclarationProps, Declaration } from "./Declaration.js";
|
|
4
|
+
import { DecoratorList } from "./DecoratorList.jsx";
|
|
4
5
|
import { MemberScope } from "./MemberScope.jsx";
|
|
5
6
|
import { PythonBlock } from "./PythonBlock.jsx";
|
|
6
7
|
|
|
@@ -9,6 +10,27 @@ export interface ClassDeclarationProps extends BaseDeclarationProps {
|
|
|
9
10
|
* The base classes that this class inherits from.
|
|
10
11
|
*/
|
|
11
12
|
bases?: Children[];
|
|
13
|
+
/**
|
|
14
|
+
* Decorators rendered above the `class` keyword, in source order —
|
|
15
|
+
* `decorators[0]` is topmost. By Python's bottom-up application order, the
|
|
16
|
+
* topmost entry is the outermost decorator (applied last).
|
|
17
|
+
*
|
|
18
|
+
* Each entry should produce a complete decorator line (typically starting
|
|
19
|
+
* with `@`). Falsy entries are skipped, so conditional decorators can be
|
|
20
|
+
* provided inline when needed.
|
|
21
|
+
*
|
|
22
|
+
* Wrappers like `DataclassDeclaration` build their intrinsic decorator
|
|
23
|
+
* (e.g. `@dataclass(...)`) and append it to this list at the position that
|
|
24
|
+
* keeps `@dataclass` closest to the class — i.e. user `decorators` end up
|
|
25
|
+
* **above** the intrinsic one, matching how Pydantic's `@field_validator`
|
|
26
|
+
* sits above `@classmethod` on methods.
|
|
27
|
+
*
|
|
28
|
+
* Do **not** pass a wrapper's intrinsic decorator here. For example, when
|
|
29
|
+
* using `DataclassDeclaration`, do not include `@dataclass(...)` in
|
|
30
|
+
* `decorators` — the component renders it for you, and stacking it twice
|
|
31
|
+
* would produce invalid Python.
|
|
32
|
+
*/
|
|
33
|
+
decorators?: Children[];
|
|
12
34
|
}
|
|
13
35
|
|
|
14
36
|
/**
|
|
@@ -57,6 +79,7 @@ export function ClassDeclaration(props: ClassDeclarationProps) {
|
|
|
57
79
|
|
|
58
80
|
return (
|
|
59
81
|
<Declaration symbol={sym}>
|
|
82
|
+
<DecoratorList decorators={props.decorators} />
|
|
60
83
|
class <Name />
|
|
61
84
|
<MemberScope ownerSymbol={sym}>
|
|
62
85
|
{basesPart}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { splitProps } from "@alloy-js/core";
|
|
1
2
|
import { createMethodSymbol } from "../symbols/factories.js";
|
|
3
|
+
import { DecoratorList } from "./DecoratorList.jsx";
|
|
2
4
|
import type { CommonFunctionProps } from "./FunctionBase.js";
|
|
3
5
|
import { MethodDeclarationBase } from "./MethodBase.js";
|
|
4
6
|
|
|
@@ -17,6 +19,10 @@ import { MethodDeclarationBase } from "./MethodBase.js";
|
|
|
17
19
|
* def create(cls, value: str) -> None:
|
|
18
20
|
* return cls(value)
|
|
19
21
|
* ```
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* Use **`decorators`** for decorators that must appear above `@classmethod`
|
|
25
|
+
* (for example Pydantic `@field_validator`).
|
|
20
26
|
*/
|
|
21
27
|
export interface ClassMethodDeclarationProps extends CommonFunctionProps {
|
|
22
28
|
abstract?: boolean;
|
|
@@ -24,11 +30,13 @@ export interface ClassMethodDeclarationProps extends CommonFunctionProps {
|
|
|
24
30
|
|
|
25
31
|
export function ClassMethodDeclaration(props: ClassMethodDeclarationProps) {
|
|
26
32
|
const sym = createMethodSymbol(props.name, { refkeys: props.refkey });
|
|
33
|
+
const [decoratorProps, rest] = splitProps(props, ["decorators"]);
|
|
27
34
|
return (
|
|
28
35
|
<>
|
|
36
|
+
<DecoratorList decorators={decoratorProps.decorators} />
|
|
29
37
|
{"@classmethod"}
|
|
30
38
|
<hbr />
|
|
31
|
-
<MethodDeclarationBase functionType="class" {...
|
|
39
|
+
<MethodDeclarationBase functionType="class" {...rest} sym={sym} />
|
|
32
40
|
</>
|
|
33
41
|
);
|
|
34
42
|
}
|
|
@@ -160,7 +160,7 @@ export function DataclassDeclaration(props: DataclassDeclarationProps) {
|
|
|
160
160
|
validateDataclassDecoratorArgs(kwargs);
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
|
|
163
|
+
const dataclassDecorator = (
|
|
164
164
|
<>
|
|
165
165
|
{"@"}
|
|
166
166
|
{dataclassesModule["."].dataclass}
|
|
@@ -175,16 +175,23 @@ export function DataclassDeclaration(props: DataclassDeclarationProps) {
|
|
|
175
175
|
</For>
|
|
176
176
|
)
|
|
177
177
|
</Show>
|
|
178
|
-
<hbr />
|
|
179
|
-
<ClassDeclaration
|
|
180
|
-
name={props.name}
|
|
181
|
-
bases={props.bases}
|
|
182
|
-
doc={props.doc}
|
|
183
|
-
refkey={props.refkey}
|
|
184
|
-
>
|
|
185
|
-
<StatementList>{props.children}</StatementList>
|
|
186
|
-
{validateDataclassMemberConflicts(kwargs as DataclassDecoratorKwargs)}
|
|
187
|
-
</ClassDeclaration>
|
|
188
178
|
</>
|
|
189
179
|
);
|
|
180
|
+
|
|
181
|
+
// User decorators stack above the intrinsic `@dataclass(...)`, mirroring
|
|
182
|
+
// how Pydantic's `@field_validator` sits above `@classmethod` on methods.
|
|
183
|
+
const decorators = [...(props.decorators ?? []), dataclassDecorator];
|
|
184
|
+
|
|
185
|
+
return (
|
|
186
|
+
<ClassDeclaration
|
|
187
|
+
name={props.name}
|
|
188
|
+
bases={props.bases}
|
|
189
|
+
doc={props.doc}
|
|
190
|
+
refkey={props.refkey}
|
|
191
|
+
decorators={decorators}
|
|
192
|
+
>
|
|
193
|
+
<StatementList>{props.children}</StatementList>
|
|
194
|
+
{validateDataclassMemberConflicts(kwargs as DataclassDecoratorKwargs)}
|
|
195
|
+
</ClassDeclaration>
|
|
196
|
+
);
|
|
190
197
|
}
|