pytorch/tools/linter/adapters
Maggie Moss 80ba6e458f Add warning when users have incomplete setup for type checking (#166603)
Looking for feedback on this approach.
Received user reports of spurious pyrefly errors for users using hg instead of git. I think this was due to the fact that when using a venv and git, `make setup-env` installs requirements and pulls from a nightly torch wheel, which is needed for pyrefly to type check properly.

Initial documentation for `make setup-env` I found here: https://github.com/pytorch/pytorch/blob/main/CONTRIBUTING.md#developing-pytorch

Testing:
```
hg clone --git ssh://git@github.com/pytorch/pytorch.git
conda create -n pytorch_env python=3.10 # (or manually create venv instead of using script)
cd pytorch
pip install -r requirements.txt
pip install -r requirements-build.txt
lintrunner init
# check how many pyrefly errors - 15,709 errors (11,693 ignored)
lintrunner # confirm error message / warning appears
>>> General linter failure:
  Warning (PYREFLY) nightly-wheel-not-run
    pytorch-nightly.pth not found. You may need to run make setup-env or make
    setup-env-conda to install nightly binaries and type stubs.
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/166603
Approved by: https://github.com/aorenste
2025-10-30 20:37:44 +00:00
..
_linter Fix pyrefly ignore syntax in /tools/... (#166240) 2025-10-26 04:20:16 +00:00
actionlint_linter.py [CD] Build Mac wheels using setup-python action (#162136) 2025-09-12 00:16:31 +00:00
bazel_linter.py [BE][Easy] enable postponed annotations in tools (#129375) 2024-06-29 09:23:35 +00:00
clangformat_linter.py Enable all flake8-logging-format rules (#164655) 2025-10-19 00:59:28 +00:00
clangtidy_linter.py Fix pyrefly ignore syntax in /tools/... (#166240) 2025-10-26 04:20:16 +00:00
cmake_linter.py [BE][Easy] enable postponed annotations in tools (#129375) 2024-06-29 09:23:35 +00:00
cmake_minimum_required_linter.py [BE] add a linter to check consistency for cmake minimum version in requirements (#156961) 2025-07-09 10:44:17 +00:00
codespell_linter.py Fix pyrefly ignore syntax in /tools/... (#166240) 2025-10-26 04:20:16 +00:00
docstring_linter-grandfather.json docstring_linter: Fix #151692 and other issues (#156596) 2025-08-25 16:04:14 +00:00
docstring_linter.py [9/N] Apply ruff UP035 rule (#165515) 2025-10-17 00:09:51 +00:00
exec_linter.py [BE][Easy] enable postponed annotations in tools (#129375) 2024-06-29 09:23:35 +00:00
flake8_linter.py Enable all flake8-logging-format rules (#164655) 2025-10-19 00:59:28 +00:00
gb_registry_linter.py [dynamo] lintrunner for gb_registry adds/updates (#158460) 2025-07-23 21:02:54 +00:00
gha_linter.py Uniformly pass secrets: inherit to all jobs that go to _linux-build/_linux-test (#141995) 2024-12-05 14:52:43 +00:00
grep_linter.py Add file size limits to linters and refactor grep_linter (#166202) 2025-10-25 14:57:19 +00:00
header_only_linter.py Add torch/header_only_apis.txt and enforce they're tested (#153635) 2025-05-20 23:42:24 +00:00
import_linter.py [Code Clean] Remove deadcodes about Python3.9 [5/N] (#163644) 2025-09-24 07:30:50 +00:00
lintrunner_version_linter.py Support CUDA nightly package in tools/nightly.py (#131133) 2024-07-25 05:33:52 +00:00
mypy_linter.py Get rid of unused code in linters (#154043) 2025-05-22 15:24:54 +00:00
nativefunctions_linter.py [BE][Easy] enable postponed annotations in tools (#129375) 2024-06-29 09:23:35 +00:00
newlines_linter.py Add file size limits to linters and refactor grep_linter (#166202) 2025-10-25 14:57:19 +00:00
no_merge_conflict_csv_linter.py Get rid of unused code in linters (#154043) 2025-05-22 15:24:54 +00:00
no_workflows_on_fork.py [9/N] Apply ruff UP035 rule (#165515) 2025-10-17 00:09:51 +00:00
pip_init.py [Fix] Adding missing f prefixes to formatted strings [3/N] (#164067) 2025-09-29 04:35:23 +00:00
pyfmt_linter.py Fix pyrefly ignore syntax in /tools/... (#166240) 2025-10-26 04:20:16 +00:00
pyproject_linter.py Remove top limit for cpython version and fix lint appropriately. (#158853) 2025-07-22 23:59:00 +00:00
pyrefly_linter.py Add warning when users have incomplete setup for type checking (#166603) 2025-10-30 20:37:44 +00:00
README.md
ruff_linter.py Enable all flake8-logging-format rules (#164655) 2025-10-19 00:59:28 +00:00
s3_init_config.json [Lint] Update clang-format to 19.1.4 (#153889) 2025-05-20 14:12:46 +00:00
s3_init.py Fix pyrefly ignore syntax in /tools/... (#166240) 2025-10-26 04:20:16 +00:00
set_linter.py Move code out of individual token linters (#152256) 2025-06-23 18:16:33 +00:00
shellcheck_linter.py [BE][Easy] enable postponed annotations in tools (#129375) 2024-06-29 09:23:35 +00:00
test_device_bias_linter.py [Linter] Expanding the scope of detecting device-bias code. (#159949) 2025-08-09 09:41:16 +00:00
test_has_main_linter.py Fix pyrefly ignore syntax in /tools/... (#166240) 2025-10-26 04:20:16 +00:00
testowners_linter.py Fix missing brackets (#165138) 2025-10-10 17:23:31 +00:00
update_s3.py
workflow_consistency_linter.py Fix pyrefly ignore syntax in /tools/... (#166240) 2025-10-26 04:20:16 +00:00

lintrunner adapters

These files adapt our various linters to work with lintrunner.

Adding a new linter

  1. init and linter
  2. {{DRYRUN}} and {{PATHSFILE}}
  3. never exit uncleanly
  4. Communication protocol
  5. Self-contained