@alloy-js/python 0.5.0-dev.0 → 0.5.0-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/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/SourceFile.js +44 -32
- package/dist/dev/src/components/SourceFile.js.map +1 -1
- 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/callsignatures.test.js +471 -297
- package/dist/dev/test/callsignatures.test.js.map +1 -1
- package/dist/dev/test/class-method-declaration.test.js +21 -10
- package/dist/dev/test/class-method-declaration.test.js.map +1 -1
- package/dist/dev/test/classdeclarations.test.js +480 -381
- package/dist/dev/test/classdeclarations.test.js.map +1 -1
- package/dist/dev/test/classinstantiations.test.js +201 -168
- package/dist/dev/test/classinstantiations.test.js.map +1 -1
- package/dist/dev/test/constructordeclaration.test.js +22 -11
- package/dist/dev/test/constructordeclaration.test.js.map +1 -1
- package/dist/dev/test/dataclassdeclarations.test.js +345 -358
- package/dist/dev/test/dataclassdeclarations.test.js.map +1 -1
- package/dist/dev/test/decoratorlist.test.js +131 -0
- package/dist/dev/test/decoratorlist.test.js.map +1 -0
- package/dist/dev/test/dundermethoddeclaration.test.js +22 -11
- package/dist/dev/test/dundermethoddeclaration.test.js.map +1 -1
- package/dist/dev/test/enums.test.js +231 -166
- package/dist/dev/test/enums.test.js.map +1 -1
- package/dist/dev/test/externals.test.js +57 -45
- package/dist/dev/test/externals.test.js.map +1 -1
- package/dist/dev/test/factories.test.js +124 -50
- package/dist/dev/test/factories.test.js.map +1 -1
- package/dist/dev/test/functioncallexpressions.test.js +199 -164
- package/dist/dev/test/functioncallexpressions.test.js.map +1 -1
- package/dist/dev/test/functiondeclaration.test.js +452 -265
- package/dist/dev/test/functiondeclaration.test.js.map +1 -1
- package/dist/dev/test/imports.test.js +273 -221
- package/dist/dev/test/imports.test.js.map +1 -1
- package/dist/dev/test/memberexpressions.test.js +1237 -972
- package/dist/dev/test/memberexpressions.test.js.map +1 -1
- package/dist/dev/test/methoddeclaration.test.js +200 -45
- package/dist/dev/test/methoddeclaration.test.js.map +1 -1
- package/dist/dev/test/namepolicies.test.js +130 -94
- package/dist/dev/test/namepolicies.test.js.map +1 -1
- package/dist/dev/test/propertydeclaration.test.js +177 -46
- package/dist/dev/test/propertydeclaration.test.js.map +1 -1
- package/dist/dev/test/pydanticclassdeclarations.test.js +1089 -0
- package/dist/dev/test/pydanticclassdeclarations.test.js.map +1 -0
- package/dist/dev/test/pydocs.test.js +888 -715
- package/dist/dev/test/pydocs.test.js.map +1 -1
- package/dist/dev/test/references.test.js +42 -35
- package/dist/dev/test/references.test.js.map +1 -1
- package/dist/dev/test/sourcefiles.test.js +1109 -841
- package/dist/dev/test/sourcefiles.test.js.map +1 -1
- package/dist/dev/test/staticmethoddeclaration.test.js +21 -10
- package/dist/dev/test/staticmethoddeclaration.test.js.map +1 -1
- package/dist/dev/test/type-checking-imports.test.js +408 -359
- package/dist/dev/test/type-checking-imports.test.js.map +1 -1
- package/dist/dev/test/typereference.test.js +55 -40
- package/dist/dev/test/typereference.test.js.map +1 -1
- package/dist/dev/test/uniontypeexpression.test.js +222 -146
- package/dist/dev/test/uniontypeexpression.test.js.map +1 -1
- package/dist/dev/test/utils.js +39 -77
- package/dist/dev/test/utils.js.map +1 -1
- package/dist/dev/test/values.test.js +237 -101
- package/dist/dev/test/values.test.js.map +1 -1
- package/dist/dev/test/variables.test.js +321 -203
- package/dist/dev/test/variables.test.js.map +1 -1
- package/dist/dev/test/vitest.setup.js +2 -0
- package/dist/dev/test/vitest.setup.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/SourceFile.d.ts +2 -2
- package/dist/src/components/SourceFile.d.ts.map +1 -1
- package/dist/src/components/SourceFile.js +12 -0
- package/dist/src/components/SourceFile.js.map +1 -1
- 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/callsignatures.test.js +346 -272
- package/dist/test/callsignatures.test.js.map +1 -1
- package/dist/test/class-method-declaration.test.js +7 -4
- package/dist/test/class-method-declaration.test.js.map +1 -1
- package/dist/test/classdeclarations.test.js +316 -277
- package/dist/test/classdeclarations.test.js.map +1 -1
- package/dist/test/classinstantiations.test.js +112 -103
- package/dist/test/classinstantiations.test.js.map +1 -1
- package/dist/test/constructordeclaration.test.js +7 -4
- package/dist/test/constructordeclaration.test.js.map +1 -1
- package/dist/test/dataclassdeclarations.test.js +153 -178
- 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 +83 -0
- package/dist/test/decoratorlist.test.js.map +1 -0
- package/dist/test/dundermethoddeclaration.test.js +7 -4
- package/dist/test/dundermethoddeclaration.test.js.map +1 -1
- package/dist/test/enums.test.js +172 -143
- package/dist/test/enums.test.js.map +1 -1
- package/dist/test/externals.test.js +24 -24
- package/dist/test/externals.test.js.map +1 -1
- package/dist/test/factories.test.js +75 -33
- package/dist/test/factories.test.js.map +1 -1
- package/dist/test/functioncallexpressions.test.js +117 -106
- package/dist/test/functioncallexpressions.test.js.map +1 -1
- package/dist/test/functiondeclaration.test.js +256 -173
- package/dist/test/functiondeclaration.test.js.map +1 -1
- package/dist/test/imports.test.js +171 -143
- package/dist/test/imports.test.js.map +1 -1
- package/dist/test/memberexpressions.test.js +582 -453
- package/dist/test/memberexpressions.test.js.map +1 -1
- package/dist/test/methoddeclaration.test.js +106 -19
- package/dist/test/methoddeclaration.test.js.map +1 -1
- package/dist/test/namepolicies.test.js +90 -78
- package/dist/test/namepolicies.test.js.map +1 -1
- package/dist/test/propertydeclaration.test.js +90 -15
- 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 +773 -0
- package/dist/test/pydanticclassdeclarations.test.js.map +1 -0
- package/dist/test/pydocs.test.js +573 -532
- package/dist/test/pydocs.test.js.map +1 -1
- package/dist/test/references.test.js +31 -28
- package/dist/test/references.test.js.map +1 -1
- package/dist/test/sourcefiles.test.js +700 -580
- package/dist/test/sourcefiles.test.js.map +1 -1
- package/dist/test/staticmethoddeclaration.test.js +7 -4
- package/dist/test/staticmethoddeclaration.test.js.map +1 -1
- package/dist/test/type-checking-imports.test.js +297 -284
- package/dist/test/type-checking-imports.test.js.map +1 -1
- package/dist/test/typereference.test.js +29 -22
- package/dist/test/typereference.test.js.map +1 -1
- package/dist/test/uniontypeexpression.test.js +124 -88
- package/dist/test/uniontypeexpression.test.js.map +1 -1
- package/dist/test/utils.d.ts +10 -17
- package/dist/test/utils.d.ts.map +1 -1
- package/dist/test/utils.js +32 -74
- package/dist/test/utils.js.map +1 -1
- package/dist/test/values.test.js +135 -67
- package/dist/test/values.test.js.map +1 -1
- package/dist/test/variables.test.js +201 -151
- package/dist/test/variables.test.js.map +1 -1
- package/dist/test/vitest.setup.d.ts +2 -0
- package/dist/test/vitest.setup.d.ts.map +1 -0
- package/dist/test/vitest.setup.js +2 -0
- package/dist/test/vitest.setup.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/SourceFile.md +20 -8
- 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 +4 -4
- 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/SourceFile.tsx +6 -1
- package/src/components/StaticMethodDeclaration.tsx +7 -1
- package/src/components/index.ts +1 -0
- package/temp/api.json +1158 -86
- package/test/callsignatures.test.tsx +309 -283
- package/test/class-method-declaration.test.tsx +3 -4
- package/test/classdeclarations.test.tsx +277 -235
- package/test/classinstantiations.test.tsx +115 -109
- package/test/constructordeclaration.test.tsx +9 -6
- package/test/dataclassdeclarations.test.tsx +256 -349
- package/test/decoratorlist.test.tsx +114 -0
- package/test/dundermethoddeclaration.test.tsx +3 -4
- package/test/enums.test.tsx +84 -71
- package/test/externals.test.tsx +25 -25
- package/test/factories.test.tsx +64 -22
- package/test/functioncallexpressions.test.tsx +123 -109
- package/test/functiondeclaration.test.tsx +218 -140
- package/test/imports.test.tsx +119 -91
- package/test/memberexpressions.test.tsx +265 -207
- package/test/methoddeclaration.test.tsx +115 -24
- package/test/namepolicies.test.tsx +69 -69
- package/test/propertydeclaration.test.tsx +71 -7
- package/test/pydanticclassdeclarations.test.tsx +704 -0
- package/test/pydocs.test.tsx +531 -579
- package/test/references.test.tsx +24 -23
- package/test/sourcefiles.test.tsx +527 -492
- package/test/staticmethoddeclaration.test.tsx +3 -4
- package/test/type-checking-imports.test.tsx +206 -218
- package/test/typereference.test.tsx +15 -12
- package/test/uniontypeexpression.test.tsx +74 -61
- package/test/utils.tsx +26 -110
- package/test/values.test.tsx +82 -32
- package/test/variables.test.tsx +162 -142
- package/test/vitest.setup.ts +1 -0
- package/vitest.config.ts +3 -0
|
@@ -13,7 +13,11 @@ A Python source file component that represents a Python file in the source direc
|
|
|
13
13
|
futureImports={Children[]}
|
|
14
14
|
header={Children}
|
|
15
15
|
headerComment="string"
|
|
16
|
+
insertFinalNewLine
|
|
16
17
|
path="string"
|
|
18
|
+
printWidth={number}
|
|
19
|
+
tabWidth={number}
|
|
20
|
+
useTabs
|
|
17
21
|
>
|
|
18
22
|
{children}
|
|
19
23
|
</SourceFile>
|
|
@@ -30,20 +34,28 @@ A Python source file component that represents a Python file in the source direc
|
|
|
30
34
|
futureImports: Children[],
|
|
31
35
|
header: Children,
|
|
32
36
|
headerComment: string,
|
|
37
|
+
insertFinalNewLine: boolean,
|
|
33
38
|
path: string,
|
|
39
|
+
printWidth: number,
|
|
40
|
+
tabWidth: number,
|
|
41
|
+
useTabs: boolean,
|
|
34
42
|
}).children(children)
|
|
35
43
|
```
|
|
36
44
|
|
|
37
45
|
## Props
|
|
38
46
|
|
|
39
|
-
|
|
|
40
|
-
|
|
|
41
|
-
| children
|
|
42
|
-
| doc
|
|
43
|
-
| futureImports
|
|
44
|
-
| header
|
|
45
|
-
| headerComment
|
|
46
|
-
|
|
|
47
|
+
| | | |
|
|
48
|
+
| ------------------ | ----------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
49
|
+
| children | optional [Children](../../../core/types/children/) | Content to add to the file, such as function definitions, class definitions, and variable declarations. |
|
|
50
|
+
| doc | optional [Children](../../../core/types/children/) | Documentation for this module, which will be rendered as a module-level docstring. |
|
|
51
|
+
| futureImports | optional [Children](../../../core/types/children/)\[] | **future** imports to render after the docstring but before regular imports. |
|
|
52
|
+
| header | optional [Children](../../../core/types/children/) | Content to render at the very top of the file, before everything else. Use this for shebang lines, encoding declarations, or license headers. |
|
|
53
|
+
| headerComment | optional string | Comment to add at the top of the file, rendered as a Python comment block. This is a convenience prop for adding copyright notices or other comments. |
|
|
54
|
+
| insertFinalNewLine | optional boolean | If files should end with a final new line. |
|
|
55
|
+
| path | string | The path to the file relative to the source directory. |
|
|
56
|
+
| printWidth | optional number | The number of characters the printer will wrap on. Defaults to 100 characters. |
|
|
57
|
+
| tabWidth | optional number | The number of spaces to use for indentation. Defaults to 2 spaces. |
|
|
58
|
+
| useTabs | optional boolean | Whether to use tabs instead of spaces for indentation. Defaults to false. |
|
|
47
59
|
|
|
48
60
|
## Examples
|
|
49
61
|
|
|
@@ -8,7 +8,7 @@ A Python static method declaration component.
|
|
|
8
8
|
import { StaticMethodDeclaration } from "@alloy-js/python";
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
<StaticMethodDeclaration abstract async />
|
|
11
|
+
<StaticMethodDeclaration abstract async decorators={Children[]} />
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
* stc
|
|
@@ -20,12 +20,14 @@ A Python static method declaration component.
|
|
|
20
20
|
StaticMethodDeclaration({
|
|
21
21
|
abstract: boolean,
|
|
22
22
|
async: boolean,
|
|
23
|
+
decorators: Children[],
|
|
23
24
|
}).children(children)
|
|
24
25
|
```
|
|
25
26
|
|
|
26
27
|
## Props
|
|
27
28
|
|
|
28
|
-
|
|
|
29
|
-
|
|
|
30
|
-
| abstract
|
|
31
|
-
| async
|
|
29
|
+
| | | |
|
|
30
|
+
| ---------- | ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
31
|
+
| abstract | optional boolean | |
|
|
32
|
+
| async | optional boolean | Indicates that the function is async. |
|
|
33
|
+
| decorators | optional [Children](../../../core/types/children/)\[] | Decorators rendered above `def`, in source order — `decorators[0]` is topmost. By Python’s bottom-up application order, the topmost entry is the **outermost** decorator (applied last) and wraps the result of every decorator below it. Each entry should produce a complete decorator line (typically starting with `@`). Falsy entries (other than `0`) are skipped, so conditional decorators can be provided inline when needed. When used through wrappers that emit an intrinsic decorator ([`ClassMethodDeclaration`](ClassMethodDeclaration.md) → `@classmethod`, [`StaticMethodDeclaration`](StaticMethodDeclaration.md) → `@staticmethod`, [`PropertyDeclaration`](PropertyDeclaration.md) → `@property`), these decorators are rendered **above** the intrinsic line — the correct position for Pydantic’s `@field_validator` / `@model_validator` and other wrappers that must see the underlying function, not a descriptor. When used on plain [`MethodDeclaration`](MethodDeclaration.md) / [`FunctionDeclaration`](FunctionDeclaration.md), these decorators are rendered above `@abstractmethod` (if `abstract` is set) and above `def`. Do **not** pass intrinsic decorators here — i.e. `@classmethod`, `@staticmethod`, `@property`, or `@abstractmethod`. Those are emitted by the matching component ([`ClassMethodDeclaration`](ClassMethodDeclaration.md), [`StaticMethodDeclaration`](StaticMethodDeclaration.md), [`PropertyDeclaration`](PropertyDeclaration.md), or the `abstract` flag) and would otherwise be stacked twice in the output, producing invalid Python. |
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
- [ModuleDoc](ModuleDoc.md) — A component that creates a ModuleDoc block for module-level documentation.
|
|
30
30
|
- [PropertyDeclaration](PropertyDeclaration.md) — Declares a Python property with optional getter, setter, and deleter methods.
|
|
31
31
|
- [PropertyDoc](PropertyDoc.md) — A component that creates a PropertyDoc block for `@property` decorated methods.
|
|
32
|
+
- [PydanticClassDeclaration](PydanticClassDeclaration.md) — Renders a Python class that subclasses Pydantic’s `BaseModel`: `class Name(BaseModel): ...`.
|
|
32
33
|
- [PyDoc](PyDoc.md) — A PyDoc comment.
|
|
33
34
|
- [PyDocExample](PyDocExample.md) — Create a PyDoc example, which is prepended by >>.
|
|
34
35
|
- [PythonBlock](PythonBlock.md) — A Python block component that can be used to render a block of Python code.
|
package/docs/api/index.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @alloy-js/python API Reference
|
|
2
2
|
|
|
3
|
-
- [components](components/index.md) (
|
|
3
|
+
- [components](components/index.md) (45 items)
|
|
4
4
|
- [contexts](contexts/index.md) (1 items)
|
|
5
5
|
- [functions](functions/index.md) (11 items)
|
|
6
|
-
- [types](types/index.md) (
|
|
7
|
-
- [variables](variables/index.md) (
|
|
6
|
+
- [types](types/index.md) (30 items)
|
|
7
|
+
- [variables](variables/index.md) (9 items)
|
|
@@ -6,9 +6,10 @@ Shared base interface for function-like components.
|
|
|
6
6
|
|
|
7
7
|
Extends [BaseDeclarationProps](../basedeclarationprops/),[CallSignatureProps](../../components/callsignature/)
|
|
8
8
|
|
|
9
|
-
|
|
|
10
|
-
|
|
|
11
|
-
| async
|
|
9
|
+
| | | |
|
|
10
|
+
| ---------- | ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
11
|
+
| async | optional boolean | Indicates that the function is async. |
|
|
12
|
+
| decorators | optional [Children](../../../core/types/children/)\[] | Decorators rendered above `def`, in source order — `decorators[0]` is topmost. By Python’s bottom-up application order, the topmost entry is the **outermost** decorator (applied last) and wraps the result of every decorator below it. Each entry should produce a complete decorator line (typically starting with `@`). Falsy entries (other than `0`) are skipped, so conditional decorators can be provided inline when needed. When used through wrappers that emit an intrinsic decorator ([`ClassMethodDeclaration`](../components/ClassMethodDeclaration.md) → `@classmethod`, [`StaticMethodDeclaration`](../components/StaticMethodDeclaration.md) → `@staticmethod`, [`PropertyDeclaration`](../components/PropertyDeclaration.md) → `@property`), these decorators are rendered **above** the intrinsic line — the correct position for Pydantic’s `@field_validator` / `@model_validator` and other wrappers that must see the underlying function, not a descriptor. When used on plain [`MethodDeclaration`](../components/MethodDeclaration.md) / [`FunctionDeclaration`](../components/FunctionDeclaration.md), these decorators are rendered above `@abstractmethod` (if `abstract` is set) and above `def`. Do **not** pass intrinsic decorators here — i.e. `@classmethod`, `@staticmethod`, `@property`, or `@abstractmethod`. Those are emitted by the matching component ([`ClassMethodDeclaration`](../components/ClassMethodDeclaration.md), [`StaticMethodDeclaration`](../components/StaticMethodDeclaration.md), [`PropertyDeclaration`](../components/PropertyDeclaration.md), or the `abstract` flag) and would otherwise be stacked twice in the output, producing invalid Python. |
|
|
12
13
|
|
|
13
14
|
## Remarks
|
|
14
15
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# PydanticModelConfigDictProps
|
|
2
|
+
|
|
3
|
+
Keyword-style options for Pydantic v2 `ConfigDict`, using camelCase prop names that map to snake\_case Python arguments (for example `validateAssignment` → `validate_assignment`).
|
|
4
|
+
|
|
5
|
+
## Members
|
|
6
|
+
|
|
7
|
+
| | | |
|
|
8
|
+
| --------------------- | ---------------------------------------------------- | --------------------------------------------------------------------------- |
|
|
9
|
+
| aliasGenerator | optional string | Resolve field aliases from a configured alias generator. |
|
|
10
|
+
| arbitraryTypesAllowed | optional boolean | Allow non-pydantic/arbitrary Python types in field annotations. |
|
|
11
|
+
| coerceNumbersToStr | optional boolean | Coerce numeric input values to strings for `str` fields. |
|
|
12
|
+
| extra | optional “allow” \| “forbid” \| “ignore” | Behavior for unknown input keys: allow, forbid, or ignore. |
|
|
13
|
+
| fromAttributes | optional boolean | Populate models from object attributes (ORM-style) instead of mapping keys. |
|
|
14
|
+
| frozen | optional boolean | Make models immutable (`frozen=True`). |
|
|
15
|
+
| hideInputInErrors | optional boolean | Hide input values in validation error messages. |
|
|
16
|
+
| jsonSchemaExtra | optional Record\<string, unknown> | Include JSON schema extras via a plain JSON-serializable object. |
|
|
17
|
+
| locByAlias | optional boolean | Use aliases in error locations instead of field names. |
|
|
18
|
+
| populateByName | optional boolean | Allow population by field name even when aliases are defined. |
|
|
19
|
+
| revalidateInstances | optional “always” \| “never” \| “subclass-instances” | Re-validate model/dataclass instances on assignment boundaries. |
|
|
20
|
+
| serJsonBytes | optional “utf8” \| “base64” \| “hex” | JSON serialization format for bytes values. |
|
|
21
|
+
| serJsonInfNan | optional “null” \| “constants” \| “strings” | JSON serialization behavior for Infinity/NaN values. |
|
|
22
|
+
| strict | optional boolean | Enable strict validation globally for the model. |
|
|
23
|
+
| strMaxLength | optional number | Upper-bound for constrained string lengths at model level. |
|
|
24
|
+
| strMinLength | optional number | Lower-bound for constrained string lengths at model level. |
|
|
25
|
+
| strStripWhitespace | optional boolean | Strip leading/trailing whitespace from all `str` fields. |
|
|
26
|
+
| strToLower | optional boolean | Convert all `str` values to lowercase. |
|
|
27
|
+
| strToUpper | optional boolean | Convert all `str` values to uppercase. |
|
|
28
|
+
| useEnumValues | optional boolean | Use enum `.value` instead of enum instances during serialization. |
|
|
29
|
+
| validateAssignment | optional boolean | Re-validate when attributes are assigned after model creation. |
|
|
30
|
+
| validateDefault | optional boolean | Validate default values in addition to provided input values. |
|
|
31
|
+
| validateReturn | optional boolean | Validate return values for call validators. |
|
|
32
|
+
| valJsonBytes | optional “utf8” \| “base64” \| “hex” | JSON validation format for bytes values. |
|
package/docs/api/types/index.md
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
- [ParameterDescriptor](ParameterDescriptor.md) — Information for a Python function parameter.
|
|
21
21
|
- [ParameterMarker](ParameterMarker.md) — type ParameterMarker = "*" | "/";
|
|
22
22
|
- [PropertyMethodDeclarationProps](PropertyMethodDeclarationProps.md) — Extends Omit<[CommonFunctionProps](../commonfunctionprops/), “name”>
|
|
23
|
+
- [PydanticModelConfigDictProps](PydanticModelConfigDictProps.md) — Keyword-style options for Pydantic v2 `ConfigDict`, using camelCase prop names that map to snake\_case Python arguments
|
|
23
24
|
- [PythonElements](PythonElements.md) — type PythonElements = "class" | "class-member" | "function" | "variable" | "object-member" | "constant" | "parameter" |
|
|
24
25
|
- [PythonLexicalScope](PythonLexicalScope.md) — Extends [OutputScope](../../../core/types/outputscope/)
|
|
25
26
|
- [PythonMemberScope](PythonMemberScope.md) — Extends [OutputScope](../../../core/types/outputscope/)
|
|
@@ -5,4 +5,7 @@
|
|
|
5
5
|
- [dataclassDecoratorKeySet](dataclassDecoratorKeySet.md) — dataclassDecoratorKeySet: Set<string>
|
|
6
6
|
- [dataclassesModule](dataclassesModule.md) — dataclassesModule: import("../create-module.js").ModuleRefkeys<{
|
|
7
7
|
- [enumModule](enumModule.md) — enumModule: import("../create-module.js").ModuleRefkeys<{
|
|
8
|
+
- [pydanticModule](pydanticModule.md) — pydanticModule: import("../create-module.js").ModuleRefkeys<{
|
|
9
|
+
- [pydanticSettingsModule](pydanticSettingsModule.md) — pydanticSettingsModule: import("../create-module.js").ModuleRefkeys<{
|
|
8
10
|
- [requestsModule](requestsModule.md) — requestsModule: import("../create-module.js").ModuleRefkeys<{
|
|
11
|
+
- [typingModule](typingModule.md) — `typing` stdlib symbols used heavily with Pydantic generics and annotations.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# pydanticModule
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
pydanticModule: import("../create-module.js").ModuleRefkeys<{
|
|
5
|
+
readonly ".": ["AfterValidator", "AliasChoices", "AliasGenerator", "AliasPath", "AllowInfNan", "AmqpDsn", "AnyHttpUrl", "AnyUrl", "AnyWebsocketUrl", "AwareDatetime", "Base64Bytes", "Base64Encoder", "Base64Str", "Base64UrlBytes", "Base64UrlStr", "BaseModel", "BeforeValidator", "ByteSize", "ClickHouseDsn", "CockroachDsn", "ConfigDict", "DirectoryPath", "Discriminator", "EmailStr", "EncodedBytes", "EncodedStr", "EncoderProtocol", "Extra", "FailFast", "Field", "FieldSerializationInfo", "FilePath", "FileUrl", "FiniteFloat", "FtpUrl", "FutureDate", "FutureDatetime", "GetCoreSchemaHandler", "GetJsonSchemaHandler", "GetPydanticSchema", "HttpUrl", "IPvAnyAddress", "IPvAnyInterface", "IPvAnyNetwork", "ImportString", "InstanceOf", "Json", "JsonValue", "KafkaDsn", "MariaDBDsn", "ModelWrapValidatorHandler", "MongoDsn", "MySQLDsn", "NaiveDatetime", "NameEmail", "NatsDsn", "NegativeFloat", "NegativeInt", "NewPath", "NonNegativeFloat", "NonNegativeInt", "NonPositiveFloat", "NonPositiveInt", "OnErrorOmit", "PastDate", "PastDatetime", "PaymentCardNumber", "PlainSerializer", "PlainValidator", "PositiveFloat", "PositiveInt", "PostgresDsn", "PrivateAttr", "PydanticDeprecatedSince20", "PydanticDeprecatedSince210", "PydanticDeprecatedSince211", "PydanticDeprecatedSince212", "PydanticDeprecatedSince26", "PydanticDeprecatedSince29", "PydanticDeprecationWarning", "PydanticErrorCodes", "PydanticExperimentalWarning", "PydanticForbiddenQualifier", "PydanticImportError", "PydanticInvalidForJsonSchema", "PydanticSchemaGenerationError", "PydanticUndefinedAnnotation", "PydanticUserError", "RedisDsn", "RootModel", "Secret", "SecretBytes", "SecretStr", "SerializationInfo", "SerializeAsAny", "SerializerFunctionWrapHandler", "SkipValidation", "SnowflakeDsn", "SocketPath", "Strict", "StrictBool", "StrictBytes", "StrictFloat", "StrictInt", "StrictStr", "StringConstraints", "Tag", "TypeAdapter", "UUID1", "UUID3", "UUID4", "UUID5", "UUID6", "UUID7", "UUID8", "UrlConstraints", "VERSION", "ValidateAs", "ValidationError", "ValidationInfo", "ValidatorFunctionWrapHandler", "WebsocketUrl", "WithJsonSchema", "WrapSerializer", "WrapValidator", "__version__", "computed_field", "conbytes", "condate", "condecimal", "confloat", "confrozenset", "conint", "conlist", "conset", "constr", "create_model", "dataclasses", "field_serializer", "field_validator", "model_serializer", "model_validator", "validate_call", "validate_email", "with_config"];
|
|
6
|
+
readonly alias_generators: ["to_camel", "to_pascal", "to_snake"];
|
|
7
|
+
readonly aliases: ["AliasChoices", "AliasGenerator", "AliasPath"];
|
|
8
|
+
readonly annotated_handlers: ["GetCoreSchemaHandler", "GetJsonSchemaHandler"];
|
|
9
|
+
readonly color: ["Any", "COLORS_BY_NAME", "COLORS_BY_VALUE", "Callable", "Color", "ColorTuple", "ColorType", "CoreSchema", "HslColorTuple", "JsonSchemaValue", "Optional", "PydanticCustomError", "PydanticDeprecatedSince20", "RGBA", "Union", "cast", "core_schema", "deprecated", "float_to_255", "hls_to_rgb", "ints_to_rgba", "math", "parse_color_value", "parse_float_alpha", "parse_hsl", "parse_str", "parse_tuple", "r_hex_long", "r_hex_short", "r_hsl", "r_hsl_v4_style", "r_rgb", "r_rgb_v4_style", "rads", "re", "repeat_colors", "rgb_to_hls"];
|
|
10
|
+
readonly config: ["ConfigDict", "with_config"];
|
|
11
|
+
readonly dataclasses: ["dataclass", "rebuild_dataclass"];
|
|
12
|
+
readonly errors: ["PydanticErrorCodes", "PydanticForbiddenQualifier", "PydanticImportError", "PydanticInvalidForJsonSchema", "PydanticSchemaGenerationError", "PydanticUndefinedAnnotation", "PydanticUserError"];
|
|
13
|
+
readonly fields: ["Field", "FieldInfo", "PrivateAttr", "computed_field"];
|
|
14
|
+
readonly functional_serializers: ["Annotated", "Any", "AnyType", "Callable", "GetCoreSchemaHandler", "Literal", "PlainSerializer", "PydanticUndefined", "PydanticUndefinedAnnotation", "PydanticUserError", "SerializationInfo", "SerializeAsAny", "SerializerFunctionWrapHandler", "TYPE_CHECKING", "TypeAlias", "TypeVar", "WhenUsed", "WrapSerializer", "annotations", "core_schema", "dataclasses", "field_serializer", "model_serializer", "overload", "partial", "partialmethod"];
|
|
15
|
+
readonly functional_validators: ["AfterValidator", "Annotated", "Any", "AnyType", "ArbitraryTypeWarning", "BeforeValidator", "Callable", "FieldValidatorModes", "FreeModelBeforeValidator", "FreeModelBeforeValidatorWithoutInfo", "GetCoreSchemaHandler", "InstanceOf", "Literal", "ModelAfterValidator", "ModelAfterValidatorWithoutInfo", "ModelBeforeValidator", "ModelBeforeValidatorWithoutInfo", "ModelWrapValidator", "ModelWrapValidatorHandler", "ModelWrapValidatorWithoutInfo", "PlainValidator", "Protocol", "PydanticDeprecatedSince212", "PydanticUndefined", "PydanticUserError", "Self", "SkipValidation", "TYPE_CHECKING", "TypeAlias", "TypeVar", "Union", "ValidateAs", "WrapValidator", "cast", "core_schema", "dataclasses", "field_validator", "model_validator", "overload", "partialmethod", "sys", "version_short", "warnings"];
|
|
16
|
+
readonly json_schema: ["Annotated", "Any", "AnyType", "Callable", "ComputedField", "CoreModeRef", "CoreRef", "CoreSchema", "CoreSchemaOrFieldType", "Counter", "DEFAULT_REF_TEMPLATE", "DefsRef", "Enum", "Examples", "GenerateJsonSchema", "GetJsonSchemaHandler", "Hashable", "Iterable", "JsonDict", "JsonRef", "JsonSchemaKeyT", "JsonSchemaMode", "JsonSchemaValue", "JsonSchemaWarningKind", "JsonValue", "Literal", "MISSING", "NewType", "NoDefault", "Pattern", "PydanticDeprecatedSince26", "PydanticDeprecatedSince29", "PydanticInvalidForJsonSchema", "PydanticJsonSchemaWarning", "PydanticOmit", "PydanticSchemaGenerationError", "PydanticUserError", "Sequence", "SkipJsonSchema", "TYPE_CHECKING", "TypeAlias", "TypeVar", "Union", "WithJsonSchema", "assert_never", "cast", "collections", "core_schema", "dataclasses", "deepcopy", "defaultdict", "deprecated", "final", "get_literal_values", "inspect", "math", "model_json_schema", "models_json_schema", "os", "overload", "pydantic_core", "re", "to_jsonable_python", "warnings"];
|
|
17
|
+
readonly main: ["BaseModel", "create_model"];
|
|
18
|
+
readonly networks: ["AmqpDsn", "AnyHttpUrl", "AnyUrl", "AnyWebsocketUrl", "ClickHouseDsn", "CockroachDsn", "EmailStr", "FileUrl", "FtpUrl", "HttpUrl", "IPvAnyAddress", "IPvAnyInterface", "IPvAnyNetwork", "KafkaDsn", "MariaDBDsn", "MongoDsn", "MySQLDsn", "NameEmail", "NatsDsn", "PostgresDsn", "RedisDsn", "SnowflakeDsn", "UrlConstraints", "WebsocketUrl", "validate_email"];
|
|
19
|
+
readonly plugin: ["BaseValidateHandlerProtocol", "NewSchemaReturns", "PydanticPluginProtocol", "SchemaKind", "SchemaTypePath", "ValidateJsonHandlerProtocol", "ValidatePythonHandlerProtocol", "ValidateStringsHandlerProtocol"];
|
|
20
|
+
readonly root_model: ["RootModel"];
|
|
21
|
+
readonly type_adapter: ["Any", "BaseModel", "Callable", "ConfigDict", "CoreSchema", "DEFAULT_REF_TEMPLATE", "ExtraValues", "FrameType", "GenerateJsonSchema", "Generic", "IncEx", "Iterable", "JsonSchemaKeyT", "JsonSchemaMode", "JsonSchemaValue", "Literal", "P", "ParamSpec", "PluggableSchemaValidator", "PydanticUndefinedAnnotation", "PydanticUserError", "R", "SchemaSerializer", "SchemaValidator", "Some", "T", "TypeAdapter", "TypeAdapterT", "TypeVar", "cast", "create_schema_validator", "final", "is_dataclass", "is_typeddict", "overload", "sys", "types"];
|
|
22
|
+
readonly types: ["AllowInfNan", "AwareDatetime", "Base64Bytes", "Base64Encoder", "Base64Str", "Base64UrlBytes", "Base64UrlStr", "ByteSize", "DirectoryPath", "Discriminator", "EncodedBytes", "EncodedStr", "EncoderProtocol", "FailFast", "FilePath", "FiniteFloat", "FutureDate", "FutureDatetime", "GetPydanticSchema", "ImportString", "Json", "JsonValue", "NaiveDatetime", "NegativeFloat", "NegativeInt", "NewPath", "NonNegativeFloat", "NonNegativeInt", "NonPositiveFloat", "NonPositiveInt", "OnErrorOmit", "PastDate", "PastDatetime", "PaymentCardNumber", "PositiveFloat", "PositiveInt", "Secret", "SecretBytes", "SecretStr", "SocketPath", "Strict", "StrictBool", "StrictBytes", "StrictFloat", "StrictInt", "StrictStr", "StringConstraints", "Tag", "UUID1", "UUID3", "UUID4", "UUID5", "UUID6", "UUID7", "UUID8", "conbytes", "condate", "condecimal", "confloat", "confrozenset", "conint", "conlist", "conset", "constr"];
|
|
23
|
+
readonly validate_call_decorator: ["validate_call"];
|
|
24
|
+
readonly version: ["VERSION", "version_info"];
|
|
25
|
+
readonly warnings: ["ArbitraryTypeWarning", "PydanticDeprecatedSince20", "PydanticDeprecatedSince210", "PydanticDeprecatedSince211", "PydanticDeprecatedSince212", "PydanticDeprecatedSince26", "PydanticDeprecatedSince29", "PydanticDeprecationWarning", "PydanticExperimentalWarning", "TypedDictExtraConfigWarning", "UnsupportedFieldAttributeWarning"];
|
|
26
|
+
}> & SymbolCreator
|
|
27
|
+
```
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# typingModule
|
|
2
|
+
|
|
3
|
+
`typing` stdlib symbols used heavily with Pydantic generics and annotations.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
typingModule: import("../create-module.js").ModuleRefkeys<{
|
|
7
|
+
readonly ".": ["Annotated", "Any", "ClassVar", "Generic", "Literal", "Optional", "Protocol", "TypeVar", "Union", "final", "override", "runtime_checkable"];
|
|
8
|
+
}> & SymbolCreator
|
|
9
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alloy-js/python",
|
|
3
|
-
"version": "0.5.0-dev.
|
|
3
|
+
"version": "0.5.0-dev.2",
|
|
4
4
|
"description": "Python bindings for Alloy",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
"author": "",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@alloy-js/core": "~0.23.
|
|
23
|
+
"@alloy-js/core": "~0.23.1 || >= 0.24.0-dev.7",
|
|
24
24
|
"change-case": "^5.4.4",
|
|
25
25
|
"pathe": "^2.0.3"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@alloy-js/cli": "~0.23.0 || >= 0.24.0-dev.
|
|
29
|
-
"@alloy-js/rollup-plugin": "~0.1.1 || >= 0.1.2-dev.
|
|
28
|
+
"@alloy-js/cli": "~0.23.0 || >= 0.24.0-dev.1",
|
|
29
|
+
"@alloy-js/rollup-plugin": "~0.1.1 || >= 0.1.2-dev.2",
|
|
30
30
|
"@microsoft/api-extractor": "~7.52.8",
|
|
31
31
|
"@rollup/plugin-typescript": "^12.1.2",
|
|
32
32
|
"concurrently": "^9.2.0",
|