quick_fix
Applies code fixes for a file's diagnostics, such as adding missing imports, and resolves ambiguous fixes by listing options or applying a chosen one.
Instructions
Apply ty's own fixes for a file's diagnostics (today: add the missing import). Example: quick_fix(file_path="src/app.py").
Looks at the file's diagnostics (narrow with line or a rule code such as
unresolved-reference), asks ty for the quick fixes, and applies them.
Imports are placed after the docstring and the existing imports, merged into
an existing from x import ... where there is one. When a diagnostic has
several equally good fixes (two modules that both export Path) nothing is
applied: the options are listed, and you repeat the call with choice set to
part of the title you want (choice="pathlib") or a 1-based choice number. Fixes that only silence the
error (# ty: ignore) are skipped unless allow_suppress=true.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"file_path": "<file_path>"
},
"name": "quick_fix"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | No | ||
| line | No | ||
| apply | No | ||
| choice | No | ||
| file_path | Yes | ||
| allow_suppress | No | ||
| max_new_errors | No |