check tool
Use check after the agent writes or changes Python, as a person runs
xpd check. It lints files and folders and returns every issue with its rule,
place, severity and fix. It changes no file, so a client can run it without asking.
check(paths=null, unsafe_fixes=false, options=null)- Changes no file
- A second call with the same arguments changes nothing more
- Stays inside the project
Tags: lint.
Description
Section titled “Description”The server gives the agent this description of the tool.
Lint Python files for slow or wrong habits with pandas, NumPy, SciPy, scikit-learn, scikit-lego, MAPIE, Category Encoders, linearmodels, arch, pymoo, plotly, Apache Hamilton and Python itself. Changes no file.
Run it after you write or change Python. Fix every error. Fix a warning unless you can say why the code is right here, and don't silence rules. An issue whose fix is set can be fixed with the fix tool. A pandas/missing-<package> warning names a package the project lacks, so ask the user before you add the dependency. The rule tool explains any rule with examples.
Arguments
Section titled “Arguments”Type: list of string or null. Optional, default null.
Files or folders inside the project root. Folders respect .gitignore. Default: the whole root.
unsafe_fixes
Section titled “unsafe_fixes”Type: boolean. Optional, default false.
Count unsafe fixes, which may change behavior, in fixable too.
options
Section titled “options”Type: object or null. Optional, default null.
Which rules run, and the project file that adds the project's own rules.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
options.rules |
list of string | no | Packages or public rule names. | |
options.severity |
"error", "warning", "info", "hint" or null |
no | null |
Run only the rules of this severity and above. |
options.config |
string or null | no | null |
A project file to read instead of the nearest sgconfig.yml, relative to the project root. |
Result
Section titled “Result”What xpd check found, after the fixes it wrote.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
fixed |
integer | yes | Number of fixes written to disk. | |
fixable |
integer | yes | Issues left that the fix tool fixes at the level asked for. | |
issues |
list of object | yes | ||
issues[].package |
string | yes | Module name of the rule's pack, such as pandas. | |
issues[].rule |
string | yes | Rule id, such as chained-assignment. | |
issues[].file |
string | yes | ||
issues[].line |
integer or null | yes | ||
issues[].column |
integer or null | yes | ||
issues[].severity |
"error", "warning", "info", "hint" |
yes | ||
issues[].message |
string | yes | ||
issues[].fix |
"safe", "unsafe" or null |
yes | How safe the rule's fix is, or null for no fix. |
Example
Section titled “Example”The call below lints one file for one rule, and counts the unsafe fix in fixable.
{"paths":["samples/bad.py"],"unsafe_fixes":true,"options":{"rules":["pandas/chained-assignment"]}}{"fixed":0,"fixable":1,"issues":[{"package":"pandas","rule":"chained-assignment","file":"samples/bad.py","line":6,"column":5,"severity":"error","message":"Chained assignment writes to a copy under copy-on-write, so the frame keeps its old values. Assign to df.loc[i, \"a\"] instead.","fix":"unsafe"}]}Errors
Section titled “Errors”A path outside the project root fails before xpd runs.
../outside.py is outside the project root /tmp/project. Pass a path inside it.A failure of the binary, such as a file it cannot read, comes back as a tool error with the command and its message. Issues are a result, not an error.