@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.
Files changed (153) hide show
  1. package/dist/dev/src/builtins/python.js +46 -0
  2. package/dist/dev/src/builtins/python.js.map +1 -1
  3. package/dist/dev/src/components/ClassDeclaration.js +19 -10
  4. package/dist/dev/src/components/ClassDeclaration.js.map +1 -1
  5. package/dist/dev/src/components/ClassMethodDeclaration.js +20 -5
  6. package/dist/dev/src/components/ClassMethodDeclaration.js.map +1 -1
  7. package/dist/dev/src/components/DataclassDeclaration.js +14 -12
  8. package/dist/dev/src/components/DataclassDeclaration.js.map +1 -1
  9. package/dist/dev/src/components/DecoratorList.js +55 -0
  10. package/dist/dev/src/components/DecoratorList.js.map +1 -0
  11. package/dist/dev/src/components/EnumDeclaration.js +21 -12
  12. package/dist/dev/src/components/EnumDeclaration.js.map +1 -1
  13. package/dist/dev/src/components/FunctionBase.js +21 -10
  14. package/dist/dev/src/components/FunctionBase.js.map +1 -1
  15. package/dist/dev/src/components/FutureStatement.js +1 -1
  16. package/dist/dev/src/components/MethodBase.js +16 -4
  17. package/dist/dev/src/components/MethodBase.js.map +1 -1
  18. package/dist/dev/src/components/PropertyDeclaration.js +68 -17
  19. package/dist/dev/src/components/PropertyDeclaration.js.map +1 -1
  20. package/dist/dev/src/components/PydanticClassDeclaration.js +136 -0
  21. package/dist/dev/src/components/PydanticClassDeclaration.js.map +1 -0
  22. package/dist/dev/src/components/StaticMethodDeclaration.js +19 -5
  23. package/dist/dev/src/components/StaticMethodDeclaration.js.map +1 -1
  24. package/dist/dev/src/components/index.js +1 -0
  25. package/dist/dev/src/components/index.js.map +1 -1
  26. package/dist/dev/test/classdeclarations.test.js +85 -52
  27. package/dist/dev/test/classdeclarations.test.js.map +1 -1
  28. package/dist/dev/test/dataclassdeclarations.test.js +122 -89
  29. package/dist/dev/test/dataclassdeclarations.test.js.map +1 -1
  30. package/dist/dev/test/decoratorlist.test.js +84 -0
  31. package/dist/dev/test/decoratorlist.test.js.map +1 -0
  32. package/dist/dev/test/enums.test.js +41 -10
  33. package/dist/dev/test/enums.test.js.map +1 -1
  34. package/dist/dev/test/functiondeclaration.test.js +81 -61
  35. package/dist/dev/test/functiondeclaration.test.js.map +1 -1
  36. package/dist/dev/test/methoddeclaration.test.js +117 -26
  37. package/dist/dev/test/methoddeclaration.test.js.map +1 -1
  38. package/dist/dev/test/propertydeclaration.test.js +109 -7
  39. package/dist/dev/test/propertydeclaration.test.js.map +1 -1
  40. package/dist/dev/test/pydanticclassdeclarations.test.js +1137 -0
  41. package/dist/dev/test/pydanticclassdeclarations.test.js.map +1 -0
  42. package/dist/src/builtins/python.d.ts +30 -0
  43. package/dist/src/builtins/python.d.ts.map +1 -1
  44. package/dist/src/builtins/python.js +46 -0
  45. package/dist/src/builtins/python.js.map +1 -1
  46. package/dist/src/components/ClassDeclaration.d.ts +21 -0
  47. package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
  48. package/dist/src/components/ClassDeclaration.js +6 -1
  49. package/dist/src/components/ClassDeclaration.js.map +1 -1
  50. package/dist/src/components/ClassMethodDeclaration.d.ts +5 -1
  51. package/dist/src/components/ClassMethodDeclaration.d.ts.map +1 -1
  52. package/dist/src/components/ClassMethodDeclaration.js +14 -3
  53. package/dist/src/components/ClassMethodDeclaration.js.map +1 -1
  54. package/dist/src/components/DataclassDeclaration.d.ts.map +1 -1
  55. package/dist/src/components/DataclassDeclaration.js +10 -4
  56. package/dist/src/components/DataclassDeclaration.js.map +1 -1
  57. package/dist/src/components/DecoratorList.d.ts +43 -0
  58. package/dist/src/components/DecoratorList.d.ts.map +1 -0
  59. package/dist/src/components/DecoratorList.js +47 -0
  60. package/dist/src/components/DecoratorList.js.map +1 -0
  61. package/dist/src/components/EnumDeclaration.d.ts +9 -0
  62. package/dist/src/components/EnumDeclaration.d.ts.map +1 -1
  63. package/dist/src/components/EnumDeclaration.js +6 -1
  64. package/dist/src/components/EnumDeclaration.js.map +1 -1
  65. package/dist/src/components/FunctionBase.d.ts +31 -1
  66. package/dist/src/components/FunctionBase.d.ts.map +1 -1
  67. package/dist/src/components/FunctionBase.js +9 -2
  68. package/dist/src/components/FunctionBase.js.map +1 -1
  69. package/dist/src/components/FutureStatement.d.ts +1 -1
  70. package/dist/src/components/FutureStatement.js +1 -1
  71. package/dist/src/components/MethodBase.d.ts.map +1 -1
  72. package/dist/src/components/MethodBase.js +10 -2
  73. package/dist/src/components/MethodBase.js.map +1 -1
  74. package/dist/src/components/PropertyDeclaration.d.ts +29 -0
  75. package/dist/src/components/PropertyDeclaration.d.ts.map +1 -1
  76. package/dist/src/components/PropertyDeclaration.js +48 -1
  77. package/dist/src/components/PropertyDeclaration.js.map +1 -1
  78. package/dist/src/components/PydanticClassDeclaration.d.ts +120 -0
  79. package/dist/src/components/PydanticClassDeclaration.d.ts.map +1 -0
  80. package/dist/src/components/PydanticClassDeclaration.js +116 -0
  81. package/dist/src/components/PydanticClassDeclaration.js.map +1 -0
  82. package/dist/src/components/StaticMethodDeclaration.d.ts +3 -0
  83. package/dist/src/components/StaticMethodDeclaration.d.ts.map +1 -1
  84. package/dist/src/components/StaticMethodDeclaration.js +13 -3
  85. package/dist/src/components/StaticMethodDeclaration.js.map +1 -1
  86. package/dist/src/components/index.d.ts +1 -0
  87. package/dist/src/components/index.d.ts.map +1 -1
  88. package/dist/src/components/index.js +1 -0
  89. package/dist/src/components/index.js.map +1 -1
  90. package/dist/test/classdeclarations.test.js +25 -0
  91. package/dist/test/classdeclarations.test.js.map +1 -1
  92. package/dist/test/dataclassdeclarations.test.js +25 -0
  93. package/dist/test/dataclassdeclarations.test.js.map +1 -1
  94. package/dist/test/decoratorlist.test.d.ts +2 -0
  95. package/dist/test/decoratorlist.test.d.ts.map +1 -0
  96. package/dist/test/decoratorlist.test.js +60 -0
  97. package/dist/test/decoratorlist.test.js.map +1 -0
  98. package/dist/test/enums.test.js +27 -0
  99. package/dist/test/enums.test.js.map +1 -1
  100. package/dist/test/functiondeclaration.test.js +16 -0
  101. package/dist/test/functiondeclaration.test.js.map +1 -1
  102. package/dist/test/methoddeclaration.test.js +67 -0
  103. package/dist/test/methoddeclaration.test.js.map +1 -1
  104. package/dist/test/propertydeclaration.test.js +71 -1
  105. package/dist/test/propertydeclaration.test.js.map +1 -1
  106. package/dist/test/pydanticclassdeclarations.test.d.ts +2 -0
  107. package/dist/test/pydanticclassdeclarations.test.d.ts.map +1 -0
  108. package/dist/test/pydanticclassdeclarations.test.js +829 -0
  109. package/dist/test/pydanticclassdeclarations.test.js.map +1 -0
  110. package/dist/tsconfig.tsbuildinfo +1 -1
  111. package/docs/api/components/ClassDeclaration.md +10 -7
  112. package/docs/api/components/ClassEnumDeclaration.md +9 -6
  113. package/docs/api/components/ClassMethodDeclaration.md +7 -5
  114. package/docs/api/components/DataclassDeclaration.md +9 -5
  115. package/docs/api/components/DunderMethodDeclaration.md +7 -5
  116. package/docs/api/components/FunctionDeclaration.md +9 -5
  117. package/docs/api/components/FutureStatement.md +1 -1
  118. package/docs/api/components/MethodDeclaration.md +11 -6
  119. package/docs/api/components/PropertyDeclaration.md +11 -8
  120. package/docs/api/components/PydanticClassDeclaration.md +146 -0
  121. package/docs/api/components/StaticMethodDeclaration.md +7 -5
  122. package/docs/api/components/index.md +1 -0
  123. package/docs/api/index.md +3 -3
  124. package/docs/api/types/CommonFunctionProps.md +4 -3
  125. package/docs/api/types/PydanticModelConfigDictProps.md +32 -0
  126. package/docs/api/types/index.md +1 -0
  127. package/docs/api/variables/index.md +3 -0
  128. package/docs/api/variables/pydanticModule.md +27 -0
  129. package/docs/api/variables/pydanticSettingsModule.md +7 -0
  130. package/docs/api/variables/typingModule.md +9 -0
  131. package/package.json +6 -6
  132. package/src/builtins/python.ts +539 -1
  133. package/src/components/ClassDeclaration.tsx +23 -0
  134. package/src/components/ClassMethodDeclaration.tsx +9 -1
  135. package/src/components/DataclassDeclaration.tsx +18 -11
  136. package/src/components/DecoratorList.tsx +50 -0
  137. package/src/components/EnumDeclaration.tsx +11 -0
  138. package/src/components/FunctionBase.tsx +34 -3
  139. package/src/components/FutureStatement.tsx +1 -1
  140. package/src/components/MethodBase.tsx +6 -2
  141. package/src/components/PropertyDeclaration.tsx +48 -1
  142. package/src/components/PydanticClassDeclaration.tsx +222 -0
  143. package/src/components/StaticMethodDeclaration.tsx +7 -1
  144. package/src/components/index.ts +1 -0
  145. package/temp/api.json +1142 -84
  146. package/test/classdeclarations.test.tsx +27 -0
  147. package/test/dataclassdeclarations.test.tsx +25 -0
  148. package/test/decoratorlist.test.tsx +95 -0
  149. package/test/enums.test.tsx +29 -0
  150. package/test/functiondeclaration.test.tsx +17 -0
  151. package/test/methoddeclaration.test.tsx +70 -0
  152. package/test/propertydeclaration.test.tsx +66 -1
  153. package/test/pydanticclassdeclarations.test.tsx +836 -0
@@ -1,3 +1,4 @@
1
+ import { type Children } from "@alloy-js/core";
1
2
  import { PythonOutputSymbol } from "../index.js";
2
3
  import { CallSignatureProps } from "./CallSignature.jsx";
3
4
  import { BaseDeclarationProps } from "./Declaration.js";
@@ -12,6 +13,35 @@ import { BaseDeclarationProps } from "./Declaration.js";
12
13
  export interface CommonFunctionProps extends BaseDeclarationProps, CallSignatureProps {
13
14
  /** Indicates that the function is async. */
14
15
  async?: boolean;
16
+ /**
17
+ * Decorators rendered above `def`, in source order — `decorators[0]` is
18
+ * topmost. By Python's bottom-up application order, the topmost entry is
19
+ * the **outermost** decorator (applied last) and wraps the result of every
20
+ * decorator below it.
21
+ *
22
+ * Each entry should produce a complete decorator line (typically starting
23
+ * with `@`). Falsy entries (other than `0`) are skipped, so conditional
24
+ * decorators can be provided inline when needed.
25
+ *
26
+ * When used through wrappers that emit an intrinsic decorator
27
+ * (`ClassMethodDeclaration` → `@classmethod`,
28
+ * `StaticMethodDeclaration` → `@staticmethod`,
29
+ * `PropertyDeclaration` → `@property`), these decorators are rendered
30
+ * **above** the intrinsic line — the correct position for Pydantic's
31
+ * `@field_validator` / `@model_validator` and other wrappers that must
32
+ * see the underlying function, not a descriptor.
33
+ *
34
+ * When used on plain `MethodDeclaration` / `FunctionDeclaration`, these
35
+ * decorators are rendered above `@abstractmethod` (if `abstract` is set)
36
+ * and above `def`.
37
+ *
38
+ * Do **not** pass intrinsic decorators here — i.e. `@classmethod`,
39
+ * `@staticmethod`, `@property`, or `@abstractmethod`. Those are emitted by
40
+ * the matching component (`ClassMethodDeclaration`, `StaticMethodDeclaration`,
41
+ * `PropertyDeclaration`, or the `abstract` flag) and would otherwise be
42
+ * stacked twice in the output, producing invalid Python.
43
+ */
44
+ decorators?: Children[];
15
45
  }
16
46
  /**
17
47
  * Props for `BaseFunctionDeclaration`.
@@ -44,5 +74,5 @@ export interface BaseFunctionDeclarationProps extends CommonFunctionProps {
44
74
  * return x
45
75
  * ```
46
76
  */
47
- export declare function BaseFunctionDeclaration(props: BaseFunctionDeclarationProps): import("@alloy-js/core").Children;
77
+ export declare function BaseFunctionDeclaration(props: BaseFunctionDeclarationProps): Children;
48
78
  //# sourceMappingURL=FunctionBase.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FunctionBase.d.ts","sourceRoot":"","sources":["../../../src/components/FunctionBase.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAiB,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAe,MAAM,kBAAkB,CAAC;AAIrE;;;;;;;GAOG;AACH,MAAM,WAAW,mBACf,SAAQ,oBAAoB,EAC1B,kBAAkB;IACpB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,4BAA6B,SAAQ,mBAAmB;IACvE,sCAAsC;IACtC,YAAY,CAAC,EAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC/C,gEAAgE;IAChE,GAAG,EAAE,kBAAkB,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,4BAA4B,qCAiC1E"}
1
+ {"version":3,"file":"FunctionBase.d.ts","sourceRoot":"","sources":["../../../src/components/FunctionBase.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiC,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAiB,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAe,MAAM,kBAAkB,CAAC;AAKrE;;;;;;;GAOG;AACH,MAAM,WAAW,mBACf,SAAQ,oBAAoB,EAC1B,kBAAkB;IACpB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,UAAU,CAAC,EAAE,QAAQ,EAAE,CAAC;CACzB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,4BAA6B,SAAQ,mBAAmB;IACvE,sCAAsC;IACtC,YAAY,CAAC,EAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC/C,gEAAgE;IAChE,GAAG,EAAE,kBAAkB,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,4BAA4B,YAkC1E"}
@@ -3,6 +3,7 @@ import { createContentSlot, Name, Show } from "@alloy-js/core";
3
3
  import { getCallSignatureProps } from "../utils.js";
4
4
  import { CallSignature } from "./CallSignature.js";
5
5
  import { Declaration } from "./Declaration.js";
6
+ import { DecoratorList } from "./DecoratorList.js";
6
7
  import { LexicalScope } from "./LexicalScope.js";
7
8
  import { PythonBlock } from "./PythonBlock.js";
8
9
 
@@ -42,6 +43,11 @@ import { PythonBlock } from "./PythonBlock.js";
42
43
  * ```
43
44
  */
44
45
  export function BaseFunctionDeclaration(props) {
46
+ const {
47
+ decorators,
48
+ sym,
49
+ ...declarationProps
50
+ } = props;
45
51
  const asyncKwd = props.async ? "async " : "";
46
52
  let parameters;
47
53
  switch (props.functionType) {
@@ -58,9 +64,10 @@ export function BaseFunctionDeclaration(props) {
58
64
  default:
59
65
  parameters = props.parameters;
60
66
  }
61
- const sym = props.sym;
62
67
  const ContentSlot = createContentSlot();
63
- return [_$createComponent(Declaration, _$mergeProps(props, {
68
+ return [_$createComponent(DecoratorList, {
69
+ decorators: decorators
70
+ }), _$createComponent(Declaration, _$mergeProps(declarationProps, {
64
71
  nameKind: "function",
65
72
  symbol: sym,
66
73
  get children() {
@@ -1 +1 @@
1
- {"version":3,"names":["createContentSlot","Name","Show","getCallSignatureProps","CallSignature","Declaration","LexicalScope","PythonBlock","BaseFunctionDeclaration","props","asyncKwd","async","parameters","functionType","name","sym","ContentSlot","_$createComponent","_$mergeProps","nameKind","symbol","children","opener","when","Boolean","doc","WhenEmpty"],"sources":["../../../src/components/FunctionBase.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,iBAAiB,EAAEC,IAAI,EAAEC,IAAI,QAAQ,gBAAgB;AAE9D,SAASC,qBAAqB,QAAQ,aAAa;AACnD,SAASC,aAAa;AACtB,SAA+BC,WAAW,QAAQ,kBAAkB;AACpE,SAASC,YAAY;AACrB,SAASC,WAAW;;AAEpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,uBAAuBA,CAACC,KAAmC,EAAE;EAC3E,MAAMC,QAAQ,GAAGD,KAAK,CAACE,KAAK,GAAG,QAAQ,GAAG,EAAE;EAC5C,IAAIC,UAAU;EACd,QAAQH,KAAK,CAACI,YAAY;IACxB,KAAK,UAAU;MACbD,UAAU,GAAG,CAAC;QAA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List":[]}
1
+ {"version":3,"names":["createContentSlot","Name","Show","getCallSignatureProps","CallSignature","Declaration","DecoratorList","LexicalScope","PythonBlock","BaseFunctionDeclaration","props","decorators","sym","declarationProps","asyncKwd","async","parameters","functionType","name","ContentSlot","_$createComponent","_$mergeProps","nameKind","symbol","children","opener","when","Boolean","doc","WhenEmpty"],"sources":["../../../src/components/FunctionBase.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,iBAAiB,EAAEC,IAAI,EAAEC,IAAI,QAAuB,gBAAgB;AAE7E,SAASC,qBAAqB,QAAQ,aAAa;AACnD,SAASC,aAAa;AACtB,SAA+BC,WAAW,QAAQ,kBAAkB;AACpE,SAASC,aAAa;AACtB,SAASC,YAAY;AACrB,SAASC,WAAW;;AAEpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,uBAAuBA,CAACC,KAAmC,EAAE;EAC3E,MAAM;IAAEC,UAAU;IAAEC,GAAG;IAAE,GAAGC;EAAiB,CAAC,GAAGH,KAAK;EACtD,MAAMI,QAAQ,GAAGJ,KAAK,CAACK,KAAK,GAAG,QAAQ,GAAG,EAAE;EAC5C,IAAIC,UAAU;EACd,QAAQN,KAAK,CAACO,YAAY;IACxB,KAAK,UAAU;MACbD,UAAU,GAAG,CAAC;QAAEE,IAAI,EAAE;MAAO,CAAC,EAAE,IAAIR,KAAK,CAACM,UAAU,IAAI,EAAE,CAAC,CAAC;MAC5D;IACF,KAAK,OAAO;MACVA,UAAU,GAAG,CAAC;QAAEE,IAAI,EAAE;MAAM,CAAC,EAAE,IAAIR,KAAK,CAACM,UAAU,IAAI,EAAE,CAAC,CAAC;MAC3D;IACF;MACEA,UAAU,GAAGN,KAAK,CAACM,UAAU;EACjC;EACA,MAAMG,WAAW,GAAGnB,iBAAiB,CAAC,CAAC;EACvC,QAAAoB,iBAAA,CAEKd,aAAa;IAACK,UAAU,EAAEA;EAAU,IAAAS,iBAAA,CACpCf,WAAW,EAAAgB,YAAA,CAAKR,gBAAgB;IAAES,QAAQ;IAAYC,MAAM,EAAEX,GAAG;IAAA,IAAAY,SAAA;MAAA,QAC/DV,QAAQ,UAAAM,iBAAA,CAAMnB,IAAI,OAAAmB,iBAAA,CAClBb,YAAY;QAAA,IAACW,IAAIA,CAAA;UAAA,OAAEN,GAAG,CAACM,IAAI;QAAA;QAAA,IAAAM,SAAA;UAAA,QAAAJ,iBAAA,CACzBhB,aAAa,EAAAiB,YAAA,OACRlB,qBAAqB,CAACO,KAAK,EAAE,CAAC,CAAC,CAAC;YACpCM,UAAU,EAAEA;UAAU,KAAAI,iBAAA,CAEvBZ,WAAW;YAACiB,MAAM;YAAA,IAAAD,SAAA;cAAA,QAAAJ,iBAAA,CAChBlB,IAAI;gBAAA,IAACwB,IAAIA,CAAA;kBAAA,OAAEC,OAAO,CAACjB,KAAK,CAACkB,GAAG,CAAC;gBAAA;gBAAA,IAAAJ,SAAA;kBAAA,OAAGd,KAAK,CAACkB,GAAG;gBAAA;cAAA,IAAAR,iBAAA,CACzCD,WAAW,CAACU,SAAS;gBAAAL,QAAA;cAAA,IAAAJ,iBAAA,CACrBD,WAAW;gBAAA,IAAAK,SAAA;kBAAA,OAAEd,KAAK,CAACc,QAAQ;gBAAA;cAAA;YAAA;UAAA;QAAA;MAAA;IAAA;EAAA;AAMxC","ignoreList":[]}
@@ -16,7 +16,7 @@ export interface FutureStatementProps {
16
16
  *
17
17
  * @example
18
18
  * ```tsx
19
- * <SourceFile path="models.py" futureImports={<FutureStatement feature="annotations" />}>
19
+ * <SourceFile path="models.py" futureImports={[<FutureStatement feature="annotations" />]}>
20
20
  * <ClassDeclaration name="User">
21
21
  * <PropertyDeclaration name="manager" type="User" />
22
22
  * </ClassDeclaration>
@@ -10,7 +10,7 @@ import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
10
10
  *
11
11
  * @example
12
12
  * ```tsx
13
- * <SourceFile path="models.py" futureImports={<FutureStatement feature="annotations" />}>
13
+ * <SourceFile path="models.py" futureImports={[<FutureStatement feature="annotations" />]}>
14
14
  * <ClassDeclaration name="User">
15
15
  * <PropertyDeclaration name="manager" type="User" />
16
16
  * </ClassDeclaration>
@@ -1 +1 @@
1
- {"version":3,"file":"MethodBase.d.ts","sourceRoot":"","sources":["../../../src/components/MethodBase.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,4BAA4B,EAC5B,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,MAAM,WAAW,0BAA2B,SAAQ,mBAAmB;IACrE,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,0BAA0B,GAC/B,IAAI,CAAC,4BAA4B,EAAE,cAAc,GAAG,KAAK,CAAC,iDAgB7D"}
1
+ {"version":3,"file":"MethodBase.d.ts","sourceRoot":"","sources":["../../../src/components/MethodBase.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,4BAA4B,EAC5B,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,MAAM,WAAW,0BAA2B,SAAQ,mBAAmB;IACrE,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,0BAA0B,GAC/B,IAAI,CAAC,4BAA4B,EAAE,cAAc,GAAG,KAAK,CAAC,iDAmB7D"}
@@ -1,5 +1,6 @@
1
1
  import { memo as _$memo, createIntrinsic as _$createIntrinsic, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
2
  import { abcModule } from "../builtins/python.js";
3
+ import { DecoratorList } from "./DecoratorList.js";
3
4
  import { BaseFunctionDeclaration } from "./FunctionBase.js";
4
5
 
5
6
  /**
@@ -26,7 +27,14 @@ import { BaseFunctionDeclaration } from "./FunctionBase.js";
26
27
  * ```
27
28
  */
28
29
  export function MethodDeclarationBase(props) {
29
- const abstractMethod = props.abstract ? ["@", _$memo(() => abcModule["."].abstractmethod), _$createIntrinsic("hbr", {})] : undefined;
30
- return [abstractMethod, _$createComponent(BaseFunctionDeclaration, props)];
30
+ const {
31
+ decorators,
32
+ abstract,
33
+ ...rest
34
+ } = props;
35
+ const abstractMethod = abstract ? ["@", _$memo(() => abcModule["."].abstractmethod), _$createIntrinsic("hbr", {})] : undefined;
36
+ return [_$createComponent(DecoratorList, {
37
+ decorators: decorators
38
+ }), abstractMethod, _$createComponent(BaseFunctionDeclaration, rest)];
31
39
  }
32
40
  //# sourceMappingURL=MethodBase.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["abcModule","BaseFunctionDeclaration","MethodDeclarationBase","props","abstractMethod","abstract","_$memo","abstractmethod","_$createIntrinsic","undefined","_$createComponent"],"sources":["../../../src/components/MethodBase.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,SAAS,QAAQ,uBAAuB;AACjD,SACEC,uBAAuB,QAGlB,mBAAmB;;AAE1B;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CACnCC,KAC4D,EAC5D;EACA,MAAMC,cAAc,GAClBD,KAAK,CAACE,QAAQ,SAAAC,MAAA,OAERN,SAAS,CAAC,GAAG,CAAC,CAACO,cAAc,GAAAC,iBAAA,eAGjCC,SAAS;EAEb,QAEKL,cAAc,EAAAM,iBAAA,CACdT,uBAAuB,EAAKE,KAAK;AAGxC","ignoreList":[]}
1
+ {"version":3,"names":["abcModule","DecoratorList","BaseFunctionDeclaration","MethodDeclarationBase","props","decorators","abstract","rest","abstractMethod","_$memo","abstractmethod","_$createIntrinsic","undefined","_$createComponent"],"sources":["../../../src/components/MethodBase.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,SAAS,QAAQ,uBAAuB;AACjD,SAASC,aAAa;AACtB,SACEC,uBAAuB,QAGlB,mBAAmB;;AAE1B;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CACnCC,KAC4D,EAC5D;EACA,MAAM;IAAEC,UAAU;IAAEC,QAAQ;IAAE,GAAGC;EAAK,CAAC,GAAGH,KAAK;EAE/C,MAAMI,cAAc,GAClBF,QAAQ,SAAAG,MAAA,OAEFT,SAAS,CAAC,GAAG,CAAC,CAACU,cAAc,GAAAC,iBAAA,eAGjCC,SAAS;EAEb,QAAAC,iBAAA,CAEKZ,aAAa;IAACI,UAAU,EAAEA;EAAU,IACpCG,cAAc,EAAAK,iBAAA,CACdX,uBAAuB,EAAKK,IAAI;AAGvC","ignoreList":[]}
@@ -47,6 +47,29 @@ import { CommonFunctionProps } from "./FunctionBase.js";
47
47
  * The property must be declared within a class. The getter method is
48
48
  * automatically generated using the `@property` decorator. Use the nested
49
49
  * `Setter` and `Deleter` components to add mutators.
50
+ *
51
+ * Use **`decorators`** for decorators that must appear **above** the intrinsic
52
+ * `@property` (for example Pydantic `@computed_field`, `@typing.final`,
53
+ * `@typing.override`). The first array entry is rendered topmost, matching
54
+ * Python source order.
55
+ *
56
+ * @example Pydantic computed field
57
+ * ```tsx
58
+ * <py.PropertyDeclaration
59
+ * name="area"
60
+ * type="float"
61
+ * decorators={[code`@${pydanticModule["."].computed_field}`]}
62
+ * >
63
+ * return self.width ** 2
64
+ * </py.PropertyDeclaration>
65
+ * ```
66
+ * Generates:
67
+ * ```python
68
+ * @computed_field
69
+ * @property
70
+ * def area(self) -> float:
71
+ * return self.width ** 2
72
+ * ```
50
73
  */
51
74
  export interface PropertyDeclarationProps {
52
75
  name: string;
@@ -55,6 +78,12 @@ export interface PropertyDeclarationProps {
55
78
  refkey?: Refkey;
56
79
  abstract?: boolean;
57
80
  doc?: Children;
81
+ /**
82
+ * Decorators rendered above the intrinsic `@property` line, in source order
83
+ * (`decorators[0]` is topmost / applied last). Use for decorators that wrap
84
+ * the resulting property, e.g. Pydantic's `@computed_field`.
85
+ */
86
+ decorators?: Children[];
58
87
  }
59
88
  export declare function PropertyDeclaration(props: PropertyDeclarationProps): Children;
60
89
  export declare namespace PropertyDeclaration {
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/PropertyDeclaration.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAGR,MAAM,EASP,MAAM,gBAAgB,CAAC;AAKxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AASxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,GAAG,CAAC,EAAE,QAAQ,CAAC;CAChB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,YA+DlE;yBA/De,mBAAmB;;eA6IkB,QAAQ;;eAAR,QAAQ;;;;AA5E7D,MAAM,WAAW,8BACf,SAAQ,IAAI,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACzC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
1
+ {"version":3,"file":"PropertyDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/PropertyDeclaration.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAGR,MAAM,EASP,MAAM,gBAAgB,CAAC;AAMxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AASxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AACH,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf;;;;OAIG;IACH,UAAU,CAAC,EAAE,QAAQ,EAAE,CAAC;CACzB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,YAgElE;yBAhEe,mBAAmB;;eAuJkB,QAAQ;;eAAR,QAAQ;;;;AArF7D,MAAM,WAAW,8BACf,SAAQ,IAAI,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACzC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
@@ -2,6 +2,7 @@ import { createComponent as _$createComponent, memo as _$memo, mergeProps as _$m
2
2
  import { DeclarationContext, List, Show, childrenArray, code, createContext, findKeyedChild, findUnkeyedChildren, taggedComponent, useContext } from "@alloy-js/core";
3
3
  import { createMethodSymbol } from "../symbols/factories.js";
4
4
  import { Atom } from "./Atom.js";
5
+ import { DecoratorList } from "./DecoratorList.js";
5
6
  import { MethodDeclarationBase } from "./MethodBase.js";
6
7
  const setterTag = Symbol();
7
8
  const deleterTag = Symbol();
@@ -56,6 +57,29 @@ const PropertyContext = createContext();
56
57
  * The property must be declared within a class. The getter method is
57
58
  * automatically generated using the `@property` decorator. Use the nested
58
59
  * `Setter` and `Deleter` components to add mutators.
60
+ *
61
+ * Use **`decorators`** for decorators that must appear **above** the intrinsic
62
+ * `@property` (for example Pydantic `@computed_field`, `@typing.final`,
63
+ * `@typing.override`). The first array entry is rendered topmost, matching
64
+ * Python source order.
65
+ *
66
+ * @example Pydantic computed field
67
+ * ```tsx
68
+ * <py.PropertyDeclaration
69
+ * name="area"
70
+ * type="float"
71
+ * decorators={[code`@${pydanticModule["."].computed_field}`]}
72
+ * >
73
+ * return self.width ** 2
74
+ * </py.PropertyDeclaration>
75
+ * ```
76
+ * Generates:
77
+ * ```python
78
+ * @computed_field
79
+ * @property
80
+ * def area(self) -> float:
81
+ * return self.width ** 2
82
+ * ```
59
83
  */
60
84
 
61
85
  export function PropertyDeclaration(props) {
@@ -94,6 +118,9 @@ export function PropertyDeclaration(props) {
94
118
  get doc() {
95
119
  return props.doc;
96
120
  },
121
+ get decorators() {
122
+ return props.decorators;
123
+ },
97
124
  children: unkeyedChildren
98
125
  }), _$createComponent(Show, {
99
126
  get when() {
@@ -133,7 +160,13 @@ export function PropertyDeclaration(props) {
133
160
  function PropertyMethodDeclaration(props) {
134
161
  const propertySymbol = useContext(DeclarationContext);
135
162
  const propertyType = useContext(PropertyContext);
136
- return [code`@property`, _$createIntrinsic("hbr", {}), _$createComponent(MethodDeclarationBase, _$mergeProps(props, {
163
+ const {
164
+ decorators,
165
+ ...rest
166
+ } = props;
167
+ return [_$createComponent(DecoratorList, {
168
+ decorators: decorators
169
+ }), code`@property`, _$createIntrinsic("hbr", {}), _$createComponent(MethodDeclarationBase, _$mergeProps(rest, {
137
170
  get name() {
138
171
  return propertySymbol.name;
139
172
  },
@@ -187,6 +220,13 @@ function PropertyMethodBase(props) {
187
220
  * def value(self, value: int) -> None:
188
221
  * self._value = value
189
222
  * ```
223
+ *
224
+ * @remarks
225
+ * The intrinsic `@<name>.setter` decorator is always rendered topmost (it must
226
+ * remain the outermost decorator). Any `decorators` passed to this component
227
+ * are rendered **between** `@<name>.setter` and `def`, which is the correct
228
+ * position for wrappers that should decorate the underlying function before
229
+ * `setter` re-binds it to the property (e.g. `@deprecated`, `@abstractmethod`).
190
230
  */
191
231
  PropertyDeclaration.Setter = taggedComponent(setterTag, function PropertySetter(props) {
192
232
  return _$createComponent(PropertyMethodBase, _$mergeProps({
@@ -218,6 +258,13 @@ PropertyDeclaration.Setter = taggedComponent(setterTag, function PropertySetter(
218
258
  * def value(self) -> None:
219
259
  * del self._value
220
260
  * ```
261
+ *
262
+ * @remarks
263
+ * The intrinsic `@<name>.deleter` decorator is always rendered topmost (it
264
+ * must remain the outermost decorator). Any `decorators` passed to this
265
+ * component are rendered **between** `@<name>.deleter` and `def`, which is
266
+ * the correct position for wrappers that should decorate the underlying
267
+ * function before `deleter` re-binds it to the property.
221
268
  */
222
269
  PropertyDeclaration.Deleter = taggedComponent(deleterTag, function PropertyDeleter(props) {
223
270
  return _$createComponent(PropertyMethodBase, _$mergeProps({
@@ -1 +1 @@
1
- {"version":3,"names":["DeclarationContext","List","Show","childrenArray","code","createContext","findKeyedChild","findUnkeyedChildren","taggedComponent","useContext","createMethodSymbol","Atom","MethodDeclarationBase","setterTag","Symbol","deleterTag","PropertyContext","PropertyDeclaration","props","nonEmptyOrNotImplemented","children","length","setterComponent","Setter","tag","undefined","deleterComponent","Deleter","setterChildren","deleterChildren","unkeyedChildren","sym","name","refkeys","refkey","_$createComponent","Provider","value","type","hardline","enderPunctuation","PropertyMethodDeclaration","abstract","doc","when","Boolean","_$mergeProps","propertySymbol","propertyType","_$createIntrinsic","functionType","returnType","PropertyMethodBase","decoratorType","parameters","restProps","_$memo","jsValue","PropertySetter","PropertyDeleter"],"sources":["../../../src/components/PropertyDeclaration.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAEEA,kBAAkB,EAClBC,IAAI,EAEJC,IAAI,EACJC,aAAa,EACbC,IAAI,EACJC,aAAa,EACbC,cAAc,EACdC,mBAAmB,EACnBC,eAAe,EACfC,UAAU,QACL,gBAAgB;AAGvB,SAASC,kBAAkB,QAAQ,yBAAyB;AAC5D,SAASC,IAAI;AAEb,SAASC,qBAAqB,QAAQ,iBAAiB;AAEvD,MAAMC,SAAS,GAAGC,MAAM,CAAC,C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,OAAO,EAAE;MAAI;IAAA;IAC/B1B,GAAG,EAAEgB,cAAc;IAAA3B,QAAA,EAElBA;EAAQ;AAIjB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAH,mBAAmB,CAACM,MAAM,GAAGf,eAAe,CAC1CK,SAAS,EACT,SAAS6C,cAAcA,CACrBxC,KAA2D,EAC3D;EACA,OAAAiB,iBAAA,CACGiB,kBAAkB,EAAAN,YAAA;IACjBO,aAAa;IAAA,IACbC,UAAUA,CAAA;MAAA,OAAE,CAAC;QAAEtB,IAAI,EAAE,OAAO;QAAEM,IAAI,EAAEpB,KAAK,CAACoB;MAAK,CAAC,CAAC;IAAA;EAAA,GAC7CpB,KAAK;AAGf,CACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAD,mBAAmB,CAACU,OAAO,GAAGnB,eAAe,CAC3CO,UAAU,EACV,SAAS4C,eAAeA,CACtBzC,KAAyD,EACzD;EACA,OAAAiB,iBAAA,CAAQiB,kBAAkB,EAAAN,YAAA;IAACO,aAAa;EAAA,GAAenC,KAAK;AAC9D,CACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["DeclarationContext","List","Show","childrenArray","code","createContext","findKeyedChild","findUnkeyedChildren","taggedComponent","useContext","createMethodSymbol","Atom","DecoratorList","MethodDeclarationBase","setterTag","Symbol","deleterTag","PropertyContext","PropertyDeclaration","props","nonEmptyOrNotImplemented","children","length","setterComponent","Setter","tag","undefined","deleterComponent","Deleter","setterChildren","deleterChildren","unkeyedChildren","sym","name","refkeys","refkey","_$createComponent","Provider","value","type","hardline","enderPunctuation","PropertyMethodDeclaration","abstract","doc","decorators","when","Boolean","_$mergeProps","propertySymbol","propertyType","rest","_$createIntrinsic","functionType","returnType","PropertyMethodBase","decoratorType","parameters","restProps","_$memo","jsValue","PropertySetter","PropertyDeleter"],"sources":["../../../src/components/PropertyDeclaration.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAEEA,kBAAkB,EAClBC,IAAI,EAEJC,IAAI,EACJC,aAAa,EACbC,IAAI,EACJC,aAAa,EACbC,cAAc,EACdC,mBAAmB,EACnBC,eAAe,EACfC,UAAU,QACL,gBAAgB;AAGvB,SAASC,kBAAkB,QAAQ,yBAAyB;AAC5D,SAASC,IAAI;AACb,SAASC,aAAa;AAEtB,SAASC,qBAAqB,QAAQ,iBAAiB;AAEvD,MAAMC,SAAS,GAAGC,MAAM,CAAC,CAAC;AAC1B,MAAMC,UAAU,GAAGD,MAAM,CAAC,CAAC;;AAE3B;AACA,MAAME,eAAe,GAAGZ,aAAa,CAAuB,CAAC;;AAE7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBA,OAAO,SAASa,mBAAmBA,CAACC,KAA+B,EAAE;EACnE,MAAMC,wBAAwB,GAC5BC,QAA8B,IACjB;IACb,IAAIA,QAAQ,IAAIlB,aAAa,CAAC,MAAMkB,QAAQ,CAAC,CAACC,MAAM,GAAG,CAAC,EAAE;MACxD,OAAOD,QAAQ;IACjB,CAAC,MAAM;MACL,OAAO,CAACjB,IAAI,2BAA2B,CAAC;IAC1C;EACF,CAAC;EAED,MAAMiB,QAAQ,GAAGlB,aAAa,CAAC,MAAMgB,KAAK,CAACE,QAAQ,CAAC;EACpD,MAAME,eAAe,GACnBjB,cAAc,CAACe,QAAQ,EAA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f,CACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAD,mBAAmB,CAACU,OAAO,GAAGpB,eAAe,CAC3CQ,UAAU,EACV,SAAS8C,eAAeA,CACtB3C,KAAyD,EACzD;EACA,OAAAiB,iBAAA,CAAQmB,kBAAkB,EAAAP,YAAA;IAACQ,aAAa;EAAA,GAAerC,KAAK;AAC9D,CACF,CAAC","ignoreList":[]}
@@ -0,0 +1,120 @@
1
+ import { type Children } from "@alloy-js/core";
2
+ import type { ClassDeclarationProps } from "./ClassDeclaration.js";
3
+ /**
4
+ * Keyword-style options for Pydantic v2 `ConfigDict`, using camelCase prop names
5
+ * that map to snake_case Python arguments (for example `validateAssignment` →
6
+ * `validate_assignment`).
7
+ */
8
+ export interface PydanticModelConfigDictProps {
9
+ /** Resolve field aliases from a configured alias generator. */
10
+ aliasGenerator?: string;
11
+ /** Allow non-pydantic/arbitrary Python types in field annotations. */
12
+ arbitraryTypesAllowed?: boolean;
13
+ /** Coerce numeric input values to strings for `str` fields. */
14
+ coerceNumbersToStr?: boolean;
15
+ /** Behavior for unknown input keys: allow, forbid, or ignore. */
16
+ extra?: "allow" | "forbid" | "ignore";
17
+ /** Populate models from object attributes (ORM-style) instead of mapping keys. */
18
+ fromAttributes?: boolean;
19
+ /** Make models immutable (`frozen=True`). */
20
+ frozen?: boolean;
21
+ /** Hide input values in validation error messages. */
22
+ hideInputInErrors?: boolean;
23
+ /** Include JSON schema extras via a plain JSON-serializable object. */
24
+ jsonSchemaExtra?: Record<string, unknown>;
25
+ /** Use aliases in error locations instead of field names. */
26
+ locByAlias?: boolean;
27
+ /** Allow population by field name even when aliases are defined. */
28
+ populateByName?: boolean;
29
+ /** Re-validate model/dataclass instances on assignment boundaries. */
30
+ revalidateInstances?: "always" | "never" | "subclass-instances";
31
+ /** JSON serialization format for bytes values. */
32
+ serJsonBytes?: "utf8" | "base64" | "hex";
33
+ /** JSON serialization behavior for Infinity/NaN values. */
34
+ serJsonInfNan?: "null" | "constants" | "strings";
35
+ /** Upper-bound for constrained string lengths at model level. */
36
+ strMaxLength?: number;
37
+ /** Lower-bound for constrained string lengths at model level. */
38
+ strMinLength?: number;
39
+ /** Strip leading/trailing whitespace from all `str` fields. */
40
+ strStripWhitespace?: boolean;
41
+ /** Convert all `str` values to lowercase. */
42
+ strToLower?: boolean;
43
+ /** Convert all `str` values to uppercase. */
44
+ strToUpper?: boolean;
45
+ /** Enable strict validation globally for the model. */
46
+ strict?: boolean;
47
+ /** Use enum `.value` instead of enum instances during serialization. */
48
+ useEnumValues?: boolean;
49
+ /** JSON validation format for bytes values. */
50
+ valJsonBytes?: "utf8" | "base64" | "hex";
51
+ /** Re-validate when attributes are assigned after model creation. */
52
+ validateAssignment?: boolean;
53
+ /** Validate default values in addition to provided input values. */
54
+ validateDefault?: boolean;
55
+ /** Validate return values for call validators. */
56
+ validateReturn?: boolean;
57
+ }
58
+ export interface PydanticClassDeclarationProps extends ClassDeclarationProps, PydanticModelConfigDictProps {
59
+ /**
60
+ * Canonical structured config object for `ConfigDict(...)`. Values here are
61
+ * merged with top-level config props.
62
+ *
63
+ * Top-level config props take precedence over `modelConfig` when the same key
64
+ * is provided in both places.
65
+ */
66
+ modelConfig?: PydanticModelConfigDictProps;
67
+ /**
68
+ * Emits `model_config = <expression>` verbatim (use for arbitrary `ConfigDict`
69
+ * kwargs or dynamic config). Takes precedence over both `modelConfig` and
70
+ * top-level config props.
71
+ *
72
+ * @example
73
+ * A typical value emits `ConfigDict(frozen=True, extra="forbid")`.
74
+ */
75
+ modelConfigExpression?: Children;
76
+ }
77
+ /**
78
+ * Renders a Python class that subclasses Pydantic's `BaseModel`:
79
+ * `class Name(BaseModel): ...`.
80
+ *
81
+ * When `bases` is omitted, the class extends `pydanticModule["."].BaseModel`.
82
+ * Pass `bases` to inherit from another generated class (or to combine bases explicitly).
83
+ *
84
+ * Optional `modelConfig={{...}}` and top-level config props (for example
85
+ * `frozen`, `strict`, `extra`) emit `model_config = ConfigDict(...)` for common
86
+ * Pydantic v2 model settings (see {@link PydanticModelConfigDictProps}).
87
+ * When both are used, top-level props override `modelConfig` keys.
88
+ *
89
+ * Fields are ordinary class body declarations; use `pydanticModule["."].Field` in
90
+ * initializers when you need `Field(...)`.
91
+ *
92
+ * @example
93
+ * ```tsx
94
+ * import { pydanticModule } from "@alloy-js/python";
95
+ * import * as py from "@alloy-js/python";
96
+ *
97
+ * <py.PydanticClassDeclaration name="User" frozen>
98
+ * <py.VariableDeclaration instanceVariable omitNone name="id" type="int" />
99
+ * <py.VariableDeclaration
100
+ * instanceVariable
101
+ * name="name"
102
+ * type="str"
103
+ * initializer={"Field(default=\"anonymous\")"}
104
+ * />
105
+ * </py.PydanticClassDeclaration>
106
+ * ```
107
+ *
108
+ * ```py
109
+ * from pydantic import BaseModel
110
+ * from pydantic import ConfigDict
111
+ * from pydantic import Field
112
+ *
113
+ * class User(BaseModel):
114
+ * model_config = ConfigDict(frozen=True)
115
+ * id: int
116
+ * name: str = Field(default="anonymous")
117
+ * ```
118
+ */
119
+ export declare function PydanticClassDeclaration(props: PydanticClassDeclarationProps): Children;
120
+ //# sourceMappingURL=PydanticClassDeclaration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PydanticClassDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/PydanticClassDeclaration.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,QAAQ,EACd,MAAM,gBAAgB,CAAC;AAIxB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAGnE;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAC3C,+DAA+D;IAC/D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sEAAsE;IACtE,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,+DAA+D;IAC/D,kBAAkB,CAAC,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,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AA6BD,MAAM,WAAW,6BACf,SAAQ,qBAAqB,EAC3B,4BAA4B;IAC9B;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,4BAA4B,CAAC;IAC3C;;;;;;;OAOG;IACH,qBAAqB,CAAC,EAAE,QAAQ,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,6BAA6B,YA6D5E"}
@@ -0,0 +1,116 @@
1
+ import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { For, List, childrenArray, splitProps } from "@alloy-js/core";
3
+ import { snakeCase } from "change-case";
4
+ import { pydanticModule } from "../builtins/python.js";
5
+ import { Atom } from "./Atom.js";
6
+ import { ClassDeclaration } from "./ClassDeclaration.js";
7
+
8
+ /**
9
+ * Keyword-style options for Pydantic v2 `ConfigDict`, using camelCase prop names
10
+ * that map to snake_case Python arguments (for example `validateAssignment` →
11
+ * `validate_assignment`).
12
+ */
13
+
14
+ const PydanticModelConfigKeys = ["aliasGenerator", "arbitraryTypesAllowed", "coerceNumbersToStr", "frozen", "extra", "fromAttributes", "hideInputInErrors", "jsonSchemaExtra", "locByAlias", "populateByName", "revalidateInstances", "serJsonBytes", "serJsonInfNan", "strMinLength", "strMaxLength", "strStripWhitespace", "strToLower", "strToUpper", "strict", "useEnumValues", "valJsonBytes", "validateAssignment", "validateDefault", "validateReturn"];
15
+ /**
16
+ * Renders a Python class that subclasses Pydantic's `BaseModel`:
17
+ * `class Name(BaseModel): ...`.
18
+ *
19
+ * When `bases` is omitted, the class extends `pydanticModule["."].BaseModel`.
20
+ * Pass `bases` to inherit from another generated class (or to combine bases explicitly).
21
+ *
22
+ * Optional `modelConfig={{...}}` and top-level config props (for example
23
+ * `frozen`, `strict`, `extra`) emit `model_config = ConfigDict(...)` for common
24
+ * Pydantic v2 model settings (see {@link PydanticModelConfigDictProps}).
25
+ * When both are used, top-level props override `modelConfig` keys.
26
+ *
27
+ * Fields are ordinary class body declarations; use `pydanticModule["."].Field` in
28
+ * initializers when you need `Field(...)`.
29
+ *
30
+ * @example
31
+ * ```tsx
32
+ * import { pydanticModule } from "@alloy-js/python";
33
+ * import * as py from "@alloy-js/python";
34
+ *
35
+ * <py.PydanticClassDeclaration name="User" frozen>
36
+ * <py.VariableDeclaration instanceVariable omitNone name="id" type="int" />
37
+ * <py.VariableDeclaration
38
+ * instanceVariable
39
+ * name="name"
40
+ * type="str"
41
+ * initializer={"Field(default=\"anonymous\")"}
42
+ * />
43
+ * </py.PydanticClassDeclaration>
44
+ * ```
45
+ *
46
+ * ```py
47
+ * from pydantic import BaseModel
48
+ * from pydantic import ConfigDict
49
+ * from pydantic import Field
50
+ *
51
+ * class User(BaseModel):
52
+ * model_config = ConfigDict(frozen=True)
53
+ * id: int
54
+ * name: str = Field(default="anonymous")
55
+ * ```
56
+ */
57
+ export function PydanticClassDeclaration(props) {
58
+ const [modelConfigProps, bodyProps, rest] = splitProps(props, PydanticModelConfigKeys, ["modelConfig", "modelConfigExpression", "children"]);
59
+ const bases = rest.bases ?? [pydanticModule["."].BaseModel];
60
+ const {
61
+ modelConfig,
62
+ modelConfigExpression,
63
+ children
64
+ } = bodyProps;
65
+ const configEntries = [];
66
+ if (modelConfigExpression === undefined) {
67
+ for (const key of PydanticModelConfigKeys) {
68
+ const value = modelConfigProps[key] ?? modelConfig?.[key];
69
+ if (value === undefined) continue;
70
+ configEntries.push([snakeCase(key), value]);
71
+ }
72
+ }
73
+ const hasStructuredModelConfig = modelConfigExpression === undefined && configEntries.length > 0;
74
+ const hasExpressionModelConfig = modelConfigExpression !== undefined;
75
+ const bodyItems = [];
76
+ if (hasExpressionModelConfig) {
77
+ bodyItems.push(["model_config = ", modelConfigExpression]);
78
+ } else if (hasStructuredModelConfig) {
79
+ bodyItems.push(["model_config = ", _$memo(() => pydanticModule["."].ConfigDict), "(", _$createComponent(For, {
80
+ each: configEntries,
81
+ comma: true,
82
+ space: true,
83
+ children: ([k, v]) => [k, "=", _$createComponent(Atom, {
84
+ jsValue: v
85
+ })]
86
+ }), ")"]);
87
+ }
88
+ bodyItems.push(...childrenArray(() => children));
89
+ return _$createComponent(ClassDeclaration, {
90
+ get name() {
91
+ return rest.name;
92
+ },
93
+ bases: bases,
94
+ get doc() {
95
+ return rest.doc;
96
+ },
97
+ get refkey() {
98
+ return rest.refkey;
99
+ },
100
+ get decorators() {
101
+ return rest.decorators;
102
+ },
103
+ get children() {
104
+ return _$createComponent(List, {
105
+ hardline: true,
106
+ get children() {
107
+ return _$createComponent(For, {
108
+ each: bodyItems,
109
+ children: item => item
110
+ });
111
+ }
112
+ });
113
+ }
114
+ });
115
+ }
116
+ //# sourceMappingURL=PydanticClassDeclaration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["For","List","childrenArray","splitProps","snakeCase","pydanticModule","Atom","ClassDeclaration","PydanticModelConfigKeys","PydanticClassDeclaration","props","modelConfigProps","bodyProps","rest","bases","BaseModel","modelConfig","modelConfigExpression","children","configEntries","undefined","key","value","push","hasStructuredModelConfig","length","hasExpressionModelConfig","bodyItems","_$memo","ConfigDict","_$createComponent","each","comma","space","k","v","jsValue","name","doc","refkey","decorators","hardline","item"],"sources":["../../../src/components/PydanticClassDeclaration.tsx"],"sourcesContent":[null],"mappings":";AAAA,SACEA,GAAG,EACHC,IAAI,EACJC,aAAa,EACbC,UAAU,QAEL,gBAAgB;AACvB,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,cAAc,QAAQ,uBAAuB;AACtD,SAASC,IAAI;AAEb,SAASC,gBAAgB,QAAQ,uBAAuB;;AAExD;AACA;AACA;AACA;AACA;;AAoDA,MAAMC,uBAAuB,GAAG,CAC9B,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,QAAQ,EACR,OAAO,EACP,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,Y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Props } from "./FunctionBase.js";
14
14
  * def identity(value: int) -> None:
15
15
  * return value
16
16
  * ```
17
+ *
18
+ * @remarks
19
+ * Use **`decorators`** for decorators that must appear above `@staticmethod`.
17
20
  */
18
21
  export interface StaticMethodDeclarationProps extends CommonFunctionProps {
19
22
  abstract?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"StaticMethodDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/StaticMethodDeclaration.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAG7D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,4BAA6B,SAAQ,mBAAmB;IACvE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,4BAA4B,iDAS1E"}
1
+ {"version":3,"file":"StaticMethodDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/StaticMethodDeclaration.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAG7D;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,4BAA6B,SAAQ,mBAAmB;IACvE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,4BAA4B,iDAW1E"}
@@ -1,5 +1,6 @@
1
- import { createIntrinsic as _$createIntrinsic, mergeProps as _$mergeProps, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
1
+ import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
2
2
  import { createMethodSymbol } from "../symbols/factories.js";
3
+ import { DecoratorList } from "./DecoratorList.js";
3
4
  import { MethodDeclarationBase } from "./MethodBase.js";
4
5
 
5
6
  /**
@@ -17,15 +18,24 @@ import { MethodDeclarationBase } from "./MethodBase.js";
17
18
  * def identity(value: int) -> None:
18
19
  * return value
19
20
  * ```
21
+ *
22
+ * @remarks
23
+ * Use **`decorators`** for decorators that must appear above `@staticmethod`.
20
24
  */
21
25
 
22
26
  export function StaticMethodDeclaration(props) {
23
27
  const sym = createMethodSymbol(props.name, {
24
28
  refkeys: props.refkey
25
29
  });
26
- return ["@staticmethod", _$createIntrinsic("hbr", {}), _$createComponent(MethodDeclarationBase, _$mergeProps({
30
+ const {
31
+ decorators,
32
+ ...rest
33
+ } = props;
34
+ return [_$createComponent(DecoratorList, {
35
+ decorators: decorators
36
+ }), "@staticmethod", _$createIntrinsic("hbr", {}), _$createComponent(MethodDeclarationBase, _$mergeProps({
27
37
  functionType: "static"
28
- }, props, {
38
+ }, rest, {
29
39
  sym: sym
30
40
  }))];
31
41
  }