pytorch/pytorch: which of 57 linter adapters become rules
PyTorch built lintrunner to run the 57 linter adapters in .lintrunner, 24 of them regex searches. The config ports the regex ones it can, runs the formatters from command_ rules and leaves the adapters that parse Python or C on lintrunner.This config was written to test alint; PyTorch doesn't use alint.
The config
The config ports regex adapters as content rules, such as the bans on std::call_ and on unpinned pip installs. The formatter adapters run from command_ rules, which fail when a formatter would change a file. It also checks the code generator's output and the generated workflows.
- id: pytorch-no-std-call-once
# fixed here: the same paths as the lintrunner adapter
kind: file_content_forbidden
paths: { include: ["c10/**" ,"aten/**" ,"torch/csrc/**" ,"torch/nativert/**" ], exclude: ["c10/util/CallOnce.h" ,"**/fb/**" ] }
pattern: 'std::call_once'
level: warningOne of the regex adapters from grep_, as a content rule: PyTorch's C++ uses its own call-once helper instead of std::call_.
- id: pytorch-pypi-install-must-be-pinned
# fixed here: (?m), so $ ends each line as it does for grep
kind: file_content_forbidden
paths:
include: [".github/**" ]
exclude: ["**/*.rst" ,"**/*.py" ,"**/*.md" ,"**/*.diff" ,"**/fb/**" ]
pattern: '(?m)(pip|pip3|python -m pip|python3 -m pip|python3 -mpip|python -mpip) install ([a-zA-Z0-9][A-Za-z0-9._\-]+)([^/=<>~!]+)[A-Za-z0-9._\-*+!]*$'
level: errorAnother: every pip install in the workflows names an exact version.
What stays outside alint
Adapters that parse code or compare jobs stay on lintrunner:
- the adapters that parse Python or C or compare version ranges, such as the docstring, test-main and device-bias checks, the graph-break registry and the stable-shim checks;
- clang-tidy and pyrefly, which do their own analysis; alint only runs them;
- WORKFLOWSYNC, which compares every job with every other job that shares its tag.
cross_compares one source with its targets;file - two adapters that need rule kinds alint doesn't have: blank lines between CSV rows, and a repository-owner guard on workflows that run on push or pull request.