@azure-tools/typespec-python 0.34.0 → 0.35.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/scripts/eng/lint.d.ts.map +1 -1
- package/dist/scripts/eng/lint.js +18 -1
- package/dist/scripts/eng/lint.js.map +1 -1
- package/dist/src/emitter.js +1 -1
- package/dist/src/emitter.js.map +1 -1
- package/generator/dev_requirements.txt +12 -0
- package/generator/requirements.txt +12 -0
- package/package.json +5 -5
- package/scripts/__pycache__/venvtools.cpython-310.pyc +0 -0
- package/scripts/eng/lint.ts +17 -1
- package/scripts/install.py +0 -1
- package/dist/scripts/copy-scripts.d.ts +0 -2
- package/dist/scripts/copy-scripts.d.ts.map +0 -1
- package/dist/scripts/copy-scripts.js +0 -24
- package/dist/scripts/copy-scripts.js.map +0 -1
- package/scripts/copy-scripts.ts +0 -26
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../../scripts/eng/lint.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../../scripts/eng/lint.ts"],"names":[],"mappings":"AAyCA,wBAAgB,MAAM,SAErB;AAWD,wBAAgB,IAAI,SAOnB;AAED,wBAAgB,OAAO,SAEtB;AAED,wBAAgB,MAAM,SAIrB"}
|
package/dist/scripts/eng/lint.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import yargs from "yargs";
|
|
3
3
|
import { hideBin } from "yargs/helpers";
|
|
4
4
|
import { runCommand, executeCommand } from "./utils.js";
|
|
5
|
+
import fs from "fs";
|
|
6
|
+
import path from "path";
|
|
5
7
|
const validCommands = ["pylint", "mypy", "pyright", "eslint"];
|
|
6
8
|
// PARSE INPUT ARGUMENTS
|
|
7
9
|
const argv = yargs(hideBin(process.argv))
|
|
@@ -30,8 +32,23 @@ const argv = yargs(hideBin(process.argv))
|
|
|
30
32
|
export function pylint() {
|
|
31
33
|
runCommand(`pylint ${argv.folderName}/ --rcfile ./scripts/eng/pylintrc`, "pylint");
|
|
32
34
|
}
|
|
35
|
+
function checkPythonFile(directory) {
|
|
36
|
+
const files = fs.readdirSync(directory);
|
|
37
|
+
for (let i = 0; i < files.length; i++) {
|
|
38
|
+
if (path.extname(files[i]) === ".py") {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
33
44
|
export function mypy() {
|
|
34
|
-
|
|
45
|
+
if (checkPythonFile(argv.folderName)) {
|
|
46
|
+
runCommand(`mypy ${argv.folderName}/ --config-file ./scripts/eng/mypy.ini`, "mypy");
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
console.log("No python file found in the directory");
|
|
50
|
+
console.log("mypy passed");
|
|
51
|
+
}
|
|
35
52
|
}
|
|
36
53
|
export function pyright() {
|
|
37
54
|
runCommand(`pyright ${argv.folderName}/ -p ./scripts/eng/pyrightconfig.json`, "pyright");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint.js","sourceRoot":"","sources":["../../../scripts/eng/lint.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"lint.js","sourceRoot":"","sources":["../../../scripts/eng/lint.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AASxB,MAAM,aAAa,GAA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sources":["../../src/emitter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAEjF,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,OAA0C;IACpE,sBAAsB,CAAC,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"emitter.js","sourceRoot":"","sources":["../../src/emitter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAEjF,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,OAA0C;IACpE,MAAM,sBAAsB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure-tools/typespec-python",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.1",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec emitter for Python SDKs",
|
|
6
6
|
"homepage": "https://github.com/Azure/autorest.python",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"files": [
|
|
30
30
|
"dist/**",
|
|
31
31
|
"!dist/test/**",
|
|
32
|
-
"scripts/**"
|
|
32
|
+
"scripts/**",
|
|
33
|
+
"generator/**"
|
|
33
34
|
],
|
|
34
35
|
"peerDependencies": {
|
|
35
36
|
"@azure-tools/typespec-azure-core": ">=0.46.0 <1.0.0",
|
|
@@ -39,7 +40,6 @@
|
|
|
39
40
|
"@azure-tools/typespec-azure-rulesets": ">=0.46.0 <3.0.0",
|
|
40
41
|
"@typespec/compiler": ">=0.60.0 <1.0.0",
|
|
41
42
|
"@typespec/http": ">=0.60.0 <1.0.0",
|
|
42
|
-
"@typespec/http-client-python": ">=0.2.0 <1.0.0",
|
|
43
43
|
"@typespec/rest": ">=0.60.0 <1.0.0",
|
|
44
44
|
"@typespec/versioning": ">=0.60.0 <1.0.0",
|
|
45
45
|
"@typespec/openapi": ">=0.60.0 <1.0.0"
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"@typespec/openapi3": "~0.60.0",
|
|
50
50
|
"semver": "~7.6.2",
|
|
51
51
|
"tsx": "4.17.0",
|
|
52
|
+
"@typespec/http-client-python": "0.2.0",
|
|
52
53
|
"fs-extra": "~11.2.0"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
@@ -75,7 +76,6 @@
|
|
|
75
76
|
"@azure-tools/typespec-azure-rulesets": "~0.46.0",
|
|
76
77
|
"yargs": "~17.7.2",
|
|
77
78
|
"chalk": "5.3.0",
|
|
78
|
-
"@typespec/http-client-python": "~0.2.0",
|
|
79
79
|
"@types/fs-extra": "11.0.4"
|
|
80
80
|
},
|
|
81
81
|
"scripts": {
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"lint": "tsx ./scripts/eng/lint.ts",
|
|
86
86
|
"lint:fix": "eslint . --fix --ext .ts",
|
|
87
87
|
"format": "npx prettier **/*.ts --write && tsx ./scripts/eng/format.ts",
|
|
88
|
-
"install": "tsx ./scripts/
|
|
88
|
+
"install": "tsx ./scripts/run-python3.ts ./scripts/install.py",
|
|
89
89
|
"regenerate": "tsx ./scripts/eng/regenerate.ts",
|
|
90
90
|
"test": "tsx ./scripts/eng/run-tests.ts"
|
|
91
91
|
}
|
|
Binary file
|
package/scripts/eng/lint.ts
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import yargs from "yargs";
|
|
3
3
|
import { hideBin } from "yargs/helpers";
|
|
4
4
|
import { runCommand, executeCommand } from "./utils.js";
|
|
5
|
+
import fs from "fs";
|
|
6
|
+
import path from "path";
|
|
5
7
|
|
|
6
8
|
interface Arguments {
|
|
7
9
|
folderName: string;
|
|
@@ -40,9 +42,23 @@ const argv = yargs(hideBin(process.argv))
|
|
|
40
42
|
export function pylint() {
|
|
41
43
|
runCommand(`pylint ${argv.folderName}/ --rcfile ./scripts/eng/pylintrc`, "pylint");
|
|
42
44
|
}
|
|
45
|
+
function checkPythonFile(directory: string): boolean {
|
|
46
|
+
const files = fs.readdirSync(directory);
|
|
47
|
+
for (let i = 0; i < files.length; i++) {
|
|
48
|
+
if (path.extname(files[i]) === ".py") {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
43
54
|
|
|
44
55
|
export function mypy() {
|
|
45
|
-
|
|
56
|
+
if (checkPythonFile(argv.folderName)) {
|
|
57
|
+
runCommand(`mypy ${argv.folderName}/ --config-file ./scripts/eng/mypy.ini`, "mypy");
|
|
58
|
+
} else {
|
|
59
|
+
console.log("No python file found in the directory");
|
|
60
|
+
console.log("mypy passed");
|
|
61
|
+
}
|
|
46
62
|
}
|
|
47
63
|
|
|
48
64
|
export function pyright() {
|
package/scripts/install.py
CHANGED
|
@@ -42,7 +42,6 @@ def main():
|
|
|
42
42
|
|
|
43
43
|
python_run(venv_context, "pip", ["install", "-U", "pip"])
|
|
44
44
|
python_run(venv_context, "pip", ["install", "-r", f"{_ROOT_DIR}/generator/requirements.txt"])
|
|
45
|
-
python_run(venv_context, "pip", ["install", "-e", f"{_ROOT_DIR}/generator"])
|
|
46
45
|
|
|
47
46
|
|
|
48
47
|
if __name__ == "__main__":
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"copy-scripts.d.ts","sourceRoot":"","sources":["../../scripts/copy-scripts.ts"],"names":[],"mappings":""}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import fsExtra from "fs-extra";
|
|
2
|
-
import { dirname, join, posix, win32 } from "path";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
4
|
-
const force = process.argv[2] === "--force";
|
|
5
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
6
|
-
function copyAndCreateDir(sourceDir, destDir) {
|
|
7
|
-
// Delete the destination directory if it exists
|
|
8
|
-
if (fsExtra.existsSync(destDir)) {
|
|
9
|
-
if (force)
|
|
10
|
-
fsExtra.removeSync(destDir);
|
|
11
|
-
else
|
|
12
|
-
process.exit(0);
|
|
13
|
-
}
|
|
14
|
-
// Copy the source directory to the destination directory
|
|
15
|
-
fsExtra.copySync(sourceDir, destDir, {
|
|
16
|
-
filter: (src) => {
|
|
17
|
-
return !src.replaceAll(win32.sep, posix.sep).includes("/test/");
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
const typespecModulePath = join(__dirname, "..", "node_modules", "@typespec", "http-client-python");
|
|
22
|
-
// Copy the generator directory
|
|
23
|
-
copyAndCreateDir(join(typespecModulePath, "generator"), join(__dirname, "..", "generator"));
|
|
24
|
-
//# sourceMappingURL=copy-scripts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"copy-scripts.js","sourceRoot":"","sources":["../../scripts/copy-scripts.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,KAAK,GAAY,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC;AACrD,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE1D,SAAS,gBAAgB,CAAC,SAAiB,EAAE,OAAe;IACxD,gDAAgD;IAChD,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC9B,IAAI,KAAK;YAAE,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;;YAClC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC;IAED,yDAAyD;IACzD,OAAO,CAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,EAAE;QACjC,MAAM,EAAE,CAAC,GAAW,EAAE,EAAE;YACpB,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACpE,CAAC;KACJ,CAAC,CAAC;AACP,CAAC;AAED,MAAM,kBAAkB,GAAW,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,cAAc,EAAE,WAAW,EAAE,oBAAoB,CAAC,CAAC;AAE5G,+BAA+B;AAC/B,gBAAgB,CAAC,IAAI,CAAC,kBAAkB,EAAE,WAAW,CAAC,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC"}
|
package/scripts/copy-scripts.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import fsExtra from "fs-extra";
|
|
2
|
-
import { dirname, join, posix, win32 } from "path";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
4
|
-
|
|
5
|
-
const force: boolean = process.argv[2] === "--force";
|
|
6
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
|
-
|
|
8
|
-
function copyAndCreateDir(sourceDir: string, destDir: string) {
|
|
9
|
-
// Delete the destination directory if it exists
|
|
10
|
-
if (fsExtra.existsSync(destDir)) {
|
|
11
|
-
if (force) fsExtra.removeSync(destDir);
|
|
12
|
-
else process.exit(0);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// Copy the source directory to the destination directory
|
|
16
|
-
fsExtra.copySync(sourceDir, destDir, {
|
|
17
|
-
filter: (src: string) => {
|
|
18
|
-
return !src.replaceAll(win32.sep, posix.sep).includes("/test/");
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const typespecModulePath: string = join(__dirname, "..", "node_modules", "@typespec", "http-client-python");
|
|
24
|
-
|
|
25
|
-
// Copy the generator directory
|
|
26
|
-
copyAndCreateDir(join(typespecModulePath, "generator"), join(__dirname, "..", "generator"));
|