Skip to content

Commit 31bf5de

Browse files
committed
tc
1 parent 74e4057 commit 31bf5de

14 files changed

+185
-2390
lines changed

.github/scripts/get_tutorials_stats.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,14 @@
88
from subprocess import check_output
99
from typing import Any, Dict, List, NamedTuple, Optional, Union
1010

11-
import boto3 # type: ignore[import-not-found]
11+
import boto3 # type: ignore[import-not-found,import-untyped]
1212

1313

1414
METADATA_PATH = "ossci_tutorials_stats/metadata.csv"
1515
FILENAMES_PATH = "ossci_tutorials_stats/filenames.csv"
1616

1717

18-
def run_command(
19-
cmd: str, cwd: Optional[str] = None, env=Optional[Dict[str, str]]
20-
) -> str:
18+
def run_command(cmd: str, cwd: Optional[str] = None, env=Optional[Dict[str, str]]):
2119
"""
2220
Run a shell command.
2321

.lintrunner.toml

Lines changed: 156 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,21 @@ exclude_patterns = [
1414
]
1515
command = [
1616
'python3',
17-
'tools/linter/adapters/flake8_linter.py',
17+
'tools/linter/adapters/run_from_link_linter.py',
18+
'--run-lint',
19+
'--lint-name=flake8_linter.py',
1820
'--',
1921
'@{{PATHSFILE}}'
2022
]
2123
init_command = [
2224
'python3',
23-
'tools/linter/adapters/pip_init.py',
25+
'tools/linter/adapters/run_from_link_linter.py',
26+
'--run-init',
27+
'--init-name=pip_init.py',
28+
'--init-link=https://raw.githubusercontent.com/pytorch/pytorch/b8895df8db23213a0db50fe833930dd1f4e4b5a5/tools/linter/adapters/pip_init.py',
29+
'--lint-name=flake8_linter.py',
30+
'--lint-link=https://raw.githubusercontent.com/pytorch/pytorch/b8895df8db23213a0db50fe833930dd1f4e4b5a5/tools/linter/adapters/flake8_linter.py',
31+
'--',
2432
'--dry-run={{DRYRUN}}',
2533
'flake8==6.1.0',
2634
'flake8-bugbear==23.3.23',
@@ -55,14 +63,23 @@ exclude_patterns = [
5563
]
5664
command = [
5765
'python3',
58-
'tools/linter/adapters/mypy_linter.py',
66+
'tools/linter/adapters/run_from_link_linter.py',
67+
'--run-lint',
68+
'--lint-name=mypy_linter.py',
69+
'--',
5970
'--config=mypy.ini',
6071
'--',
6172
'@{{PATHSFILE}}'
6273
]
6374
init_command = [
6475
'python3',
65-
'tools/linter/adapters/pip_init.py',
76+
'tools/linter/adapters/run_from_link_linter.py',
77+
'--run-init',
78+
'--init-name=pip_init.py',
79+
'--init-link=https://raw.githubusercontent.com/pytorch/pytorch/b8895df8db23213a0db50fe833930dd1f4e4b5a5/tools/linter/adapters/pip_init.py',
80+
'--lint-name=mypy_linter.py',
81+
'--lint-link=https://raw.githubusercontent.com/pytorch/pytorch/b8895df8db23213a0db50fe833930dd1f4e4b5a5/tools/linter/adapters/mypy_linter.py',
82+
'--',
6683
'--dry-run={{DRYRUN}}',
6784
"boto3==1.38.29",
6885
"botocore==1.38.29",
@@ -93,9 +110,20 @@ exclude_patterns = [
93110
"tools/stronghold/src/api/types.py",
94111
"tools/stronghold/tests/api/test_ast_param_types.py",
95112
]
113+
init_command = [
114+
'python3',
115+
'tools/linter/adapters/run_from_link_linter.py',
116+
'--lint-name=grep_linter.py',
117+
'--lint-link=https://raw.githubusercontent.com/pytorch/pytorch/267f82b860ccdf32df3dcb92e2435b64ba0f117a/tools/linter/adapters/grep_linter.py',
118+
'--',
119+
'--dry-run={{DRYRUN}}',
120+
]
96121
command = [
97122
'python3',
98-
'tools/linter/adapters/grep_linter.py',
123+
'tools/linter/adapters/run_from_link_linter.py',
124+
'--run-lint',
125+
'--lint-name=grep_linter.py',
126+
'--',
99127
'--pattern=# type:\s*ignore([^\[]|$)',
100128
'--linter-name=TYPEIGNORE',
101129
'--error-name=unqualified type: ignore',
@@ -110,9 +138,20 @@ command = [
110138
[[linter]]
111139
code = 'NOQA'
112140
include_patterns = ['**/*.py', '**/*.pyi']
141+
init_command = [
142+
'python3',
143+
'tools/linter/adapters/run_from_link_linter.py',
144+
'--lint-name=grep_linter.py',
145+
'--lint-link=https://raw.githubusercontent.com/pytorch/pytorch/267f82b860ccdf32df3dcb92e2435b64ba0f117a/tools/linter/adapters/grep_linter.py',
146+
'--',
147+
'--dry-run={{DRYRUN}}',
148+
]
113149
command = [
114150
'python3',
115-
'tools/linter/adapters/grep_linter.py',
151+
'tools/linter/adapters/run_from_link_linter.py',
152+
'--run-lint',
153+
'--lint-name=grep_linter.py',
154+
'--',
116155
'--pattern=# noqa([^:]|$)',
117156
'--linter-name=NOQA',
118157
'--error-name=unqualified noqa',
@@ -139,9 +178,19 @@ exclude_patterns=[
139178
'.github/actions/upload-artifact-s3/dist/upload/index.js',
140179
'tools/clang-tidy-checks/*-patches/**',
141180
]
181+
init_command = [
182+
'python3',
183+
'tools/linter/adapters/run_from_link_linter.py',
184+
'--lint-name=newlines_linter.py',
185+
'--lint-link=https://raw.githubusercontent.com/pytorch/pytorch/267f82b860ccdf32df3dcb92e2435b64ba0f117a/tools/linter/adapters/newlines_linter.py',
186+
'--',
187+
'--dry-run={{DRYRUN}}',
188+
]
142189
command = [
143190
'python3',
144-
'tools/linter/adapters/newlines_linter.py',
191+
'tools/linter/adapters/run_from_link_linter.py',
192+
'--run-lint',
193+
'--lint-name=newlines_linter.py',
145194
'--',
146195
'@{{PATHSFILE}}',
147196
]
@@ -159,9 +208,20 @@ exclude_patterns = [
159208
'.github/actions/setup-ssh/index.js',
160209
'.github/actions/upload-artifact-s3/dist/upload/index.js',
161210
]
211+
init_command = [
212+
'python3',
213+
'tools/linter/adapters/run_from_link_linter.py',
214+
'--lint-name=newlines_linter.py',
215+
'--lint-link=https://raw.githubusercontent.com/pytorch/pytorch/267f82b860ccdf32df3dcb92e2435b64ba0f117a/tools/linter/adapters/newlines_linter.py',
216+
'--',
217+
'--dry-run={{DRYRUN}}',
218+
]
162219
command = [
163220
'python3',
164-
'tools/linter/adapters/grep_linter.py',
221+
'tools/linter/adapters/run_from_link_linter.py',
222+
'--run-lint',
223+
'--lint-name=grep_linter.py',
224+
'--',
165225
'--pattern=[[:blank:]]$',
166226
'--linter-name=SPACES',
167227
'--error-name=trailing spaces',
@@ -189,9 +249,20 @@ exclude_patterns = [
189249
'terraform-aws-github-runner/**',
190250
'aws/ami/windows/**',
191251
]
252+
init_command = [
253+
'python3',
254+
'tools/linter/adapters/run_from_link_linter.py',
255+
'--lint-name=newlines_linter.py',
256+
'--lint-link=https://raw.githubusercontent.com/pytorch/pytorch/267f82b860ccdf32df3dcb92e2435b64ba0f117a/tools/linter/adapters/newlines_linter.py',
257+
'--',
258+
'--dry-run={{DRYRUN}}',
259+
]
192260
command = [
193261
'python3',
194-
'tools/linter/adapters/grep_linter.py',
262+
'tools/linter/adapters/run_from_link_linter.py',
263+
'--run-lint',
264+
'--lint-name=grep_linter.py',
265+
'--',
195266
# @lint-ignore TXT2
196267
'--pattern= ',
197268
'--linter-name=TABS',
@@ -222,9 +293,20 @@ exclude_patterns = [
222293
".github/workflows/validate-linux-binaries.yml",
223294
".github/workflows/validate-repackaged-binary-sizes.yml",
224295
]
296+
init_command = [
297+
'python3',
298+
'tools/linter/adapters/run_from_link_linter.py',
299+
'--lint-name=grep_linter.py',
300+
'--lint-link=https://raw.githubusercontent.com/pytorch/pytorch/267f82b860ccdf32df3dcb92e2435b64ba0f117a/tools/linter/adapters/grep_linter.py',
301+
'--',
302+
'--dry-run={{DRYRUN}}',
303+
]
225304
command = [
226305
'python3',
227-
'tools/linter/adapters/grep_linter.py',
306+
'tools/linter/adapters/run_from_link_linter.py',
307+
'--run-lint',
308+
'--lint-name=grep_linter.py',
309+
'--',
228310
"""--pattern=\
229311
(pip|pip3|python -m pip|python3 -m pip|python3 -mpip|python -mpip) \
230312
install ([a-zA-Z0-9][A-Za-z0-9\\._\\-]+)([^/=<>~!]+)[A-Za-z0-9\\._\\-\\*\\+\\!]*$\
@@ -257,9 +339,19 @@ exclude_patterns = [
257339
# Putting this exclusion just to get the linter running.
258340
"tools/stronghold/bin/build-check-api-compatibility",
259341
]
342+
init_command = [
343+
'python3',
344+
'tools/linter/adapters/run_from_link_linter.py',
345+
'--lint-name=exec_linter.py',
346+
'--lint-link=https://raw.githubusercontent.com/pytorch/pytorch/267f82b860ccdf32df3dcb92e2435b64ba0f117a/tools/linter/adapters/exec_linter.py',
347+
'--',
348+
'--dry-run={{DRYRUN}}',
349+
]
260350
command = [
261351
'python3',
262-
'tools/linter/adapters/exec_linter.py',
352+
'tools/linter/adapters/run_from_link_linter.py',
353+
'--run-lint',
354+
'--lint-name=exec_linter.py',
263355
'--',
264356
'@{{PATHSFILE}}',
265357
]
@@ -275,14 +367,23 @@ include_patterns = [
275367
]
276368
command = [
277369
'python3',
278-
'tools/linter/adapters/actionlint_linter.py',
370+
'tools/linter/adapters/run_from_link_linter.py',
371+
'--run-lint',
372+
'--lint-name=actionlint_linter.py',
373+
'--',
279374
'--binary=.lintbin/actionlint',
280375
'--',
281376
'@{{PATHSFILE}}',
282377
]
283378
init_command = [
284379
'python3',
285-
'tools/linter/adapters/s3_init.py',
380+
'tools/linter/adapters/run_from_link_linter.py',
381+
'--run-init',
382+
'--init-name=s3_init.py',
383+
'--init-link=https://raw.githubusercontent.com/pytorch/pytorch/b8b840be3d03cf2f7dc4a373f9b0a95f1411cb89/tools/linter/adapters/s3_init.py',
384+
'--lint-name=actionlint_linter.py',
385+
'--lint-link=https://raw.githubusercontent.com/pytorch/pytorch/267f82b860ccdf32df3dcb92e2435b64ba0f117a/tools/linter/adapters/actionlint_linter.py',
386+
'--',
286387
'--config-json=tools/linter/adapters/s3_init_config.json',
287388
'--linter=actionlint',
288389
'--dry-run={{DRYRUN}}',
@@ -299,6 +400,7 @@ include_patterns = [
299400
command = [
300401
'python3',
301402
'tools/linter/adapters/run_from_link_linter.py',
403+
'--run-lint',
302404
'--lint-name=pyfmt_linter.py',
303405
'--',
304406
'@{{PATHSFILE}}'
@@ -308,9 +410,9 @@ init_command = [
308410
'tools/linter/adapters/run_from_link_linter.py',
309411
'--run-init',
310412
'--init-name=pip_init.py',
311-
'--init-link=https://raw.githubusercontent.com/pytorch/test-infra/main/tools/linter/adapters/pip_init.py',
413+
'--init-link=https://raw.githubusercontent.com/pytorch/pytorch/b8895df8db23213a0db50fe833930dd1f4e4b5a5/tools/linter/adapters/pip_init.py',
312414
'--lint-name=pyfmt_linter.py',
313-
'--lint-link=https://raw.githubusercontent.com/pytorch/test-infra/main/tools/linter/adapters/pyfmt_linter.py',
415+
'--lint-link=https://raw.githubusercontent.com/pytorch/pytorch/267f82b860ccdf32df3dcb92e2435b64ba0f117a/tools/linter/adapters/pyfmt_linter.py',
314416
'--',
315417
'--dry-run={{DRYRUN}}',
316418
'--no-black-binary',
@@ -325,9 +427,20 @@ is_formatter = true
325427
code = 'COPYRIGHT'
326428
include_patterns = ['**']
327429
exclude_patterns = ['.lintrunner.toml', '**/fixtures/**']
430+
init_command = [
431+
'python3',
432+
'tools/linter/adapters/run_from_link_linter.py',
433+
'--lint-name=grep_linter.py',
434+
'--lint-link=https://raw.githubusercontent.com/pytorch/pytorch/267f82b860ccdf32df3dcb92e2435b64ba0f117a/tools/linter/adapters/grep_linter.py',
435+
'--',
436+
'--dry-run={{DRYRUN}}',
437+
]
328438
command = [
329439
'python3',
330-
'tools/linter/adapters/grep_linter.py',
440+
'tools/linter/adapters/run_from_link_linter.py',
441+
'--run-lint',
442+
'--lint-name=grep_linter.py',
443+
'--',
331444
'--pattern=Confidential and proprietary',
332445
'--linter-name=COPYRIGHT',
333446
'--error-name=Confidential Code',
@@ -342,9 +455,19 @@ command = [
342455
[[linter]]
343456
code = 'LINTRUNNER_VERSION'
344457
include_patterns = ['**']
458+
init_command = [
459+
'python3',
460+
'tools/linter/adapters/run_from_link_linter.py',
461+
'--lint-name=lintrunner_version_linter.py',
462+
'--lint-link=https://raw.githubusercontent.com/pytorch/pytorch/267f82b860ccdf32df3dcb92e2435b64ba0f117a/tools/linter/adapters/lintrunner_version_linter.py',
463+
'--',
464+
'--dry-run={{DRYRUN}}',
465+
]
345466
command = [
346467
'python3',
347-
'tools/linter/adapters/lintrunner_version_linter.py'
468+
'tools/linter/adapters/run_from_link_linter.py',
469+
'--run-lint',
470+
'--lint-name=lintrunner_version_linter.py',
348471
]
349472

350473
[[linter]]
@@ -360,15 +483,24 @@ exclude_patterns = [
360483
]
361484
command = [
362485
'python3',
363-
'tools/linter/adapters/ruff_linter.py',
486+
'tools/linter/adapters/run_from_link_linter.py',
487+
'--run-lint',
488+
'--lint-name=ruff_linter.py',
489+
'--',
364490
'--config=pyproject.toml',
365491
'--show-disable',
366492
'--',
367493
'@{{PATHSFILE}}'
368494
]
369495
init_command = [
370496
'python3',
371-
'tools/linter/adapters/pip_init.py',
497+
'tools/linter/adapters/run_from_link_linter.py',
498+
'--run-init',
499+
'--init-name=pip_init.py',
500+
'--init-link=https://raw.githubusercontent.com/pytorch/pytorch/b8895df8db23213a0db50fe833930dd1f4e4b5a5/tools/linter/adapters/pip_init.py',
501+
'--lint-name=ruff_linter.py',
502+
'--lint-link=https://raw.githubusercontent.com/pytorch/pytorch/d0b98746039990d9f82f2c72d7256f89ac69875a/tools/linter/adapters/ruff_linter.py',
503+
'--',
372504
'--dry-run={{DRYRUN}}',
373505
'ruff==0.8.4', # sync with PYFMT
374506
]
@@ -384,7 +516,11 @@ command = [
384516
]
385517
init_command = [
386518
'python3',
387-
'tools/linter/adapters/pip_init.py',
519+
'tools/linter/adapters/run_from_link_linter.py',
520+
'--run-init',
521+
'--init-name=pip_init.py',
522+
'--init-link=https://raw.githubusercontent.com/pytorch/pytorch/b8895df8db23213a0db50fe833930dd1f4e4b5a5/tools/linter/adapters/pip_init.py',
523+
'--',
388524
'--dry-run={{DRYRUN}}',
389525
'sqlfluff==3.3.0',
390526
]

0 commit comments

Comments
 (0)