@@ -34,227 +34,158 @@ def __init__(self, prog: str, **kwargs: Any) -> None:
3434
3535
3636parser = argparse .ArgumentParser (
37- prog = "dmypy" , description = "Client for mypy daemon mode" , fromfile_prefix_chars = "@"
38- )
37+ prog = "dmypy" , description = "Client for mypy daemon mode" , fromfile_prefix_chars = "@" )
3938if sys .version_info >= (3 , 14 ):
4039 parser .color = True # Set as init arg in 3.14
4140
4241parser .set_defaults (action = None )
43- parser .add_argument (
44- "--status-file" , default = DEFAULT_STATUS_FILE , help = "status file to retrieve daemon details"
45- )
46- parser .add_argument (
47- "-V" ,
48- "--version" ,
49- action = "version" ,
50- version = "%(prog)s " + __version__ ,
51- help = "Show program's version number and exit" ,
52- )
42+ parser .add_argument ("--status-file" , default = DEFAULT_STATUS_FILE ,
43+ help = "status file to retrieve daemon details" )
44+ parser .add_argument ("-V" ,"--version" , action = "version" , version = "%(prog)s " + __version__ ,
45+ help = "Show program's version number and exit" )
5346subparsers = parser .add_subparsers ()
5447
55- start_parser = p = subparsers .add_parser ("start" , help = "Start daemon" )
56- p .add_argument ("--log-file" , metavar = "FILE" , type = str , help = "Direct daemon stdout/stderr to FILE" )
57- p .add_argument (
58- "--timeout" , metavar = "TIMEOUT" , type = int , help = "Server shutdown timeout (in seconds)"
59- )
60- p .add_argument (
61- "flags" , metavar = "FLAG" , nargs = "*" , type = str , help = "Regular mypy flags (precede with --)"
62- )
63-
64- restart_parser = p = subparsers .add_parser (
65- "restart" , help = "Restart daemon (stop or kill followed by start)"
66- )
67- p .add_argument ("--log-file" , metavar = "FILE" , type = str , help = "Direct daemon stdout/stderr to FILE" )
68- p .add_argument (
69- "--timeout" , metavar = "TIMEOUT" , type = int , help = "Server shutdown timeout (in seconds)"
70- )
71- p .add_argument (
72- "flags" , metavar = "FLAG" , nargs = "*" , type = str , help = "Regular mypy flags (precede with --)"
73- )
74-
75- status_parser = p = subparsers .add_parser ("status" , help = "Show daemon status" )
76- p .add_argument ("-v" , "--verbose" , action = "store_true" , help = "Print detailed status" )
77- p .add_argument ("--fswatcher-dump-file" , help = "Collect information about the current file state" )
78-
79- stop_parser = p = subparsers .add_parser ("stop" , help = "Stop daemon (asks it politely to go away)" )
80-
81- kill_parser = p = subparsers .add_parser ("kill" , help = "Kill daemon (kills the process)" )
82-
83- check_parser = p = subparsers .add_parser (
84- "check" , formatter_class = AugmentedHelpFormatter , help = "Check some files (requires daemon)"
85- )
86- p .add_argument ("-v" , "--verbose" , action = "store_true" , help = "Print detailed status" )
48+ start_parser = subparsers .add_parser ("start" , help = "Start daemon" )
49+ p = start_parser
50+ p .add_argument ("--log-file" , metavar = "FILE" , type = str ,
51+ help = "Direct daemon stdout/stderr to FILE" )
52+ p .add_argument ("--timeout" , metavar = "TIMEOUT" , type = int ,
53+ help = "Server shutdown timeout (in seconds)" )
54+ p .add_argument ("flags" , metavar = "FLAG" , nargs = "*" , type = str ,
55+ help = "Regular mypy flags (precede with --)" )
56+
57+ restart_parser = subparsers .add_parser ("restart" ,
58+ help = "Restart daemon (stop or kill followed by start)" )
59+ p = restart_parser
60+ p .add_argument ("--log-file" , metavar = "FILE" , type = str ,
61+ help = "Direct daemon stdout/stderr to FILE" )
62+ p .add_argument ("--timeout" , metavar = "TIMEOUT" , type = int ,
63+ help = "Server shutdown timeout (in seconds)" )
64+ p .add_argument ("flags" , metavar = "FLAG" , nargs = "*" , type = str ,
65+ help = "Regular mypy flags (precede with --)" )
66+
67+ status_parser = subparsers .add_parser ("status" , help = "Show daemon status" )
68+ p = status_parser
69+ p .add_argument ("-v" , "--verbose" , action = "store_true" ,
70+ help = "Print detailed status" )
71+ p .add_argument ("--fswatcher-dump-file" ,
72+ help = "Collect information about the current file state" )
73+
74+ stop_parser = subparsers .add_parser ("stop" ,
75+ help = "Stop daemon (asks it politely to go away)" )
76+
77+ kill_parser = subparsers .add_parser ("kill" , help = "Kill daemon (kills the process)" )
78+
79+ check_parser = subparsers .add_parser ("check" , formatter_class = AugmentedHelpFormatter ,
80+ help = "Check some files (requires daemon)" )
81+ p = check_parser
82+ p .add_argument ("-v" , "--verbose" , action = "store_true" ,
83+ help = "Print detailed status" )
8784p .add_argument ("-q" , "--quiet" , action = "store_true" , help = argparse .SUPPRESS ) # Deprecated
88- p .add_argument ("--junit-xml" , help = "Write junit.xml to the given file" )
89- p .add_argument ("--perf-stats-file" , help = "write performance information to the given file" )
90- p .add_argument ("files" , metavar = "FILE" , nargs = "+" , help = "File (or directory) to check" )
91- p .add_argument (
92- "--export-types" ,
93- action = "store_true" ,
94- help = "Store types of all expressions in a shared location (useful for inspections)" ,
95- )
96-
97- run_parser = p = subparsers .add_parser (
98- "run" ,
99- formatter_class = AugmentedHelpFormatter ,
100- help = "Check some files, [re]starting daemon if necessary" ,
101- )
102- p .add_argument ("-v" , "--verbose" , action = "store_true" , help = "Print detailed status" )
103- p .add_argument ("--junit-xml" , help = "Write junit.xml to the given file" )
104- p .add_argument ("--perf-stats-file" , help = "write performance information to the given file" )
105- p .add_argument (
106- "--timeout" , metavar = "TIMEOUT" , type = int , help = "Server shutdown timeout (in seconds)"
107- )
108- p .add_argument ("--log-file" , metavar = "FILE" , type = str , help = "Direct daemon stdout/stderr to FILE" )
109- p .add_argument (
110- "--export-types" ,
111- action = "store_true" ,
112- help = "Store types of all expressions in a shared location (useful for inspections)" ,
113- )
114- p .add_argument (
115- "flags" ,
116- metavar = "ARG" ,
117- nargs = "*" ,
118- type = str ,
119- help = "Regular mypy flags and files (precede with --)" ,
120- )
121-
122- recheck_parser = p = subparsers .add_parser (
123- "recheck" ,
124- formatter_class = AugmentedHelpFormatter ,
125- help = "Re-check the previous list of files, with optional modifications (requires daemon)" ,
126- )
127- p .add_argument ("-v" , "--verbose" , action = "store_true" , help = "Print detailed status" )
85+ p .add_argument ("--junit-xml" ,
86+ help = "Write junit.xml to the given file" )
87+ p .add_argument ("--perf-stats-file" ,
88+ help = "write performance information to the given file" )
89+ p .add_argument ("files" , metavar = "FILE" , nargs = "+" ,
90+ help = "File (or directory) to check" )
91+ p .add_argument ("--export-types" , action = "store_true" ,
92+ help = "Store types of all expressions in a shared location (useful for inspections)" )
93+
94+ run_parser = subparsers .add_parser ("run" , formatter_class = AugmentedHelpFormatter ,
95+ help = "Check some files, [re]starting daemon if necessary" )
96+ p = run_parser
97+ p .add_argument ("-v" , "--verbose" , action = "store_true" ,
98+ help = "Print detailed status" )
99+ p .add_argument ("--junit-xml" ,
100+ help = "Write junit.xml to the given file" )
101+ p .add_argument ("--perf-stats-file" ,
102+ help = "write performance information to the given file" )
103+ p .add_argument ("--timeout" , metavar = "TIMEOUT" , type = int ,
104+ help = "Server shutdown timeout (in seconds)" )
105+ p .add_argument ("--log-file" , metavar = "FILE" , type = str ,
106+ help = "Direct daemon stdout/stderr to FILE" )
107+ p .add_argument ("--export-types" , action = "store_true" ,
108+ help = "Store types of all expressions in a shared location (useful for inspections)" )
109+ p .add_argument ("flags" , metavar = "ARG" , nargs = "*" , type = str ,
110+ help = "Regular mypy flags and files (precede with --)" )
111+
112+ recheck_parser = subparsers .add_parser ("recheck" , formatter_class = AugmentedHelpFormatter ,
113+ help = "Re-check the previous list of files, with optional modifications (requires daemon)" )
114+ p = recheck_parser
115+ p .add_argument ("-v" , "--verbose" , action = "store_true" ,
116+ help = "Print detailed status" )
128117p .add_argument ("-q" , "--quiet" , action = "store_true" , help = argparse .SUPPRESS ) # Deprecated
129- p .add_argument ("--junit-xml" , help = "Write junit.xml to the given file" )
130- p .add_argument ("--perf-stats-file" , help = "write performance information to the given file" )
131- p .add_argument (
132- "--export-types" ,
133- action = "store_true" ,
134- help = "Store types of all expressions in a shared location (useful for inspections)" ,
135- )
136- p .add_argument (
137- "--update" ,
138- metavar = "FILE" ,
139- nargs = "*" ,
140- help = "Files in the run to add or check again (default: all from previous run)" ,
141- )
142- p .add_argument ("--remove" , metavar = "FILE" , nargs = "*" , help = "Files to remove from the run" )
143-
144- suggest_parser = p = subparsers .add_parser (
145- "suggest" , help = "Suggest a signature or show call sites for a specific function"
146- )
147- p .add_argument (
148- "function" ,
149- metavar = "FUNCTION" ,
150- type = str ,
151- help = "Function specified as '[package.]module.[class.]function'" ,
152- )
153- p .add_argument (
154- "--json" ,
155- action = "store_true" ,
156- help = "Produce json that pyannotate can use to apply a suggestion" ,
157- )
158- p .add_argument (
159- "--no-errors" , action = "store_true" , help = "Only produce suggestions that cause no errors"
160- )
161- p .add_argument (
162- "--no-any" , action = "store_true" , help = "Only produce suggestions that don't contain Any"
163- )
164- p .add_argument (
165- "--flex-any" ,
166- type = float ,
167- help = "Allow anys in types if they go above a certain score (scores are from 0-1)" ,
168- )
169- p .add_argument (
170- "--callsites" , action = "store_true" , help = "Find callsites instead of suggesting a type"
171- )
172- p .add_argument (
173- "--use-fixme" ,
174- metavar = "NAME" ,
175- type = str ,
176- help = "A dummy name to use instead of Any for types that can't be inferred" ,
177- )
178- p .add_argument (
179- "--max-guesses" ,
180- type = int ,
181- help = "Set the maximum number of types to try for a function (default 64)" ,
182- )
183-
184- inspect_parser = p = subparsers .add_parser (
185- "inspect" , help = "Locate and statically inspect expression(s)"
186- )
187- p .add_argument (
188- "location" ,
189- metavar = "LOCATION" ,
190- type = str ,
191- help = "Location specified as path/to/file.py:line:column[:end_line:end_column]."
192- " If position is given (i.e. only line and column), this will return all"
193- " enclosing expressions" ,
194- )
195- p .add_argument (
196- "--show" ,
197- metavar = "INSPECTION" ,
198- type = str ,
199- default = "type" ,
200- choices = ["type" , "attrs" , "definition" ],
201- help = "What kind of inspection to run" ,
202- )
203- p .add_argument (
204- "--verbose" ,
205- "-v" ,
206- action = "count" ,
207- default = 0 ,
208- help = "Increase verbosity of the type string representation (can be repeated)" ,
209- )
210- p .add_argument (
211- "--limit" ,
212- metavar = "NUM" ,
213- type = int ,
214- default = 0 ,
215- help = "Return at most NUM innermost expressions (if position is given); 0 means no limit" ,
216- )
217- p .add_argument (
218- "--include-span" ,
219- action = "store_true" ,
220- help = "Prepend each inspection result with the span of corresponding expression"
221- ' (e.g. 1:2:3:4:"int")' ,
222- )
223- p .add_argument (
224- "--include-kind" ,
225- action = "store_true" ,
226- help = "Prepend each inspection result with the kind of corresponding expression"
227- ' (e.g. NameExpr:"int")' ,
228- )
229- p .add_argument (
230- "--include-object-attrs" ,
231- action = "store_true" ,
232- help = 'Include attributes of "object" in "attrs" inspection' ,
233- )
234- p .add_argument (
235- "--union-attrs" ,
236- action = "store_true" ,
237- help = "Include attributes valid for some of possible expression types"
238- " (by default an intersection is returned)" ,
239- )
240- p .add_argument (
241- "--force-reload" ,
242- action = "store_true" ,
243- help = "Re-parse and re-type-check file before inspection (may be slow)" ,
244- )
245-
246- hang_parser = p = subparsers .add_parser ("hang" , help = "Hang for 100 seconds" )
247-
248- daemon_parser = p = subparsers .add_parser ("daemon" , help = "Run daemon in foreground" )
249- p .add_argument (
250- "--timeout" , metavar = "TIMEOUT" , type = int , help = "Server shutdown timeout (in seconds)"
251- )
252- p .add_argument ("--log-file" , metavar = "FILE" , type = str , help = "Direct daemon stdout/stderr to FILE" )
253- p .add_argument (
254- "flags" , metavar = "FLAG" , nargs = "*" , type = str , help = "Regular mypy flags (precede with --)"
255- )
118+ p .add_argument ("--junit-xml" ,
119+ help = "Write junit.xml to the given file" )
120+ p .add_argument ("--perf-stats-file" ,
121+ help = "write performance information to the given file" )
122+ p .add_argument ("--export-types" , action = "store_true" ,
123+ help = "Store types of all expressions in a shared location (useful for inspections)" )
124+ p .add_argument ("--update" , metavar = "FILE" , nargs = "*" ,
125+ help = "Files in the run to add or check again (default: all from previous run)" )
126+ p .add_argument ("--remove" , metavar = "FILE" , nargs = "*" ,
127+ help = "Files to remove from the run" )
128+
129+ suggest_parser = subparsers .add_parser ("suggest" ,
130+ help = "Suggest a signature or show call sites for a specific function" )
131+ p = suggest_parser
132+ p .add_argument ("function" , metavar = "FUNCTION" , type = str ,
133+ help = "Function specified as '[package.]module.[class.]function'" )
134+ p .add_argument ("--json" , action = "store_true" ,
135+ help = "Produce json that pyannotate can use to apply a suggestion" )
136+ p .add_argument ("--no-errors" , action = "store_true" ,
137+ help = "Only produce suggestions that cause no errors" )
138+ p .add_argument ("--no-any" , action = "store_true" ,
139+ help = "Only produce suggestions that don't contain Any" )
140+ p .add_argument ("--flex-any" , type = float ,
141+ help = "Allow anys in types if they go above a certain score (scores are from 0-1)" )
142+ p .add_argument ("--callsites" , action = "store_true" ,
143+ help = "Find callsites instead of suggesting a type" )
144+ p .add_argument ("--use-fixme" , metavar = "NAME" , type = str ,
145+ help = "A dummy name to use instead of Any for types that can't be inferred" )
146+ p .add_argument ("--max-guesses" , type = int ,
147+ help = "Set the maximum number of types to try for a function (default 64)" )
148+
149+ inspect_parser = subparsers .add_parser ("inspect" ,
150+ help = "Locate and statically inspect expression(s)" )
151+ p = suggest_parser
152+ p .add_argument ("location" , metavar = "LOCATION" , type = str ,
153+ help = "Location specified as path/to/file.py:line:column[:end_line:end_column]."
154+ " If position is given (i.e. only line and column), this will return all"
155+ " enclosing expressions" )
156+ p .add_argument ("--show" , metavar = "INSPECTION" , type = str , default = "type" , choices = ["type" , "attrs" , "definition" ],
157+ help = "What kind of inspection to run" )
158+ p .add_argument ("--verbose" , "-v" , action = "count" , default = 0 ,
159+ help = "Increase verbosity of the type string representation (can be repeated)" )
160+ p .add_argument ("--limit" , metavar = "NUM" , type = int , default = 0 ,
161+ help = "Return at most NUM innermost expressions (if position is given); 0 means no limit" )
162+ p .add_argument ("--include-span" , action = "store_true" ,
163+ help = "Prepend each inspection result with the span of corresponding expression"
164+ ' (e.g. 1:2:3:4:"int")' )
165+ p .add_argument ("--include-kind" , action = "store_true" ,
166+ help = "Prepend each inspection result with the kind of corresponding expression"
167+ ' (e.g. NameExpr:"int")' )
168+ p .add_argument ("--include-object-attrs" , action = "store_true" ,
169+ help = 'Include attributes of "object" in "attrs" inspection' )
170+ p .add_argument ("--union-attrs" , action = "store_true" ,
171+ help = "Include attributes valid for some of possible expression types"
172+ " (by default an intersection is returned)" )
173+ p .add_argument ("--force-reload" , action = "store_true" ,
174+ help = "Re-parse and re-type-check file before inspection (may be slow)" )
175+
176+ hang_parser = subparsers .add_parser ("hang" , help = "Hang for 100 seconds" )
177+
178+ daemon_parser = subparsers .add_parser ("daemon" , help = "Run daemon in foreground" )
179+ p = daemon_parser
180+ p .add_argument ("--timeout" , metavar = "TIMEOUT" , type = int ,
181+ help = "Server shutdown timeout (in seconds)" )
182+ p .add_argument ("--log-file" , metavar = "FILE" , type = str ,
183+ help = "Direct daemon stdout/stderr to FILE" )
184+ p .add_argument ("flags" , metavar = "FLAG" , nargs = "*" , type = str ,
185+ help = "Regular mypy flags (precede with --)" )
256186p .add_argument ("--options-data" , help = argparse .SUPPRESS )
257- help_parser = p = subparsers .add_parser ("help" )
187+
188+ help_parser = subparsers .add_parser ("help" )
258189
259190del p
260191
0 commit comments