-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathpython.ts
168 lines (166 loc) · 4.88 KB
/
python.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
import { filepaths } from "@fig/autocomplete-generators";
const completionSpec: Fig.Spec = {
name: "python",
description: "Run the python interpreter",
generateSpec: async (tokens, executeShellCommand) => {
const isDjangoManagePyFilePresentCommand = "cat manage.py | grep -q django";
if (
(
await executeShellCommand({
command: "bash",
args: ["-c", isDjangoManagePyFilePresentCommand],
})
).status === 0
) {
return {
name: "python",
subcommands: [{ name: "manage.py", loadSpec: "django-admin" }],
};
}
},
args: {
name: "python script",
isScript: true,
generators: filepaths({
extensions: ["py"],
editFileSuggestions: { priority: 76 },
}),
},
options: [
{
name: "-c",
insertValue: "-c '{cursor}'",
description:
"Execute the Python code in command. command can be one or more statements separated by newlines, with significant leading whitespace as in normal module code",
args: {
name: "command",
isCommand: true,
},
},
{
name: "-m",
description: "Module",
args: {
name: "python module",
isModule: "python/",
suggestions: ["http.server"],
},
},
{
name: ["-?", "-h", "--help"],
description: "Print a short description of all command line options",
},
{
name: ["-V", "--version"],
description: "Print the Python version number and exit",
},
{
name: "-b",
description:
"Issue a warning when comparing bytes or bytearray with str or bytes with int. Issue an error when the option is given twice (-bb)",
},
{
name: "-B",
description:
"If given, Python won’t try to write .pyc files on the import of source modules",
},
{
name: "--check-hash-based-pycs",
description:
"Control the validation behavior of hash-based .pyc files. See Cached bytecode invalidation",
args: {
suggestions: [
{ name: "default" },
{ name: "always" },
{ name: "never" },
],
},
},
{
name: "-d",
description:
"Turn on parser debugging output (for expert only, depending on compilation options)",
},
{
name: "-E",
description:
"Ignore all PYTHON* environment variables, e.g. PYTHONPATH and PYTHONHOME, that might be set",
},
{
name: "-i",
description:
"When a script is passed as first argument or the -c option is used, enter interactive mode after executing the script or the command, even when sys.stdin does not appear to be a terminal",
},
{
name: "-I",
description:
"Run Python in isolated mode. This also implies -E and -s. In isolated mode sys.path contains neither the script’s directory nor the user’s site-packages directory",
},
{
name: "-O",
description:
"Remove assert statements and any code conditional on the value of __debug__",
},
{
name: "-OO",
description: "Do -O and also discard docstrings",
},
{
name: "-g",
description:
"Don’t display the copyright and version messages even in interactive mode",
},
{
name: "-R",
description:
"Turn on hash randomization. This option only has an effect if the PYTHONHASHSEED environment variable is set to 0, since hash randomization is enabled by default",
},
{
name: "-s",
description: "Don’t add the user site-packages directory to sys.path",
},
{
name: "-S",
description:
"Disable the import of the module site and the site-dependent manipulations of sys.path that it entails",
},
{
name: "-u",
description:
"Force the stdout and stderr streams to be unbuffered. This option has no effect on the stdin stream",
},
{
name: "-v",
description:
"Print a message each time a module is initialized, showing the place (filename or built-in module) from which it is loaded",
},
{
name: "-W",
description:
"Warning control. Python’s warning machinery by default prints warning messages to sys.stderr",
args: {},
},
{
name: "-x",
description:
"Skip the first line of the source, allowing use of non-Unix forms of #!cmd. This is intended for a DOS specific hack only",
},
{
name: "-X",
description: "Reserved for various implementation-specific options",
args: {
suggestions: [
{ name: "faulthandler" },
{ name: "showrefcount" },
{ name: "tracemalloc" },
{ name: "showalloccount" },
{ name: "importtime" },
{ name: "dev" },
{ name: "utf8" },
{ name: "pycache_prefix=PATH" },
],
},
},
],
};
export default completionSpec;