Add basic spin linting documentation (#167227)

This adds basic documentation of the linting features for Spin added in #167226 to the CONTRIBUTING.md document.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/167227
Approved by: https://github.com/atalman, https://github.com/albanD
This commit is contained in:
Klaus Zimmermann
2025-11-20 09:26:30 +01:00
committed by PyTorch MergeBot
parent 762273e3c5
commit bd883bb290

View File

@@ -14,6 +14,10 @@ aspects of contributing to PyTorch.
- [Tips and Debugging](#tips-and-debugging)
- [Nightly Checkout & Pull](#nightly-checkout--pull)
- [Codebase structure](#codebase-structure)
- [Spin](#spin)
- [Linting](#linting)
- [default lint](#default-lint)
- [Regenerating](#regenerating)
- [Unit testing](#unit-testing)
- [Python Unit Testing](#python-unit-testing)
- [Better local unit tests with `pytest`](#better-local-unit-tests-with-pytest)
@@ -274,6 +278,46 @@ dependencies as well as the nightly binaries into the repo directory.
* ...
* [.circleci](.circleci) - CircleCI configuration management. [README](.circleci/README.md)
## Spin
[Spin](https://github.com/scientific-python/spin) is a developer cli tool that
helps running common tasks.
To list the available tasks, run `spin --help`.
Currently, we support the following tasks with Spin:
### Linting
Spin helps with linting by making sure that lintrunner is installed correctly
and by isolating the lintrunner environment from the general development
environment using uv.
|command||
|-|-|
|`setup-lint`|update lintrunner and perform a fresh setup|
|`lazy-setup-lint`|only perform setup if the lint configuration has changed|
|`lint`|perform default lint (see below)|
|`quicklint`|perform lint on all files changed in the latest commit and the working directory|
|`quickfix`|autofix issues on all files changed in the latest commit and the working directory|
#### default lint
Since some linters take a long time to run, we categorize all linters as either
fast or slow. In the default lint, only the fast linters are run on all files;
the slow linters are run on the changed files only.
### Regenerating
Pytorch makes use of a number of code generations, which range from the version
information in `torch/version.py` over type stubs and other linter support to
github workflows.
With Spin, we offer a unified interface to these tasks.
|command||
|-|-|
|`regenerate-version`|regenerate `torch/version.py`|
|`regenerate-type-stubs`|regenerates type stubs for use by static type checkers|
|`regenerate-clangtidy-files`|regenerates clang related files needed for linting|
## Unit testing
### Python Unit Testing