@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
|
@@ -1,168 +1,168 @@
|
|
|
1
1
|
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import { Prose } from "@alloy-js/core";
|
|
3
|
-
import { d } from "@alloy-js/core/testing";
|
|
4
3
|
import { expect, it } from "vitest";
|
|
5
4
|
import * as py from "../src/index.js";
|
|
6
5
|
import { dataclassesModule } from "../src/index.js";
|
|
7
|
-
import {
|
|
6
|
+
import { TestOutput, TestOutputDirectory } from "./utils.js";
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* TestOutputDirectory wraps content in an Output component without a default
|
|
10
|
+
* SourceFile, so SourceFile components with their own path/props can be used.
|
|
12
11
|
*/
|
|
13
12
|
it("renders an empty source file", () => {
|
|
14
|
-
|
|
15
|
-
expect(result).toRenderTo(d`
|
|
16
|
-
|
|
13
|
+
expect(_$createComponent(TestOutput, {})).toRenderTo(`
|
|
17
14
|
|
|
18
15
|
`);
|
|
19
16
|
});
|
|
20
17
|
it("correct formatting of source file", () => {
|
|
21
|
-
|
|
22
|
-
name: "someClass",
|
|
18
|
+
expect(_$createComponent(TestOutput, {
|
|
23
19
|
get children() {
|
|
24
|
-
return _$createComponent(py.
|
|
20
|
+
return [_$createComponent(py.ClassDeclaration, {
|
|
21
|
+
name: "someClass",
|
|
25
22
|
get children() {
|
|
26
|
-
return
|
|
27
|
-
name: "someMethod",
|
|
28
|
-
returnType: "str",
|
|
23
|
+
return _$createComponent(py.StatementList, {
|
|
29
24
|
get children() {
|
|
30
|
-
return _$createComponent(py.
|
|
25
|
+
return [_$createComponent(py.FunctionDeclaration, {
|
|
26
|
+
name: "someMethod",
|
|
27
|
+
returnType: "str",
|
|
31
28
|
get children() {
|
|
32
|
-
return
|
|
33
|
-
name: "x",
|
|
34
|
-
type: "int",
|
|
35
|
-
get initializer() {
|
|
36
|
-
return _$createComponent(py.Atom, {
|
|
37
|
-
jsValue: 42
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}), _$createComponent(py.VariableDeclaration, {
|
|
41
|
-
name: "y",
|
|
42
|
-
type: "int",
|
|
43
|
-
get initializer() {
|
|
44
|
-
return _$createComponent(py.Atom, {
|
|
45
|
-
jsValue: 42
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}), _$createComponent(py.FunctionCallExpression, {
|
|
49
|
-
target: "foo",
|
|
50
|
-
args: ["a", "b"]
|
|
51
|
-
}), _$createComponent(py.MemberExpression, {
|
|
29
|
+
return _$createComponent(py.StatementList, {
|
|
52
30
|
get children() {
|
|
53
|
-
return [_$createComponent(py.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
31
|
+
return [_$createComponent(py.VariableDeclaration, {
|
|
32
|
+
name: "x",
|
|
33
|
+
type: "int",
|
|
34
|
+
get initializer() {
|
|
35
|
+
return _$createComponent(py.Atom, {
|
|
36
|
+
jsValue: 42
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}), _$createComponent(py.VariableDeclaration, {
|
|
40
|
+
name: "y",
|
|
41
|
+
type: "int",
|
|
42
|
+
get initializer() {
|
|
43
|
+
return _$createComponent(py.Atom, {
|
|
44
|
+
jsValue: 42
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}), _$createComponent(py.FunctionCallExpression, {
|
|
48
|
+
target: "foo",
|
|
49
|
+
args: ["a", "b"]
|
|
50
|
+
}), _$createComponent(py.MemberExpression, {
|
|
51
|
+
get children() {
|
|
52
|
+
return [_$createComponent(py.MemberExpression.Part, {
|
|
53
|
+
id: "a"
|
|
54
|
+
}), _$createComponent(py.MemberExpression.Part, {
|
|
55
|
+
id: "b"
|
|
56
|
+
}), _$createComponent(py.MemberExpression.Part, {
|
|
57
|
+
key: "special-prop"
|
|
58
|
+
})];
|
|
59
|
+
}
|
|
60
|
+
}), _$createComponent(py.VariableDeclaration, {
|
|
61
|
+
name: "z",
|
|
62
|
+
type: "int",
|
|
63
|
+
get initializer() {
|
|
64
|
+
return _$createComponent(py.Atom, {
|
|
65
|
+
jsValue: 42
|
|
66
|
+
});
|
|
67
|
+
}
|
|
59
68
|
})];
|
|
60
69
|
}
|
|
61
|
-
})
|
|
62
|
-
name: "z",
|
|
63
|
-
type: "int",
|
|
64
|
-
get initializer() {
|
|
65
|
-
return _$createComponent(py.Atom, {
|
|
66
|
-
jsValue: 42
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
})];
|
|
70
|
+
});
|
|
70
71
|
}
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
});
|
|
72
|
+
}), _$createComponent(py.VariableDeclaration, {
|
|
73
|
+
name: "someVar",
|
|
74
|
+
type: "int",
|
|
75
|
+
get initializer() {
|
|
76
|
+
return _$createComponent(py.Atom, {
|
|
77
|
+
jsValue: 42
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}), _$createComponent(py.FunctionDeclaration, {
|
|
81
|
+
name: "someOtherMethod",
|
|
82
|
+
returnType: "str"
|
|
83
|
+
}), _$createComponent(py.VariableDeclaration, {
|
|
84
|
+
name: "someOtherVar",
|
|
85
|
+
type: "int",
|
|
86
|
+
get initializer() {
|
|
87
|
+
return _$createComponent(py.Atom, {
|
|
88
|
+
jsValue: 42
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
})];
|
|
91
92
|
}
|
|
92
|
-
})
|
|
93
|
+
});
|
|
93
94
|
}
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
}), _$createComponent(py.FunctionDeclaration, {
|
|
97
|
-
name: "someFunction",
|
|
98
|
-
get children() {
|
|
99
|
-
return _$createComponent(py.StatementList, {
|
|
95
|
+
}), _$createComponent(py.FunctionDeclaration, {
|
|
96
|
+
name: "someFunction",
|
|
100
97
|
get children() {
|
|
101
|
-
return
|
|
102
|
-
name: "x",
|
|
103
|
-
type: "int",
|
|
104
|
-
get initializer() {
|
|
105
|
-
return _$createComponent(py.Atom, {
|
|
106
|
-
jsValue: 42
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
}), _$createComponent(py.VariableDeclaration, {
|
|
110
|
-
name: "y",
|
|
111
|
-
type: "int",
|
|
112
|
-
get initializer() {
|
|
113
|
-
return _$createComponent(py.Atom, {
|
|
114
|
-
jsValue: 42
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
}), _$createComponent(py.FunctionCallExpression, {
|
|
118
|
-
target: "foo",
|
|
119
|
-
args: ["a", "b"]
|
|
120
|
-
}), _$createComponent(py.MemberExpression, {
|
|
98
|
+
return _$createComponent(py.StatementList, {
|
|
121
99
|
get children() {
|
|
122
|
-
return [_$createComponent(py.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
100
|
+
return [_$createComponent(py.VariableDeclaration, {
|
|
101
|
+
name: "x",
|
|
102
|
+
type: "int",
|
|
103
|
+
get initializer() {
|
|
104
|
+
return _$createComponent(py.Atom, {
|
|
105
|
+
jsValue: 42
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}), _$createComponent(py.VariableDeclaration, {
|
|
109
|
+
name: "y",
|
|
110
|
+
type: "int",
|
|
111
|
+
get initializer() {
|
|
112
|
+
return _$createComponent(py.Atom, {
|
|
113
|
+
jsValue: 42
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}), _$createComponent(py.FunctionCallExpression, {
|
|
117
|
+
target: "foo",
|
|
118
|
+
args: ["a", "b"]
|
|
119
|
+
}), _$createComponent(py.MemberExpression, {
|
|
120
|
+
get children() {
|
|
121
|
+
return [_$createComponent(py.MemberExpression.Part, {
|
|
122
|
+
id: "a"
|
|
123
|
+
}), _$createComponent(py.MemberExpression.Part, {
|
|
124
|
+
id: "b"
|
|
125
|
+
}), _$createComponent(py.MemberExpression.Part, {
|
|
126
|
+
key: "special-prop"
|
|
127
|
+
})];
|
|
128
|
+
}
|
|
129
|
+
}), _$createComponent(py.VariableDeclaration, {
|
|
130
|
+
name: "z",
|
|
131
|
+
type: "int",
|
|
132
|
+
get initializer() {
|
|
133
|
+
return _$createComponent(py.Atom, {
|
|
134
|
+
jsValue: 42
|
|
135
|
+
});
|
|
136
|
+
}
|
|
128
137
|
})];
|
|
129
138
|
}
|
|
130
|
-
})
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}), _$createComponent(py.ClassDeclaration, {
|
|
142
|
+
name: "someOtherClass",
|
|
143
|
+
get children() {
|
|
144
|
+
return _$createComponent(py.StatementList, {
|
|
145
|
+
get children() {
|
|
146
|
+
return _$createComponent(py.FunctionDeclaration, {
|
|
147
|
+
name: "someMethod",
|
|
148
|
+
returnType: "str"
|
|
136
149
|
});
|
|
137
150
|
}
|
|
138
|
-
})
|
|
151
|
+
});
|
|
139
152
|
}
|
|
140
|
-
})
|
|
141
|
-
}
|
|
142
|
-
}), _$createComponent(py.ClassDeclaration, {
|
|
143
|
-
name: "someOtherClass",
|
|
144
|
-
get children() {
|
|
145
|
-
return _$createComponent(py.StatementList, {
|
|
153
|
+
}), _$createComponent(py.MemberExpression, {
|
|
146
154
|
get children() {
|
|
147
|
-
return _$createComponent(py.
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
155
|
+
return [_$createComponent(py.MemberExpression.Part, {
|
|
156
|
+
id: "a"
|
|
157
|
+
}), _$createComponent(py.MemberExpression.Part, {
|
|
158
|
+
id: "b"
|
|
159
|
+
}), _$createComponent(py.MemberExpression.Part, {
|
|
160
|
+
key: "special-prop"
|
|
161
|
+
})];
|
|
151
162
|
}
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
}), _$createComponent(py.MemberExpression, {
|
|
155
|
-
get children() {
|
|
156
|
-
return [_$createComponent(py.MemberExpression.Part, {
|
|
157
|
-
id: "a"
|
|
158
|
-
}), _$createComponent(py.MemberExpression.Part, {
|
|
159
|
-
id: "b"
|
|
160
|
-
}), _$createComponent(py.MemberExpression.Part, {
|
|
161
|
-
key: "special-prop"
|
|
162
163
|
})];
|
|
163
164
|
}
|
|
164
|
-
})
|
|
165
|
-
expect(result).toRenderTo(d`
|
|
165
|
+
})).toRenderTo(`
|
|
166
166
|
class SomeClass:
|
|
167
167
|
def some_method() -> str:
|
|
168
168
|
x: int = 42
|
|
@@ -193,7 +193,6 @@ it("correct formatting of source file", () => {
|
|
|
193
193
|
|
|
194
194
|
|
|
195
195
|
a.b["special-prop"]
|
|
196
|
-
|
|
197
196
|
`);
|
|
198
197
|
});
|
|
199
198
|
it("renders module documentation correctly", () => {
|
|
@@ -215,23 +214,27 @@ it("renders module documentation correctly", () => {
|
|
|
215
214
|
todo: ["Add caching functionality", "Improve error messages"],
|
|
216
215
|
style: "google"
|
|
217
216
|
});
|
|
218
|
-
|
|
219
|
-
path: "test.py",
|
|
220
|
-
doc: moduleDoc,
|
|
217
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
221
218
|
get children() {
|
|
222
|
-
return
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
219
|
+
return _$createComponent(py.SourceFile, {
|
|
220
|
+
path: "test.py",
|
|
221
|
+
doc: moduleDoc,
|
|
222
|
+
get children() {
|
|
223
|
+
return [_$createComponent(py.VariableDeclaration, {
|
|
224
|
+
name: "DEFAULT_TIMEOUT",
|
|
225
|
+
initializer: 30
|
|
226
|
+
}), _$createComponent(py.VariableDeclaration, {
|
|
227
|
+
name: "MAX_RETRIES",
|
|
228
|
+
initializer: 3
|
|
229
|
+
}), _$createComponent(py.FunctionDeclaration, {
|
|
230
|
+
name: "process_data",
|
|
231
|
+
children: "pass"
|
|
232
|
+
})];
|
|
233
|
+
}
|
|
234
|
+
});
|
|
232
235
|
}
|
|
233
|
-
})
|
|
234
|
-
|
|
236
|
+
})).toRenderTo({
|
|
237
|
+
"test.py": `
|
|
235
238
|
"""
|
|
236
239
|
This module provides utility functions for data processing. It includes
|
|
237
240
|
functions for validation, transformation, and analysis.
|
|
@@ -253,54 +256,67 @@ it("renders module documentation correctly", () => {
|
|
|
253
256
|
def process_data():
|
|
254
257
|
pass
|
|
255
258
|
|
|
256
|
-
|
|
257
|
-
|
|
259
|
+
`
|
|
260
|
+
});
|
|
258
261
|
});
|
|
259
262
|
it("renders source file without documentation correctly", () => {
|
|
260
|
-
|
|
261
|
-
path: "test.py",
|
|
263
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
262
264
|
get children() {
|
|
263
|
-
return _$createComponent(py.
|
|
264
|
-
|
|
265
|
-
children
|
|
265
|
+
return _$createComponent(py.SourceFile, {
|
|
266
|
+
path: "test.py",
|
|
267
|
+
get children() {
|
|
268
|
+
return _$createComponent(py.FunctionDeclaration, {
|
|
269
|
+
name: "hello_world",
|
|
270
|
+
children: "print(\"Hello, World!\")"
|
|
271
|
+
});
|
|
272
|
+
}
|
|
266
273
|
});
|
|
267
274
|
}
|
|
268
|
-
})
|
|
269
|
-
|
|
275
|
+
})).toRenderTo({
|
|
276
|
+
"test.py": `
|
|
270
277
|
def hello_world():
|
|
271
278
|
print("Hello, World!")
|
|
272
279
|
|
|
273
|
-
|
|
274
|
-
|
|
280
|
+
`
|
|
281
|
+
});
|
|
275
282
|
});
|
|
276
283
|
it("nothing before top-level definition", () => {
|
|
277
|
-
|
|
278
|
-
path: "test.py",
|
|
284
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
279
285
|
get children() {
|
|
280
|
-
return _$createComponent(py.
|
|
281
|
-
|
|
282
|
-
children
|
|
286
|
+
return _$createComponent(py.SourceFile, {
|
|
287
|
+
path: "test.py",
|
|
288
|
+
get children() {
|
|
289
|
+
return _$createComponent(py.FunctionDeclaration, {
|
|
290
|
+
name: "hello",
|
|
291
|
+
children: "pass"
|
|
292
|
+
});
|
|
293
|
+
}
|
|
283
294
|
});
|
|
284
295
|
}
|
|
285
|
-
})
|
|
286
|
-
|
|
296
|
+
})).toRenderTo({
|
|
297
|
+
"test.py": `
|
|
287
298
|
def hello():
|
|
288
299
|
pass
|
|
289
300
|
|
|
290
|
-
|
|
291
|
-
|
|
301
|
+
`
|
|
302
|
+
});
|
|
292
303
|
});
|
|
293
304
|
it("nothing before non-definition", () => {
|
|
294
|
-
|
|
295
|
-
path: "test.py",
|
|
305
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
296
306
|
get children() {
|
|
297
|
-
return _$createComponent(py.
|
|
298
|
-
|
|
299
|
-
|
|
307
|
+
return _$createComponent(py.SourceFile, {
|
|
308
|
+
path: "test.py",
|
|
309
|
+
get children() {
|
|
310
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
311
|
+
name: "x",
|
|
312
|
+
initializer: 42
|
|
313
|
+
});
|
|
314
|
+
}
|
|
300
315
|
});
|
|
301
316
|
}
|
|
317
|
+
})).toRenderTo({
|
|
318
|
+
"test.py": "x = 42"
|
|
302
319
|
});
|
|
303
|
-
expect(toSourceText(content)).toRenderTo("x = 42");
|
|
304
320
|
});
|
|
305
321
|
it("only doc before definition", () => {
|
|
306
322
|
const moduleDoc = _$createComponent(py.ModuleDoc, {
|
|
@@ -310,17 +326,21 @@ it("only doc before definition", () => {
|
|
|
310
326
|
})];
|
|
311
327
|
}
|
|
312
328
|
});
|
|
313
|
-
|
|
314
|
-
path: "test.py",
|
|
315
|
-
doc: moduleDoc,
|
|
329
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
316
330
|
get children() {
|
|
317
|
-
return _$createComponent(py.
|
|
318
|
-
|
|
319
|
-
|
|
331
|
+
return _$createComponent(py.SourceFile, {
|
|
332
|
+
path: "test.py",
|
|
333
|
+
doc: moduleDoc,
|
|
334
|
+
get children() {
|
|
335
|
+
return _$createComponent(py.FunctionDeclaration, {
|
|
336
|
+
name: "hello",
|
|
337
|
+
children: "pass"
|
|
338
|
+
});
|
|
339
|
+
}
|
|
320
340
|
});
|
|
321
341
|
}
|
|
322
|
-
})
|
|
323
|
-
|
|
342
|
+
})).toRenderTo({
|
|
343
|
+
"test.py": `
|
|
324
344
|
"""
|
|
325
345
|
Module description.
|
|
326
346
|
"""
|
|
@@ -329,8 +349,8 @@ it("only doc before definition", () => {
|
|
|
329
349
|
def hello():
|
|
330
350
|
pass
|
|
331
351
|
|
|
332
|
-
|
|
333
|
-
|
|
352
|
+
`
|
|
353
|
+
});
|
|
334
354
|
});
|
|
335
355
|
it("only doc before non-definition", () => {
|
|
336
356
|
const moduleDoc = _$createComponent(py.ModuleDoc, {
|
|
@@ -340,127 +360,149 @@ it("only doc before non-definition", () => {
|
|
|
340
360
|
})];
|
|
341
361
|
}
|
|
342
362
|
});
|
|
343
|
-
|
|
344
|
-
path: "test.py",
|
|
345
|
-
doc: moduleDoc,
|
|
363
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
346
364
|
get children() {
|
|
347
|
-
return _$createComponent(py.
|
|
348
|
-
|
|
349
|
-
|
|
365
|
+
return _$createComponent(py.SourceFile, {
|
|
366
|
+
path: "test.py",
|
|
367
|
+
doc: moduleDoc,
|
|
368
|
+
get children() {
|
|
369
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
370
|
+
name: "x",
|
|
371
|
+
initializer: 42
|
|
372
|
+
});
|
|
373
|
+
}
|
|
350
374
|
});
|
|
351
375
|
}
|
|
352
|
-
})
|
|
353
|
-
|
|
376
|
+
})).toRenderTo({
|
|
377
|
+
"test.py": `
|
|
354
378
|
"""
|
|
355
379
|
Module description.
|
|
356
380
|
"""
|
|
357
381
|
|
|
358
|
-
x = 42`
|
|
382
|
+
x = 42`
|
|
383
|
+
});
|
|
359
384
|
});
|
|
360
385
|
it("only header before definition", () => {
|
|
361
|
-
|
|
362
|
-
path: "test.py",
|
|
363
|
-
header: "#!/usr/bin/env python3",
|
|
386
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
364
387
|
get children() {
|
|
365
|
-
return _$createComponent(py.
|
|
366
|
-
|
|
367
|
-
|
|
388
|
+
return _$createComponent(py.SourceFile, {
|
|
389
|
+
path: "test.py",
|
|
390
|
+
header: "#!/usr/bin/env python3",
|
|
391
|
+
get children() {
|
|
392
|
+
return _$createComponent(py.FunctionDeclaration, {
|
|
393
|
+
name: "hello",
|
|
394
|
+
children: "pass"
|
|
395
|
+
});
|
|
396
|
+
}
|
|
368
397
|
});
|
|
369
398
|
}
|
|
370
|
-
})
|
|
371
|
-
|
|
372
|
-
// 2 blank lines before definition (PEP 8)
|
|
373
|
-
expect(toSourceText(content)).toRenderTo(d`
|
|
399
|
+
})).toRenderTo({
|
|
400
|
+
"test.py": `
|
|
374
401
|
#!/usr/bin/env python3
|
|
375
402
|
|
|
376
403
|
|
|
377
404
|
def hello():
|
|
378
405
|
pass
|
|
379
406
|
|
|
380
|
-
|
|
381
|
-
|
|
407
|
+
`
|
|
408
|
+
});
|
|
382
409
|
});
|
|
383
410
|
it("only header before non-definition", () => {
|
|
384
|
-
|
|
385
|
-
path: "test.py",
|
|
386
|
-
header: "#!/usr/bin/env python3",
|
|
411
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
387
412
|
get children() {
|
|
388
|
-
return _$createComponent(py.
|
|
389
|
-
|
|
390
|
-
|
|
413
|
+
return _$createComponent(py.SourceFile, {
|
|
414
|
+
path: "test.py",
|
|
415
|
+
header: "#!/usr/bin/env python3",
|
|
416
|
+
get children() {
|
|
417
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
418
|
+
name: "x",
|
|
419
|
+
initializer: 42
|
|
420
|
+
});
|
|
421
|
+
}
|
|
391
422
|
});
|
|
392
423
|
}
|
|
393
|
-
})
|
|
394
|
-
|
|
395
|
-
// 1 blank line for non-definition
|
|
396
|
-
expect(toSourceText(content)).toRenderTo(d`
|
|
424
|
+
})).toRenderTo({
|
|
425
|
+
"test.py": `
|
|
397
426
|
#!/usr/bin/env python3
|
|
398
427
|
|
|
399
|
-
x = 42`
|
|
428
|
+
x = 42`
|
|
429
|
+
});
|
|
400
430
|
});
|
|
401
431
|
it("only futureImports before definition", () => {
|
|
402
|
-
|
|
403
|
-
path: "test.py",
|
|
404
|
-
get futureImports() {
|
|
405
|
-
return [_$createComponent(py.FutureStatement, {
|
|
406
|
-
feature: "annotations"
|
|
407
|
-
})];
|
|
408
|
-
},
|
|
432
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
409
433
|
get children() {
|
|
410
|
-
return _$createComponent(py.
|
|
411
|
-
|
|
412
|
-
|
|
434
|
+
return _$createComponent(py.SourceFile, {
|
|
435
|
+
path: "test.py",
|
|
436
|
+
get futureImports() {
|
|
437
|
+
return [_$createComponent(py.FutureStatement, {
|
|
438
|
+
feature: "annotations"
|
|
439
|
+
})];
|
|
440
|
+
},
|
|
441
|
+
get children() {
|
|
442
|
+
return _$createComponent(py.FunctionDeclaration, {
|
|
443
|
+
name: "hello",
|
|
444
|
+
children: "pass"
|
|
445
|
+
});
|
|
446
|
+
}
|
|
413
447
|
});
|
|
414
448
|
}
|
|
415
|
-
})
|
|
416
|
-
|
|
449
|
+
})).toRenderTo({
|
|
450
|
+
"test.py": `
|
|
417
451
|
from __future__ import annotations
|
|
418
452
|
|
|
419
453
|
|
|
420
454
|
def hello():
|
|
421
455
|
pass
|
|
422
456
|
|
|
423
|
-
|
|
424
|
-
|
|
457
|
+
`
|
|
458
|
+
});
|
|
425
459
|
});
|
|
426
460
|
it("only futureImports before non-definition", () => {
|
|
427
|
-
|
|
428
|
-
path: "test.py",
|
|
429
|
-
get futureImports() {
|
|
430
|
-
return [_$createComponent(py.FutureStatement, {
|
|
431
|
-
feature: "annotations"
|
|
432
|
-
})];
|
|
433
|
-
},
|
|
461
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
434
462
|
get children() {
|
|
435
|
-
return _$createComponent(py.
|
|
436
|
-
|
|
437
|
-
|
|
463
|
+
return _$createComponent(py.SourceFile, {
|
|
464
|
+
path: "test.py",
|
|
465
|
+
get futureImports() {
|
|
466
|
+
return [_$createComponent(py.FutureStatement, {
|
|
467
|
+
feature: "annotations"
|
|
468
|
+
})];
|
|
469
|
+
},
|
|
470
|
+
get children() {
|
|
471
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
472
|
+
name: "x",
|
|
473
|
+
initializer: 42
|
|
474
|
+
});
|
|
475
|
+
}
|
|
438
476
|
});
|
|
439
477
|
}
|
|
440
|
-
})
|
|
441
|
-
|
|
478
|
+
})).toRenderTo({
|
|
479
|
+
"test.py": `
|
|
442
480
|
from __future__ import annotations
|
|
443
481
|
|
|
444
|
-
x = 42`
|
|
482
|
+
x = 42`
|
|
483
|
+
});
|
|
445
484
|
});
|
|
446
485
|
it("only imports before definition", () => {
|
|
447
|
-
|
|
448
|
-
|
|
486
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
487
|
+
externals: [dataclassesModule],
|
|
449
488
|
get children() {
|
|
450
|
-
return _$createComponent(py.
|
|
451
|
-
|
|
489
|
+
return _$createComponent(py.SourceFile, {
|
|
490
|
+
path: "test.py",
|
|
452
491
|
get children() {
|
|
453
|
-
return _$createComponent(py.
|
|
454
|
-
name: "
|
|
455
|
-
|
|
492
|
+
return _$createComponent(py.DataclassDeclaration, {
|
|
493
|
+
name: "User",
|
|
494
|
+
get children() {
|
|
495
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
496
|
+
name: "name",
|
|
497
|
+
type: "str"
|
|
498
|
+
});
|
|
499
|
+
}
|
|
456
500
|
});
|
|
457
501
|
}
|
|
458
502
|
});
|
|
459
503
|
}
|
|
460
|
-
})
|
|
461
|
-
|
|
462
|
-
externals: [dataclassesModule]
|
|
463
|
-
})).toRenderTo(d`
|
|
504
|
+
})).toRenderTo({
|
|
505
|
+
"test.py": `
|
|
464
506
|
from dataclasses import dataclass
|
|
465
507
|
|
|
466
508
|
|
|
@@ -468,31 +510,35 @@ it("only imports before definition", () => {
|
|
|
468
510
|
class User:
|
|
469
511
|
name: str = None
|
|
470
512
|
|
|
471
|
-
|
|
472
|
-
|
|
513
|
+
`
|
|
514
|
+
});
|
|
473
515
|
});
|
|
474
516
|
it("only imports before non-definition", () => {
|
|
475
|
-
|
|
476
|
-
|
|
517
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
518
|
+
externals: [dataclassesModule],
|
|
477
519
|
get children() {
|
|
478
|
-
return _$createComponent(py.
|
|
479
|
-
|
|
480
|
-
get
|
|
481
|
-
return _$createComponent(py.
|
|
482
|
-
|
|
483
|
-
|
|
520
|
+
return _$createComponent(py.SourceFile, {
|
|
521
|
+
path: "test.py",
|
|
522
|
+
get children() {
|
|
523
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
524
|
+
name: "x",
|
|
525
|
+
get initializer() {
|
|
526
|
+
return _$createComponent(py.Reference, {
|
|
527
|
+
get refkey() {
|
|
528
|
+
return dataclassesModule["."].dataclass;
|
|
529
|
+
}
|
|
530
|
+
});
|
|
484
531
|
}
|
|
485
532
|
});
|
|
486
533
|
}
|
|
487
534
|
});
|
|
488
535
|
}
|
|
489
|
-
})
|
|
490
|
-
|
|
491
|
-
externals: [dataclassesModule]
|
|
492
|
-
})).toRenderTo(d`
|
|
536
|
+
})).toRenderTo({
|
|
537
|
+
"test.py": `
|
|
493
538
|
from dataclasses import dataclass
|
|
494
539
|
|
|
495
|
-
x = dataclass`
|
|
540
|
+
x = dataclass`
|
|
541
|
+
});
|
|
496
542
|
});
|
|
497
543
|
it("doc + futureImports before definition", () => {
|
|
498
544
|
const moduleDoc = _$createComponent(py.ModuleDoc, {
|
|
@@ -502,22 +548,26 @@ it("doc + futureImports before definition", () => {
|
|
|
502
548
|
})];
|
|
503
549
|
}
|
|
504
550
|
});
|
|
505
|
-
|
|
506
|
-
path: "test.py",
|
|
507
|
-
doc: moduleDoc,
|
|
508
|
-
get futureImports() {
|
|
509
|
-
return [_$createComponent(py.FutureStatement, {
|
|
510
|
-
feature: "annotations"
|
|
511
|
-
})];
|
|
512
|
-
},
|
|
551
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
513
552
|
get children() {
|
|
514
|
-
return _$createComponent(py.
|
|
515
|
-
|
|
516
|
-
|
|
553
|
+
return _$createComponent(py.SourceFile, {
|
|
554
|
+
path: "test.py",
|
|
555
|
+
doc: moduleDoc,
|
|
556
|
+
get futureImports() {
|
|
557
|
+
return [_$createComponent(py.FutureStatement, {
|
|
558
|
+
feature: "annotations"
|
|
559
|
+
})];
|
|
560
|
+
},
|
|
561
|
+
get children() {
|
|
562
|
+
return _$createComponent(py.FunctionDeclaration, {
|
|
563
|
+
name: "hello",
|
|
564
|
+
children: "pass"
|
|
565
|
+
});
|
|
566
|
+
}
|
|
517
567
|
});
|
|
518
568
|
}
|
|
519
|
-
})
|
|
520
|
-
|
|
569
|
+
})).toRenderTo({
|
|
570
|
+
"test.py": `
|
|
521
571
|
"""
|
|
522
572
|
Module description.
|
|
523
573
|
"""
|
|
@@ -528,8 +578,8 @@ it("doc + futureImports before definition", () => {
|
|
|
528
578
|
def hello():
|
|
529
579
|
pass
|
|
530
580
|
|
|
531
|
-
|
|
532
|
-
|
|
581
|
+
`
|
|
582
|
+
});
|
|
533
583
|
});
|
|
534
584
|
it("doc + futureImports before non-definition", () => {
|
|
535
585
|
const moduleDoc = _$createComponent(py.ModuleDoc, {
|
|
@@ -539,29 +589,34 @@ it("doc + futureImports before non-definition", () => {
|
|
|
539
589
|
})];
|
|
540
590
|
}
|
|
541
591
|
});
|
|
542
|
-
|
|
543
|
-
path: "test.py",
|
|
544
|
-
doc: moduleDoc,
|
|
545
|
-
get futureImports() {
|
|
546
|
-
return [_$createComponent(py.FutureStatement, {
|
|
547
|
-
feature: "annotations"
|
|
548
|
-
})];
|
|
549
|
-
},
|
|
592
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
550
593
|
get children() {
|
|
551
|
-
return _$createComponent(py.
|
|
552
|
-
|
|
553
|
-
|
|
594
|
+
return _$createComponent(py.SourceFile, {
|
|
595
|
+
path: "test.py",
|
|
596
|
+
doc: moduleDoc,
|
|
597
|
+
get futureImports() {
|
|
598
|
+
return [_$createComponent(py.FutureStatement, {
|
|
599
|
+
feature: "annotations"
|
|
600
|
+
})];
|
|
601
|
+
},
|
|
602
|
+
get children() {
|
|
603
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
604
|
+
name: "x",
|
|
605
|
+
initializer: 42
|
|
606
|
+
});
|
|
607
|
+
}
|
|
554
608
|
});
|
|
555
609
|
}
|
|
556
|
-
})
|
|
557
|
-
|
|
610
|
+
})).toRenderTo({
|
|
611
|
+
"test.py": `
|
|
558
612
|
"""
|
|
559
613
|
Module description.
|
|
560
614
|
"""
|
|
561
615
|
|
|
562
616
|
from __future__ import annotations
|
|
563
617
|
|
|
564
|
-
x = 42`
|
|
618
|
+
x = 42`
|
|
619
|
+
});
|
|
565
620
|
});
|
|
566
621
|
it("doc + imports before definition", () => {
|
|
567
622
|
const moduleDoc = _$createComponent(py.ModuleDoc, {
|
|
@@ -571,24 +626,27 @@ it("doc + imports before definition", () => {
|
|
|
571
626
|
})];
|
|
572
627
|
}
|
|
573
628
|
});
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
doc: moduleDoc,
|
|
629
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
630
|
+
externals: [dataclassesModule],
|
|
577
631
|
get children() {
|
|
578
|
-
return _$createComponent(py.
|
|
579
|
-
|
|
632
|
+
return _$createComponent(py.SourceFile, {
|
|
633
|
+
path: "test.py",
|
|
634
|
+
doc: moduleDoc,
|
|
580
635
|
get children() {
|
|
581
|
-
return _$createComponent(py.
|
|
582
|
-
name: "
|
|
583
|
-
|
|
636
|
+
return _$createComponent(py.DataclassDeclaration, {
|
|
637
|
+
name: "User",
|
|
638
|
+
get children() {
|
|
639
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
640
|
+
name: "name",
|
|
641
|
+
type: "str"
|
|
642
|
+
});
|
|
643
|
+
}
|
|
584
644
|
});
|
|
585
645
|
}
|
|
586
646
|
});
|
|
587
647
|
}
|
|
588
|
-
})
|
|
589
|
-
|
|
590
|
-
externals: [dataclassesModule]
|
|
591
|
-
})).toRenderTo(d`
|
|
648
|
+
})).toRenderTo({
|
|
649
|
+
"test.py": `
|
|
592
650
|
"""
|
|
593
651
|
Module description.
|
|
594
652
|
"""
|
|
@@ -600,8 +658,8 @@ it("doc + imports before definition", () => {
|
|
|
600
658
|
class User:
|
|
601
659
|
name: str = None
|
|
602
660
|
|
|
603
|
-
|
|
604
|
-
|
|
661
|
+
`
|
|
662
|
+
});
|
|
605
663
|
});
|
|
606
664
|
it("doc + imports before non-definition", () => {
|
|
607
665
|
const moduleDoc = _$createComponent(py.ModuleDoc, {
|
|
@@ -611,56 +669,63 @@ it("doc + imports before non-definition", () => {
|
|
|
611
669
|
})];
|
|
612
670
|
}
|
|
613
671
|
});
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
doc: moduleDoc,
|
|
672
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
673
|
+
externals: [dataclassesModule],
|
|
617
674
|
get children() {
|
|
618
|
-
return _$createComponent(py.
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
675
|
+
return _$createComponent(py.SourceFile, {
|
|
676
|
+
path: "test.py",
|
|
677
|
+
doc: moduleDoc,
|
|
678
|
+
get children() {
|
|
679
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
680
|
+
name: "x",
|
|
681
|
+
get initializer() {
|
|
682
|
+
return _$createComponent(py.Reference, {
|
|
683
|
+
get refkey() {
|
|
684
|
+
return dataclassesModule["."].dataclass;
|
|
685
|
+
}
|
|
686
|
+
});
|
|
624
687
|
}
|
|
625
688
|
});
|
|
626
689
|
}
|
|
627
690
|
});
|
|
628
691
|
}
|
|
629
|
-
})
|
|
630
|
-
|
|
631
|
-
externals: [dataclassesModule]
|
|
632
|
-
})).toRenderTo(d`
|
|
692
|
+
})).toRenderTo({
|
|
693
|
+
"test.py": `
|
|
633
694
|
"""
|
|
634
695
|
Module description.
|
|
635
696
|
"""
|
|
636
697
|
|
|
637
698
|
from dataclasses import dataclass
|
|
638
699
|
|
|
639
|
-
x = dataclass`
|
|
700
|
+
x = dataclass`
|
|
701
|
+
});
|
|
640
702
|
});
|
|
641
703
|
it("futureImports + imports before definition", () => {
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
get futureImports() {
|
|
645
|
-
return [_$createComponent(py.FutureStatement, {
|
|
646
|
-
feature: "annotations"
|
|
647
|
-
})];
|
|
648
|
-
},
|
|
704
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
705
|
+
externals: [dataclassesModule],
|
|
649
706
|
get children() {
|
|
650
|
-
return _$createComponent(py.
|
|
651
|
-
|
|
707
|
+
return _$createComponent(py.SourceFile, {
|
|
708
|
+
path: "test.py",
|
|
709
|
+
get futureImports() {
|
|
710
|
+
return [_$createComponent(py.FutureStatement, {
|
|
711
|
+
feature: "annotations"
|
|
712
|
+
})];
|
|
713
|
+
},
|
|
652
714
|
get children() {
|
|
653
|
-
return _$createComponent(py.
|
|
654
|
-
name: "
|
|
655
|
-
|
|
715
|
+
return _$createComponent(py.DataclassDeclaration, {
|
|
716
|
+
name: "User",
|
|
717
|
+
get children() {
|
|
718
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
719
|
+
name: "name",
|
|
720
|
+
type: "str"
|
|
721
|
+
});
|
|
722
|
+
}
|
|
656
723
|
});
|
|
657
724
|
}
|
|
658
725
|
});
|
|
659
726
|
}
|
|
660
|
-
})
|
|
661
|
-
|
|
662
|
-
externals: [dataclassesModule]
|
|
663
|
-
})).toRenderTo(d`
|
|
727
|
+
})).toRenderTo({
|
|
728
|
+
"test.py": `
|
|
664
729
|
from __future__ import annotations
|
|
665
730
|
|
|
666
731
|
from dataclasses import dataclass
|
|
@@ -670,38 +735,42 @@ it("futureImports + imports before definition", () => {
|
|
|
670
735
|
class User:
|
|
671
736
|
name: str = None
|
|
672
737
|
|
|
673
|
-
|
|
674
|
-
|
|
738
|
+
`
|
|
739
|
+
});
|
|
675
740
|
});
|
|
676
741
|
it("futureImports + imports before non-definition", () => {
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
get futureImports() {
|
|
680
|
-
return [_$createComponent(py.FutureStatement, {
|
|
681
|
-
feature: "annotations"
|
|
682
|
-
})];
|
|
683
|
-
},
|
|
742
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
743
|
+
externals: [dataclassesModule],
|
|
684
744
|
get children() {
|
|
685
|
-
return _$createComponent(py.
|
|
686
|
-
|
|
687
|
-
get
|
|
688
|
-
return _$createComponent(py.
|
|
689
|
-
|
|
690
|
-
|
|
745
|
+
return _$createComponent(py.SourceFile, {
|
|
746
|
+
path: "test.py",
|
|
747
|
+
get futureImports() {
|
|
748
|
+
return [_$createComponent(py.FutureStatement, {
|
|
749
|
+
feature: "annotations"
|
|
750
|
+
})];
|
|
751
|
+
},
|
|
752
|
+
get children() {
|
|
753
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
754
|
+
name: "x",
|
|
755
|
+
get initializer() {
|
|
756
|
+
return _$createComponent(py.Reference, {
|
|
757
|
+
get refkey() {
|
|
758
|
+
return dataclassesModule["."].dataclass;
|
|
759
|
+
}
|
|
760
|
+
});
|
|
691
761
|
}
|
|
692
762
|
});
|
|
693
763
|
}
|
|
694
764
|
});
|
|
695
765
|
}
|
|
696
|
-
})
|
|
697
|
-
|
|
698
|
-
externals: [dataclassesModule]
|
|
699
|
-
})).toRenderTo(d`
|
|
766
|
+
})).toRenderTo({
|
|
767
|
+
"test.py": `
|
|
700
768
|
from __future__ import annotations
|
|
701
769
|
|
|
702
770
|
from dataclasses import dataclass
|
|
703
771
|
|
|
704
|
-
x = dataclass`
|
|
772
|
+
x = dataclass`
|
|
773
|
+
});
|
|
705
774
|
});
|
|
706
775
|
it("doc + futureImports + imports before definition", () => {
|
|
707
776
|
const moduleDoc = _$createComponent(py.ModuleDoc, {
|
|
@@ -711,29 +780,32 @@ it("doc + futureImports + imports before definition", () => {
|
|
|
711
780
|
})];
|
|
712
781
|
}
|
|
713
782
|
});
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
doc: moduleDoc,
|
|
717
|
-
get futureImports() {
|
|
718
|
-
return [_$createComponent(py.FutureStatement, {
|
|
719
|
-
feature: "annotations"
|
|
720
|
-
})];
|
|
721
|
-
},
|
|
783
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
784
|
+
externals: [dataclassesModule],
|
|
722
785
|
get children() {
|
|
723
|
-
return _$createComponent(py.
|
|
724
|
-
|
|
786
|
+
return _$createComponent(py.SourceFile, {
|
|
787
|
+
path: "test.py",
|
|
788
|
+
doc: moduleDoc,
|
|
789
|
+
get futureImports() {
|
|
790
|
+
return [_$createComponent(py.FutureStatement, {
|
|
791
|
+
feature: "annotations"
|
|
792
|
+
})];
|
|
793
|
+
},
|
|
725
794
|
get children() {
|
|
726
|
-
return _$createComponent(py.
|
|
727
|
-
name: "
|
|
728
|
-
|
|
795
|
+
return _$createComponent(py.DataclassDeclaration, {
|
|
796
|
+
name: "User",
|
|
797
|
+
get children() {
|
|
798
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
799
|
+
name: "name",
|
|
800
|
+
type: "str"
|
|
801
|
+
});
|
|
802
|
+
}
|
|
729
803
|
});
|
|
730
804
|
}
|
|
731
805
|
});
|
|
732
806
|
}
|
|
733
|
-
})
|
|
734
|
-
|
|
735
|
-
externals: [dataclassesModule]
|
|
736
|
-
})).toRenderTo(d`
|
|
807
|
+
})).toRenderTo({
|
|
808
|
+
"test.py": `
|
|
737
809
|
"""
|
|
738
810
|
Module description.
|
|
739
811
|
"""
|
|
@@ -747,8 +819,8 @@ it("doc + futureImports + imports before definition", () => {
|
|
|
747
819
|
class User:
|
|
748
820
|
name: str = None
|
|
749
821
|
|
|
750
|
-
|
|
751
|
-
|
|
822
|
+
`
|
|
823
|
+
});
|
|
752
824
|
});
|
|
753
825
|
it("doc + futureImports + imports before non-definition", () => {
|
|
754
826
|
const moduleDoc = _$createComponent(py.ModuleDoc, {
|
|
@@ -758,30 +830,33 @@ it("doc + futureImports + imports before non-definition", () => {
|
|
|
758
830
|
})];
|
|
759
831
|
}
|
|
760
832
|
});
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
doc: moduleDoc,
|
|
764
|
-
get futureImports() {
|
|
765
|
-
return [_$createComponent(py.FutureStatement, {
|
|
766
|
-
feature: "annotations"
|
|
767
|
-
})];
|
|
768
|
-
},
|
|
833
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
834
|
+
externals: [dataclassesModule],
|
|
769
835
|
get children() {
|
|
770
|
-
return _$createComponent(py.
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
836
|
+
return _$createComponent(py.SourceFile, {
|
|
837
|
+
path: "test.py",
|
|
838
|
+
doc: moduleDoc,
|
|
839
|
+
get futureImports() {
|
|
840
|
+
return [_$createComponent(py.FutureStatement, {
|
|
841
|
+
feature: "annotations"
|
|
842
|
+
})];
|
|
843
|
+
},
|
|
844
|
+
get children() {
|
|
845
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
846
|
+
name: "x",
|
|
847
|
+
get initializer() {
|
|
848
|
+
return _$createComponent(py.Reference, {
|
|
849
|
+
get refkey() {
|
|
850
|
+
return dataclassesModule["."].dataclass;
|
|
851
|
+
}
|
|
852
|
+
});
|
|
776
853
|
}
|
|
777
854
|
});
|
|
778
855
|
}
|
|
779
856
|
});
|
|
780
857
|
}
|
|
781
|
-
})
|
|
782
|
-
|
|
783
|
-
externals: [dataclassesModule]
|
|
784
|
-
})).toRenderTo(d`
|
|
858
|
+
})).toRenderTo({
|
|
859
|
+
"test.py": `
|
|
785
860
|
"""
|
|
786
861
|
Module description.
|
|
787
862
|
"""
|
|
@@ -790,7 +865,8 @@ it("doc + futureImports + imports before non-definition", () => {
|
|
|
790
865
|
|
|
791
866
|
from dataclasses import dataclass
|
|
792
867
|
|
|
793
|
-
x = dataclass`
|
|
868
|
+
x = dataclass`
|
|
869
|
+
});
|
|
794
870
|
});
|
|
795
871
|
it("only doc in file (no children)", () => {
|
|
796
872
|
const moduleDoc = _$createComponent(py.ModuleDoc, {
|
|
@@ -800,42 +876,52 @@ it("only doc in file (no children)", () => {
|
|
|
800
876
|
})];
|
|
801
877
|
}
|
|
802
878
|
});
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
879
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
880
|
+
get children() {
|
|
881
|
+
return _$createComponent(py.SourceFile, {
|
|
882
|
+
path: "test.py",
|
|
883
|
+
doc: moduleDoc
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
})).toRenderTo({
|
|
887
|
+
"test.py": `
|
|
808
888
|
"""
|
|
809
889
|
Module description.
|
|
810
890
|
"""
|
|
811
891
|
|
|
812
|
-
|
|
813
|
-
|
|
892
|
+
`
|
|
893
|
+
});
|
|
814
894
|
});
|
|
815
895
|
it("only header in file (no children)", () => {
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
896
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
897
|
+
get children() {
|
|
898
|
+
return _$createComponent(py.SourceFile, {
|
|
899
|
+
path: "test.py",
|
|
900
|
+
header: "#!/usr/bin/env python3"
|
|
901
|
+
});
|
|
902
|
+
}
|
|
903
|
+
})).toRenderTo({
|
|
904
|
+
"test.py": `
|
|
821
905
|
#!/usr/bin/env python3
|
|
822
906
|
|
|
823
|
-
|
|
824
|
-
|
|
907
|
+
`
|
|
908
|
+
});
|
|
825
909
|
});
|
|
826
910
|
it("only futureImports in file (no children)", () => {
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
911
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
912
|
+
get children() {
|
|
913
|
+
return _$createComponent(py.SourceFile, {
|
|
914
|
+
path: "test.py",
|
|
915
|
+
get futureImports() {
|
|
916
|
+
return [_$createComponent(py.FutureStatement, {
|
|
917
|
+
feature: "annotations"
|
|
918
|
+
})];
|
|
919
|
+
}
|
|
920
|
+
});
|
|
833
921
|
}
|
|
922
|
+
})).toRenderTo({
|
|
923
|
+
"test.py": "from __future__ import annotations"
|
|
834
924
|
});
|
|
835
|
-
expect(toSourceText(content)).toRenderTo(d`
|
|
836
|
-
from __future__ import annotations
|
|
837
|
-
|
|
838
|
-
`);
|
|
839
925
|
});
|
|
840
926
|
it("doc + futureImports in file (no children)", () => {
|
|
841
927
|
const moduleDoc = _$createComponent(py.ModuleDoc, {
|
|
@@ -845,64 +931,75 @@ it("doc + futureImports in file (no children)", () => {
|
|
|
845
931
|
})];
|
|
846
932
|
}
|
|
847
933
|
});
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
934
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
935
|
+
get children() {
|
|
936
|
+
return _$createComponent(py.SourceFile, {
|
|
937
|
+
path: "test.py",
|
|
938
|
+
doc: moduleDoc,
|
|
939
|
+
get futureImports() {
|
|
940
|
+
return [_$createComponent(py.FutureStatement, {
|
|
941
|
+
feature: "annotations"
|
|
942
|
+
})];
|
|
943
|
+
}
|
|
944
|
+
});
|
|
855
945
|
}
|
|
856
|
-
})
|
|
857
|
-
|
|
946
|
+
})).toRenderTo({
|
|
947
|
+
"test.py": `
|
|
858
948
|
"""
|
|
859
949
|
Module description.
|
|
860
950
|
"""
|
|
861
951
|
|
|
862
952
|
from __future__ import annotations
|
|
863
|
-
|
|
864
|
-
|
|
953
|
+
`
|
|
954
|
+
});
|
|
865
955
|
});
|
|
866
956
|
|
|
867
957
|
// headerComment tests
|
|
868
958
|
it("only headerComment before definition", () => {
|
|
869
|
-
|
|
870
|
-
path: "test.py",
|
|
871
|
-
headerComment: "Copyright 2024 My Company",
|
|
959
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
872
960
|
get children() {
|
|
873
|
-
return _$createComponent(py.
|
|
874
|
-
|
|
875
|
-
|
|
961
|
+
return _$createComponent(py.SourceFile, {
|
|
962
|
+
path: "test.py",
|
|
963
|
+
headerComment: "Copyright 2024 My Company",
|
|
964
|
+
get children() {
|
|
965
|
+
return _$createComponent(py.FunctionDeclaration, {
|
|
966
|
+
name: "hello",
|
|
967
|
+
children: "pass"
|
|
968
|
+
});
|
|
969
|
+
}
|
|
876
970
|
});
|
|
877
971
|
}
|
|
878
|
-
})
|
|
879
|
-
|
|
880
|
-
// 2 blank lines before definition (PEP 8)
|
|
881
|
-
expect(toSourceText(content)).toRenderTo(d`
|
|
972
|
+
})).toRenderTo({
|
|
973
|
+
"test.py": `
|
|
882
974
|
# Copyright 2024 My Company
|
|
883
975
|
|
|
884
976
|
|
|
885
977
|
def hello():
|
|
886
978
|
pass
|
|
887
979
|
|
|
888
|
-
|
|
889
|
-
|
|
980
|
+
`
|
|
981
|
+
});
|
|
890
982
|
});
|
|
891
983
|
it("only headerComment before non-definition", () => {
|
|
892
|
-
|
|
893
|
-
path: "test.py",
|
|
894
|
-
headerComment: "Copyright 2024 My Company",
|
|
984
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
895
985
|
get children() {
|
|
896
|
-
return _$createComponent(py.
|
|
897
|
-
|
|
898
|
-
|
|
986
|
+
return _$createComponent(py.SourceFile, {
|
|
987
|
+
path: "test.py",
|
|
988
|
+
headerComment: "Copyright 2024 My Company",
|
|
989
|
+
get children() {
|
|
990
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
991
|
+
name: "x",
|
|
992
|
+
initializer: 42
|
|
993
|
+
});
|
|
994
|
+
}
|
|
899
995
|
});
|
|
900
996
|
}
|
|
901
|
-
})
|
|
902
|
-
|
|
997
|
+
})).toRenderTo({
|
|
998
|
+
"test.py": `
|
|
903
999
|
# Copyright 2024 My Company
|
|
904
1000
|
|
|
905
|
-
x = 42`
|
|
1001
|
+
x = 42`
|
|
1002
|
+
});
|
|
906
1003
|
});
|
|
907
1004
|
it("headerComment + doc before definition", () => {
|
|
908
1005
|
const moduleDoc = _$createComponent(py.ModuleDoc, {
|
|
@@ -912,20 +1009,22 @@ it("headerComment + doc before definition", () => {
|
|
|
912
1009
|
})];
|
|
913
1010
|
}
|
|
914
1011
|
});
|
|
915
|
-
|
|
916
|
-
path: "test.py",
|
|
917
|
-
headerComment: "Copyright 2024 My Company",
|
|
918
|
-
doc: moduleDoc,
|
|
1012
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
919
1013
|
get children() {
|
|
920
|
-
return _$createComponent(py.
|
|
921
|
-
|
|
922
|
-
|
|
1014
|
+
return _$createComponent(py.SourceFile, {
|
|
1015
|
+
path: "test.py",
|
|
1016
|
+
headerComment: "Copyright 2024 My Company",
|
|
1017
|
+
doc: moduleDoc,
|
|
1018
|
+
get children() {
|
|
1019
|
+
return _$createComponent(py.FunctionDeclaration, {
|
|
1020
|
+
name: "hello",
|
|
1021
|
+
children: "pass"
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
923
1024
|
});
|
|
924
1025
|
}
|
|
925
|
-
})
|
|
926
|
-
|
|
927
|
-
// headerComment and doc adjacent, then PEP 8 spacing before definition
|
|
928
|
-
expect(toSourceText(content)).toRenderTo(d`
|
|
1026
|
+
})).toRenderTo({
|
|
1027
|
+
"test.py": `
|
|
929
1028
|
# Copyright 2024 My Company
|
|
930
1029
|
"""
|
|
931
1030
|
Module description.
|
|
@@ -935,28 +1034,30 @@ it("headerComment + doc before definition", () => {
|
|
|
935
1034
|
def hello():
|
|
936
1035
|
pass
|
|
937
1036
|
|
|
938
|
-
|
|
939
|
-
|
|
1037
|
+
`
|
|
1038
|
+
});
|
|
940
1039
|
});
|
|
941
1040
|
it("headerComment + futureImports before definition", () => {
|
|
942
|
-
|
|
943
|
-
path: "test.py",
|
|
944
|
-
headerComment: "Copyright 2024 My Company",
|
|
945
|
-
get futureImports() {
|
|
946
|
-
return [_$createComponent(py.FutureStatement, {
|
|
947
|
-
feature: "annotations"
|
|
948
|
-
})];
|
|
949
|
-
},
|
|
1041
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
950
1042
|
get children() {
|
|
951
|
-
return _$createComponent(py.
|
|
952
|
-
|
|
953
|
-
|
|
1043
|
+
return _$createComponent(py.SourceFile, {
|
|
1044
|
+
path: "test.py",
|
|
1045
|
+
headerComment: "Copyright 2024 My Company",
|
|
1046
|
+
get futureImports() {
|
|
1047
|
+
return [_$createComponent(py.FutureStatement, {
|
|
1048
|
+
feature: "annotations"
|
|
1049
|
+
})];
|
|
1050
|
+
},
|
|
1051
|
+
get children() {
|
|
1052
|
+
return _$createComponent(py.FunctionDeclaration, {
|
|
1053
|
+
name: "hello",
|
|
1054
|
+
children: "pass"
|
|
1055
|
+
});
|
|
1056
|
+
}
|
|
954
1057
|
});
|
|
955
1058
|
}
|
|
956
|
-
})
|
|
957
|
-
|
|
958
|
-
// headerComment and futureImports adjacent, then PEP 8 spacing
|
|
959
|
-
expect(toSourceText(content)).toRenderTo(d`
|
|
1059
|
+
})).toRenderTo({
|
|
1060
|
+
"test.py": `
|
|
960
1061
|
# Copyright 2024 My Company
|
|
961
1062
|
|
|
962
1063
|
from __future__ import annotations
|
|
@@ -965,28 +1066,31 @@ it("headerComment + futureImports before definition", () => {
|
|
|
965
1066
|
def hello():
|
|
966
1067
|
pass
|
|
967
1068
|
|
|
968
|
-
|
|
969
|
-
|
|
1069
|
+
`
|
|
1070
|
+
});
|
|
970
1071
|
});
|
|
971
1072
|
it("headerComment + imports before definition", () => {
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
headerComment: "Copyright 2024 My Company",
|
|
1073
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
1074
|
+
externals: [dataclassesModule],
|
|
975
1075
|
get children() {
|
|
976
|
-
return _$createComponent(py.
|
|
977
|
-
|
|
1076
|
+
return _$createComponent(py.SourceFile, {
|
|
1077
|
+
path: "test.py",
|
|
1078
|
+
headerComment: "Copyright 2024 My Company",
|
|
978
1079
|
get children() {
|
|
979
|
-
return _$createComponent(py.
|
|
980
|
-
name: "
|
|
981
|
-
|
|
1080
|
+
return _$createComponent(py.DataclassDeclaration, {
|
|
1081
|
+
name: "User",
|
|
1082
|
+
get children() {
|
|
1083
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
1084
|
+
name: "name",
|
|
1085
|
+
type: "str"
|
|
1086
|
+
});
|
|
1087
|
+
}
|
|
982
1088
|
});
|
|
983
1089
|
}
|
|
984
1090
|
});
|
|
985
1091
|
}
|
|
986
|
-
})
|
|
987
|
-
|
|
988
|
-
externals: [dataclassesModule]
|
|
989
|
-
})).toRenderTo(d`
|
|
1092
|
+
})).toRenderTo({
|
|
1093
|
+
"test.py": `
|
|
990
1094
|
# Copyright 2024 My Company
|
|
991
1095
|
|
|
992
1096
|
from dataclasses import dataclass
|
|
@@ -996,8 +1100,8 @@ it("headerComment + imports before definition", () => {
|
|
|
996
1100
|
class User:
|
|
997
1101
|
name: str = None
|
|
998
1102
|
|
|
999
|
-
|
|
1000
|
-
|
|
1103
|
+
`
|
|
1104
|
+
});
|
|
1001
1105
|
});
|
|
1002
1106
|
it("headerComment + doc + futureImports before definition", () => {
|
|
1003
1107
|
const moduleDoc = _$createComponent(py.ModuleDoc, {
|
|
@@ -1007,23 +1111,27 @@ it("headerComment + doc + futureImports before definition", () => {
|
|
|
1007
1111
|
})];
|
|
1008
1112
|
}
|
|
1009
1113
|
});
|
|
1010
|
-
|
|
1011
|
-
path: "test.py",
|
|
1012
|
-
headerComment: "Copyright 2024 My Company",
|
|
1013
|
-
doc: moduleDoc,
|
|
1014
|
-
get futureImports() {
|
|
1015
|
-
return [_$createComponent(py.FutureStatement, {
|
|
1016
|
-
feature: "annotations"
|
|
1017
|
-
})];
|
|
1018
|
-
},
|
|
1114
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
1019
1115
|
get children() {
|
|
1020
|
-
return _$createComponent(py.
|
|
1021
|
-
|
|
1022
|
-
|
|
1116
|
+
return _$createComponent(py.SourceFile, {
|
|
1117
|
+
path: "test.py",
|
|
1118
|
+
headerComment: "Copyright 2024 My Company",
|
|
1119
|
+
doc: moduleDoc,
|
|
1120
|
+
get futureImports() {
|
|
1121
|
+
return [_$createComponent(py.FutureStatement, {
|
|
1122
|
+
feature: "annotations"
|
|
1123
|
+
})];
|
|
1124
|
+
},
|
|
1125
|
+
get children() {
|
|
1126
|
+
return _$createComponent(py.FunctionDeclaration, {
|
|
1127
|
+
name: "hello",
|
|
1128
|
+
children: "pass"
|
|
1129
|
+
});
|
|
1130
|
+
}
|
|
1023
1131
|
});
|
|
1024
1132
|
}
|
|
1025
|
-
})
|
|
1026
|
-
|
|
1133
|
+
})).toRenderTo({
|
|
1134
|
+
"test.py": `
|
|
1027
1135
|
# Copyright 2024 My Company
|
|
1028
1136
|
"""
|
|
1029
1137
|
Module description.
|
|
@@ -1035,8 +1143,8 @@ it("headerComment + doc + futureImports before definition", () => {
|
|
|
1035
1143
|
def hello():
|
|
1036
1144
|
pass
|
|
1037
1145
|
|
|
1038
|
-
|
|
1039
|
-
|
|
1146
|
+
`
|
|
1147
|
+
});
|
|
1040
1148
|
});
|
|
1041
1149
|
it("headerComment + doc + futureImports + imports before definition", () => {
|
|
1042
1150
|
const moduleDoc = _$createComponent(py.ModuleDoc, {
|
|
@@ -1046,30 +1154,33 @@ it("headerComment + doc + futureImports + imports before definition", () => {
|
|
|
1046
1154
|
})];
|
|
1047
1155
|
}
|
|
1048
1156
|
});
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
headerComment: "Copyright 2024 My Company",
|
|
1052
|
-
doc: moduleDoc,
|
|
1053
|
-
get futureImports() {
|
|
1054
|
-
return [_$createComponent(py.FutureStatement, {
|
|
1055
|
-
feature: "annotations"
|
|
1056
|
-
})];
|
|
1057
|
-
},
|
|
1157
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
1158
|
+
externals: [dataclassesModule],
|
|
1058
1159
|
get children() {
|
|
1059
|
-
return _$createComponent(py.
|
|
1060
|
-
|
|
1160
|
+
return _$createComponent(py.SourceFile, {
|
|
1161
|
+
path: "test.py",
|
|
1162
|
+
headerComment: "Copyright 2024 My Company",
|
|
1163
|
+
doc: moduleDoc,
|
|
1164
|
+
get futureImports() {
|
|
1165
|
+
return [_$createComponent(py.FutureStatement, {
|
|
1166
|
+
feature: "annotations"
|
|
1167
|
+
})];
|
|
1168
|
+
},
|
|
1061
1169
|
get children() {
|
|
1062
|
-
return _$createComponent(py.
|
|
1063
|
-
name: "
|
|
1064
|
-
|
|
1170
|
+
return _$createComponent(py.DataclassDeclaration, {
|
|
1171
|
+
name: "User",
|
|
1172
|
+
get children() {
|
|
1173
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
1174
|
+
name: "name",
|
|
1175
|
+
type: "str"
|
|
1176
|
+
});
|
|
1177
|
+
}
|
|
1065
1178
|
});
|
|
1066
1179
|
}
|
|
1067
1180
|
});
|
|
1068
1181
|
}
|
|
1069
|
-
})
|
|
1070
|
-
|
|
1071
|
-
externals: [dataclassesModule]
|
|
1072
|
-
})).toRenderTo(d`
|
|
1182
|
+
})).toRenderTo({
|
|
1183
|
+
"test.py": `
|
|
1073
1184
|
# Copyright 2024 My Company
|
|
1074
1185
|
"""
|
|
1075
1186
|
Module description.
|
|
@@ -1084,34 +1195,38 @@ it("headerComment + doc + futureImports + imports before definition", () => {
|
|
|
1084
1195
|
class User:
|
|
1085
1196
|
name: str = None
|
|
1086
1197
|
|
|
1087
|
-
|
|
1088
|
-
|
|
1198
|
+
`
|
|
1199
|
+
});
|
|
1089
1200
|
});
|
|
1090
1201
|
it("only headerComment in file (no children)", () => {
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1202
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
1203
|
+
get children() {
|
|
1204
|
+
return _$createComponent(py.SourceFile, {
|
|
1205
|
+
path: "test.py",
|
|
1206
|
+
headerComment: "Copyright 2024 My Company"
|
|
1207
|
+
});
|
|
1208
|
+
}
|
|
1209
|
+
})).toRenderTo({
|
|
1210
|
+
"test.py": "# Copyright 2024 My Company"
|
|
1094
1211
|
});
|
|
1095
|
-
expect(toSourceText(content)).toRenderTo(d`
|
|
1096
|
-
# Copyright 2024 My Company
|
|
1097
|
-
|
|
1098
|
-
`);
|
|
1099
1212
|
});
|
|
1100
1213
|
it("header + headerComment before definition", () => {
|
|
1101
|
-
|
|
1102
|
-
path: "test.py",
|
|
1103
|
-
header: "#!/usr/bin/env python3",
|
|
1104
|
-
headerComment: "Copyright 2024 My Company",
|
|
1214
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
1105
1215
|
get children() {
|
|
1106
|
-
return _$createComponent(py.
|
|
1107
|
-
|
|
1108
|
-
|
|
1216
|
+
return _$createComponent(py.SourceFile, {
|
|
1217
|
+
path: "test.py",
|
|
1218
|
+
header: "#!/usr/bin/env python3",
|
|
1219
|
+
headerComment: "Copyright 2024 My Company",
|
|
1220
|
+
get children() {
|
|
1221
|
+
return _$createComponent(py.FunctionDeclaration, {
|
|
1222
|
+
name: "hello",
|
|
1223
|
+
children: "pass"
|
|
1224
|
+
});
|
|
1225
|
+
}
|
|
1109
1226
|
});
|
|
1110
1227
|
}
|
|
1111
|
-
})
|
|
1112
|
-
|
|
1113
|
-
// 2 blank lines before definition (PEP 8)
|
|
1114
|
-
expect(toSourceText(content)).toRenderTo(d`
|
|
1228
|
+
})).toRenderTo({
|
|
1229
|
+
"test.py": `
|
|
1115
1230
|
#!/usr/bin/env python3
|
|
1116
1231
|
# Copyright 2024 My Company
|
|
1117
1232
|
|
|
@@ -1119,24 +1234,26 @@ it("header + headerComment before definition", () => {
|
|
|
1119
1234
|
def hello():
|
|
1120
1235
|
pass
|
|
1121
1236
|
|
|
1122
|
-
|
|
1123
|
-
|
|
1237
|
+
`
|
|
1238
|
+
});
|
|
1124
1239
|
});
|
|
1125
1240
|
it("header + headerComment before class definition", () => {
|
|
1126
|
-
|
|
1127
|
-
path: "test.py",
|
|
1128
|
-
header: "#!/usr/bin/env python3",
|
|
1129
|
-
headerComment: "Copyright 2024 My Company",
|
|
1241
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
1130
1242
|
get children() {
|
|
1131
|
-
return _$createComponent(py.
|
|
1132
|
-
|
|
1133
|
-
|
|
1243
|
+
return _$createComponent(py.SourceFile, {
|
|
1244
|
+
path: "test.py",
|
|
1245
|
+
header: "#!/usr/bin/env python3",
|
|
1246
|
+
headerComment: "Copyright 2024 My Company",
|
|
1247
|
+
get children() {
|
|
1248
|
+
return _$createComponent(py.ClassDeclaration, {
|
|
1249
|
+
name: "MyClass",
|
|
1250
|
+
children: "pass"
|
|
1251
|
+
});
|
|
1252
|
+
}
|
|
1134
1253
|
});
|
|
1135
1254
|
}
|
|
1136
|
-
})
|
|
1137
|
-
|
|
1138
|
-
// 2 blank lines before definition (PEP 8)
|
|
1139
|
-
expect(toSourceText(content)).toRenderTo(d`
|
|
1255
|
+
})).toRenderTo({
|
|
1256
|
+
"test.py": `
|
|
1140
1257
|
#!/usr/bin/env python3
|
|
1141
1258
|
# Copyright 2024 My Company
|
|
1142
1259
|
|
|
@@ -1144,27 +1261,30 @@ it("header + headerComment before class definition", () => {
|
|
|
1144
1261
|
class MyClass:
|
|
1145
1262
|
pass
|
|
1146
1263
|
|
|
1147
|
-
|
|
1148
|
-
|
|
1264
|
+
`
|
|
1265
|
+
});
|
|
1149
1266
|
});
|
|
1150
1267
|
it("header + headerComment before non-definition", () => {
|
|
1151
|
-
|
|
1152
|
-
path: "test.py",
|
|
1153
|
-
header: "#!/usr/bin/env python3",
|
|
1154
|
-
headerComment: "Copyright 2024 My Company",
|
|
1268
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
1155
1269
|
get children() {
|
|
1156
|
-
return _$createComponent(py.
|
|
1157
|
-
|
|
1158
|
-
|
|
1270
|
+
return _$createComponent(py.SourceFile, {
|
|
1271
|
+
path: "test.py",
|
|
1272
|
+
header: "#!/usr/bin/env python3",
|
|
1273
|
+
headerComment: "Copyright 2024 My Company",
|
|
1274
|
+
get children() {
|
|
1275
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
1276
|
+
name: "x",
|
|
1277
|
+
initializer: 42
|
|
1278
|
+
});
|
|
1279
|
+
}
|
|
1159
1280
|
});
|
|
1160
1281
|
}
|
|
1161
|
-
})
|
|
1162
|
-
|
|
1163
|
-
// 1 blank line for non-definition
|
|
1164
|
-
expect(toSourceText(content)).toRenderTo(d`
|
|
1282
|
+
})).toRenderTo({
|
|
1283
|
+
"test.py": `
|
|
1165
1284
|
#!/usr/bin/env python3
|
|
1166
1285
|
# Copyright 2024 My Company
|
|
1167
1286
|
|
|
1168
|
-
x = 42`
|
|
1287
|
+
x = 42`
|
|
1288
|
+
});
|
|
1169
1289
|
});
|
|
1170
1290
|
//# sourceMappingURL=sourcefiles.test.js.map
|