mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 13:44:15 +08:00
Updated lintrunner (markdown)
@ -6,15 +6,39 @@ pip install lintrunner
|
|||||||
lintrunner init
|
lintrunner init
|
||||||
```
|
```
|
||||||
This will install `lintrunner` on your system and download all the necessary dependencies to run linters locally. Note that this will install new packages with `pip` and download binaries maintained by the PyTorch team. If you want to see what `lintrunner init` will install, run `lintrunner init --dry-run`.
|
This will install `lintrunner` on your system and download all the necessary dependencies to run linters locally. Note that this will install new packages with `pip` and download binaries maintained by the PyTorch team. If you want to see what `lintrunner init` will install, run `lintrunner init --dry-run`.
|
||||||
|
### How do I run linters locally?
|
||||||
After that, you can do:
|
|
||||||
```
|
```
|
||||||
lintrunner
|
lintrunner
|
||||||
```
|
```
|
||||||
to lint your local changes, or
|
to lint your local changes (by default, this is your working tree changes and the HEAD commit).
|
||||||
|
### How do I autoformat my code?
|
||||||
```
|
```
|
||||||
lintrunner f
|
lintrunner f
|
||||||
```
|
```
|
||||||
to autoformat your changes.
|
to format locally changed files.
|
||||||
|
### How do I run lint on my entire PR/branch?
|
||||||
|
If, say, your PR is targeting `master`, run:
|
||||||
|
```
|
||||||
|
lintrunner -m master
|
||||||
|
```
|
||||||
|
### How do I run lint on specific files?
|
||||||
|
```
|
||||||
|
lintrunner torch/jit/_script.py torch/jit/_trace.py
|
||||||
|
```
|
||||||
|
`xargs` also works fine:
|
||||||
|
```
|
||||||
|
find -type f torch/onnx | xargs lintrunner
|
||||||
|
```
|
||||||
|
### How do I run lint on every file?
|
||||||
|
```
|
||||||
|
lintrunner --paths-cmd='git grep -Il .'
|
||||||
|
```
|
||||||
|
(or use `xargs`).
|
||||||
|
### How do I run only a specific linter?
|
||||||
|
```
|
||||||
|
lintrunner --take BLACK,CLANGFORMAT
|
||||||
|
```
|
||||||
|
To see what linter names to pass, consult the [config](https://github.com/pytorch/pytorch/blob/master/.lintrunner.toml). By default, `lintrunner` runs all linters. To skip a linter, use `--skip`.
|
||||||
|
### I have another question
|
||||||
|
|
||||||
For more docs run `lintrunner --help`, or see [the `lintrunner` repo](https://github.com/suo/lintrunner).
|
For more docs run `lintrunner --help`, or see [the `lintrunner` repo](https://github.com/suo/lintrunner).
|
Reference in New Issue
Block a user