@@ -87,6 +87,11 @@ require more precise control over the lifetime of the daemon process:
87
87
* ``dmypy check <files> `` checks a set of files using an already
88
88
running daemon.
89
89
90
+ * ``dmypy recheck `` checks the same set of files as the most recent
91
+ ``check `` or ``recheck `` command. (You can also use the :option: `--update `
92
+ and :option: `--remove ` options to alter the set of files, and to define
93
+ which files should be processed.)
94
+
90
95
* ``dmypy status `` checks whether a daemon is running. It prints a
91
96
diagnostic and exits with ``0 `` if there is a running daemon.
92
97
@@ -101,60 +106,69 @@ Additional daemon flags
101
106
102
107
Use ``FILE `` as the status file for storing daemon runtime state. This is
103
108
normally a JSON file that contains information about daemon process and
104
- connection. Default is ``.dmypy.json `` in current directory.
109
+ connection. The default path is ``.dmypy.json `` in the current working
110
+ directory.
105
111
106
112
.. option :: --log-file FILE
107
113
108
114
Direct daemon stdout/stderr to ``FILE ``. This is useful for debugging daemon
109
- crashes, since the server traceback may be not printed to client stderr .
110
- Only available for ``start ``, ``restart ``, and ``run `` commands.
115
+ crashes, since the server traceback is not always printed by the client .
116
+ This is available for the ``start ``, ``restart ``, and ``run `` commands.
111
117
112
118
.. option :: --timeout TIMEOUT
113
119
114
120
Automatically shut down server after ``TIMEOUT `` seconds of inactivity.
115
- Only available for ``start ``, ``restart ``, and ``run `` commands.
121
+ This is available for the ``start ``, ``restart ``, and ``run `` commands.
116
122
117
- .. option :: --fswatcher-dump-file FILE
123
+ .. option :: --update FILE
118
124
119
- Collect information about the current file state. Only available for
120
- ``status `` command. This will dump a JSON to ``FILE `` in the format
121
- ``{path: [modification_time, size, content_hash]} ``. This is useful for
122
- debugging the built-in file system watcher. *Note: * this is an internal
123
- flag and the format may change.
125
+ Re-check ``FILE ``, or add it to the set of files being
126
+ checked (and check it). This option may be repeated, and it's only available for
127
+ the ``recheck `` command. By default, mypy finds and checks all files changed
128
+ since the previous run and files that depend on them. However, if you use this option
129
+ (and/or :option: `--remove `), mypy assumes that only the explicitly
130
+ specified files have changed. This is only useful to
131
+ speed up mypy if you type check a very large number of files, and use an
132
+ external, fast file system watcher, such as `watchman `_ or
133
+ `watchdog `_, to determine which files got edited or deleted.
134
+ *Note: * This option is never required and is only available for
135
+ performance tuning.
124
136
125
- .. option :: --perf-stats-file FILE
137
+ .. option :: --remove FILE
126
138
127
- Write performance profiling information to ``FILE ``. Only available
128
- for ``check ``, ``recheck ``, and ``run `` commands.
139
+ Remove ``FILE `` from the set of files being checked. This option may be
140
+ repeated. This is only available for the
141
+ ``recheck `` command. See :option: `--update ` above for when this may be useful.
142
+ *Note: * This option is never required and is only available for performance
143
+ tuning.
129
144
130
- .. option :: --update FILE
145
+ .. option :: --fswatcher-dump-file FILE
131
146
132
- Files in the run to add or check again, may be repeated. Default: all
133
- files from the previous run. Only available for `` recheck `` command.
134
- This is useful when type checking thousands of files and using external
135
- fast file system watcher, like ` watchman `_ or ` watchdog `_, to speed
136
- things up . *Note: * this option is never required and is only available
137
- for performance tuning .
147
+ Collect information about the current internal file state. This is
148
+ only available for the `` status `` command. This will dump JSON to
149
+ `` FILE `` in the format `` {path: [modification_time, size,
150
+ content_hash]} ``. This is useful for debugging the built-in file
151
+ system watcher . *Note: * This is an internal flag and the format may
152
+ change .
138
153
139
- .. option :: --remove FILE
154
+ .. option :: --perf-stats-file FILE
140
155
141
- Files to remove from the run, may be repeated. Only available for
142
- ``recheck `` command. This flag an be used as an optimization to avoid
143
- looking at all source files for deletions. *Note: * this option is never
144
- required and is only available for performance tuning.
156
+ Write performance profiling information to ``FILE ``. This is only available
157
+ for the ``check ``, ``recheck ``, and ``run `` commands.
145
158
146
159
Static inference of annotations
147
160
*******************************
148
161
149
- Mypy daemon supports (as an experimental feature) statically inferring
150
- a draft type annotation for a given function or method. Running
151
- `` dmypy suggest FUNCTION `` will produce a suggested signature in the format
152
- ``(param_type_1, param_type_2, ...) -> ret_type `` (including named and
153
- star arguments).
162
+ The mypy daemon supports (as an experimental feature) statically inferring
163
+ draft function and method type annotations. Use `` dmypy suggest FUNCTION `` to
164
+ generate a draft signature in the format
165
+ ``(param_type_1, param_type_2, ...) -> ret_type `` (types are included for all
166
+ arguments, including keyword-only arguments, `` *args `` and `` **kwargs `` ).
154
167
155
- This low level command may be used by editors, IDEs, or similar tools, like
156
- `mypy plugin for PyCharm `_, to propose an annotation to user and/or to insert
157
- the annotation into a source file.
168
+ This is a low-level feature intended to be used by editor integrations,
169
+ IDEs, and other tools (for example, the `mypy plugin for PyCharm `_),
170
+ to automatically add annotations to source files, or to propose function
171
+ signatures.
158
172
159
173
In this example, the function ``format_id() `` has no annotation:
160
174
@@ -165,26 +179,29 @@ In this example, the function ``format_id()`` has no annotation:
165
179
166
180
root = format_id(0 )
167
181
168
- Mypy can use call sites and return statements (plus extra heuristics such as
169
- a signature in superclass for methods) to infer that ``format_id() `` takes
170
- an ``int `` and returns a ``str ``. To get a suggested signature for a function,
171
- use ``dmypy suggest FUNCTION ``, where the function may be specified in
172
- either of two forms:
182
+ ``dymypy suggest `` uses call sites, return statements, and other heuristics (such as
183
+ looking for signatures in base classes) to infer that ``format_id() `` accepts
184
+ an ``int `` argument and returns a ``str ``. Use ``dmypy suggest module.format_id `` to
185
+ print the suggested signature for the function.
173
186
174
- * By its fully qualified name, i.e. `` [package.]module.[class.]function ``
187
+ More generally, the target function may be specified in two ways:
175
188
176
- * By its textual location, i.e. ``/path/to/file.py:line ``. The path can be
189
+ * By its fully qualified name, i.e. ``[package.]module.[class.]function ``.
190
+
191
+ * By its location in a source file, i.e. ``/path/to/file.py:line ``. The path can be
177
192
absolute or relative, and ``line `` can refer to any line number within
178
193
the function body.
179
194
180
- This command can also be used to find an improvement for an existing (imprecise)
181
- annotation. The following flags customize various aspects of the ``dmypy suggest ``
195
+ This command can also be used to find a more precise alternative for an existing,
196
+ imprecise annotation with some ``Any `` types.
197
+
198
+ The following flags customize various aspects of the ``dmypy suggest ``
182
199
command.
183
200
184
201
.. option :: --json
185
202
186
- Output the signature as JSON, so that `PyAnnotate `_ can use it to apply
187
- a suggestion to file. An example JSON looks like this :
203
+ Output the signature as JSON, so that `PyAnnotate `_ can read it and add
204
+ the signature to the source file. Here is what the JSON looks like:
188
205
189
206
.. code-block :: python
190
207
@@ -196,39 +213,39 @@ command.
196
213
197
214
.. option :: --no-errors
198
215
199
- Only produce suggestions that cause no errors in the checked code. By default
216
+ Only produce suggestions that cause no errors in the checked code. By default,
200
217
mypy will try to find the most precise type, even if it causes some type errors.
201
218
202
219
.. option :: --no-any
203
220
204
221
Only produce suggestions that don't contain ``Any `` types. By default mypy
205
222
proposes the most precise signature found, even if it contains ``Any `` types.
206
223
207
- .. option :: --flex-any PERCENTAGE
224
+ .. option :: --flex-any FRACTION
208
225
209
- Allow `` Any `` types in suggested signature if they go above a certain score .
210
- Scores are from ``0 `` (same as ``--no-any ``) to ``1 ``.
226
+ Only allow some fraction of types in the suggested signature to be `` Any `` types .
227
+ The fraction ranges from ``0 `` (same as ``--no-any ``) to ``1 ``.
211
228
212
229
.. option :: --try-text
213
230
214
- Try using ``unicode `` wherever ``str `` is inferred. This flag may be useful
231
+ Try also using ``unicode `` wherever ``str `` is inferred. This flag may be useful
215
232
for annotating Python 2/3 straddling code.
216
233
217
234
.. option :: --callsites
218
235
219
236
Only find call sites for a given function instead of suggesting a type.
220
- This will produce a list including textual locations and types of actual
237
+ This will produce a list with line numbers and types of actual
221
238
arguments for each call: ``/path/to/file.py:line: (arg_type_1, arg_type_2, ...) ``.
222
239
223
240
.. option :: --use-fixme NAME
224
241
225
- A dummy name to use instead of plain ``Any `` for types that cannot
242
+ Use a dummy name instead of plain ``Any `` for types that cannot
226
243
be inferred. This may be useful to emphasize to a user that a given type
227
- can 't be inferred and needs to be entered manually.
244
+ couldn 't be inferred and needs to be entered manually.
228
245
229
246
.. option :: --max-guesses NUMBER
230
247
231
- Set the maximum number of types to try for a function (default ``64 ``).
248
+ Set the maximum number of types to try for a function (default: ``64 ``).
232
249
233
250
.. TODO: Add similar sections about go to definition, find usages, and
234
251
reveal type when added, and then move this to a separate file.
0 commit comments