[lint] small updates to .lintrunner.toml (#67942)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/67942

- Change "name" to "code" for consistency with linttool and LintMessage
format.
- Change "args" and "init_args" to "command" and "init_command" for
consistency with internal representation.

Test Plan: Imported from OSS

Reviewed By: H-Huang

Differential Revision: D32250606

Pulled By: suo

fbshipit-source-id: 557fef731bab9adca7ab1e7cc41b996956076b05
This commit is contained in:
Michael Suo 2021-11-08 09:34:39 -08:00 committed by Facebook GitHub Bot
parent d201102d36
commit 8e2528132b
9 changed files with 40 additions and 66 deletions

View File

@ -1,5 +1,5 @@
[[linter]] [[linter]]
name = 'FLAKE8' code = 'FLAKE8'
include_patterns = ['**/*.py'] include_patterns = ['**/*.py']
exclude_patterns = [ exclude_patterns = [
'.git/**', '.git/**',
@ -18,14 +18,14 @@ exclude_patterns = [
'venv/**', 'venv/**',
'**/*.pyi', '**/*.pyi',
] ]
args = [ command = [
'python3', 'python3',
'tools/linter/adapters/flake8_linter.py', 'tools/linter/adapters/flake8_linter.py',
'--binary=flake8', '--binary=flake8',
'--', '--',
'@{{PATHSFILE}}' '@{{PATHSFILE}}'
] ]
init_args = [ init_command = [
'python3', 'python3',
'tools/linter/adapters/pip_init.py', 'tools/linter/adapters/pip_init.py',
'--dry-run={{DRYRUN}}', '--dry-run={{DRYRUN}}',
@ -41,7 +41,7 @@ init_args = [
[[linter]] [[linter]]
name = 'CLANGFORMAT' code = 'CLANGFORMAT'
include_patterns = [ include_patterns = [
'c10/**/*.h', 'c10/**/*.h',
'c10/**/*.cpp', 'c10/**/*.cpp',
@ -54,8 +54,7 @@ include_patterns = [
'test/cpp/tensorexpr/**/*.h', 'test/cpp/tensorexpr/**/*.h',
'test/cpp/tensorexpr/**/*.cpp', 'test/cpp/tensorexpr/**/*.cpp',
] ]
exclude_patterns = [] command = [
args = [
'python3', 'python3',
'tools/linter/adapters/clangformat_linter.py', 'tools/linter/adapters/clangformat_linter.py',
'--binary=clang-format', '--binary=clang-format',
@ -64,7 +63,7 @@ args = [
] ]
[[linter]] [[linter]]
name = 'MYPY' code = 'MYPY'
include_patterns = [ include_patterns = [
'torch/**/*.py', 'torch/**/*.py',
'caffe2/**/*.py', 'caffe2/**/*.py',
@ -84,7 +83,7 @@ exclude_patterns = [
'torch/csrc/**', 'torch/csrc/**',
'torch/distributed/elastic/agent/server/api.py', 'torch/distributed/elastic/agent/server/api.py',
] ]
args = [ command = [
'python3', 'python3',
'tools/linter/adapters/mypy_linter.py', 'tools/linter/adapters/mypy_linter.py',
'--binary=mypy', '--binary=mypy',
@ -92,7 +91,7 @@ args = [
'--', '--',
'@{{PATHSFILE}}' '@{{PATHSFILE}}'
] ]
init_args = [ init_command = [
'python3', 'python3',
'tools/linter/adapters/pip_init.py', 'tools/linter/adapters/pip_init.py',
'--dry-run={{DRYRUN}}', '--dry-run={{DRYRUN}}',
@ -104,7 +103,7 @@ init_args = [
] ]
[[linter]] [[linter]]
name = 'MYPY_STRICT' code = 'MYPYSTRICT'
include_patterns = [ include_patterns = [
'.github/**/*.py', '.github/**/*.py',
'benchmarks/instruction_counts/**/*.py', 'benchmarks/instruction_counts/**/*.py',
@ -114,8 +113,7 @@ include_patterns = [
'torch/utils/benchmark/utils/timer.py', 'torch/utils/benchmark/utils/timer.py',
'torch/utils/benchmark/utils/valgrind_wrapper/**/*.py', 'torch/utils/benchmark/utils/valgrind_wrapper/**/*.py',
] ]
exclude_patterns = [] command = [
args = [
'python3', 'python3',
'tools/linter/adapters/mypy_linter.py', 'tools/linter/adapters/mypy_linter.py',
'--binary=mypy', '--binary=mypy',
@ -125,17 +123,23 @@ args = [
] ]
[[linter]] [[linter]]
name = 'CLANGTIDY' code = 'CLANGTIDY'
include_patterns = ['**/*.cpp'] include_patterns = [
exclude_patterns = [] '**/*.cpp',
init_args = [ 'torch/csrc/fx/**/*.cpp',
'torch/csrc/utils/**/*.cpp',
'torch/csrc/generic/**/*.cpp',
'torch/csrc/deploy/**/*.cpp',
'torch/csrc/tensor/**/*.cpp',
]
init_command = [
'python3', 'python3',
'tools/linter/adapters/clangtidy_init.py', 'tools/linter/adapters/clangtidy_init.py',
'--dry_run={{DRYRUN}}', '--dry_run={{DRYRUN}}',
'--output_dir=.clang-tidy-bin', '--output_dir=.clang-tidy-bin',
'--output_name=clang-tidy', '--output_name=clang-tidy',
] ]
args = [ command = [
'python3', 'python3',
'tools/linter/adapters/clangtidy_linter.py', 'tools/linter/adapters/clangtidy_linter.py',
'--binary=.clang-tidy-bin/clang-tidy', '--binary=.clang-tidy-bin/clang-tidy',
@ -145,10 +149,10 @@ args = [
] ]
[[linter]] [[linter]]
name = 'TYPEIGNORE' code = 'TYPEIGNORE'
include_patterns = ['**/*.py', '**/*.pyi'] include_patterns = ['**/*.py', '**/*.pyi']
exclude_patterns = ['test/test_jit.py'] exclude_patterns = ['test/test_jit.py']
args = [ command = [
'python3', 'python3',
'tools/linter/adapters/grep_linter.py', 'tools/linter/adapters/grep_linter.py',
'--pattern=# type:\s*ignore(?!\[)', '--pattern=# type:\s*ignore(?!\[)',
@ -163,10 +167,10 @@ args = [
] ]
[[linter]] [[linter]]
name = 'NOQA' code = 'NOQA'
include_patterns = ['**/*.py', '**/*.pyi'] include_patterns = ['**/*.py', '**/*.pyi']
exclude_patterns = ['caffe2/**'] exclude_patterns = ['caffe2/**']
args = [ command = [
'python3', 'python3',
'tools/linter/adapters/grep_linter.py', 'tools/linter/adapters/grep_linter.py',
'--pattern=# type:\s*ignore(?!\[)', '--pattern=# type:\s*ignore(?!\[)',
@ -181,35 +185,33 @@ args = [
] ]
[[linter]] [[linter]]
name = 'CIRCLECI' code = 'CIRCLECI'
include_patterns=['.circleci/**'] include_patterns=['.circleci/**']
args = [ command = [
'python3', 'python3',
'tools/linter/adapters/circleci_linter.py', 'tools/linter/adapters/circleci_linter.py',
'--regen-script-working-dir=.circleci', '--regen-script-working-dir=.circleci',
'--config-yml=.circleci/config.yml', '--config-yml=.circleci/config.yml',
'--regen-script=generate_config_yml.py', '--regen-script=generate_config_yml.py',
] ]
bypass_matched_file_filter = true
[[linter]] [[linter]]
name = 'NATIVEFUNCTIONS' code = 'NATIVEFUNCTIONS'
include_patterns=['aten/src/ATen/native/native_functions.yaml'] include_patterns=['aten/src/ATen/native/native_functions.yaml']
args = [ command = [
'python3', 'python3',
'tools/linter/adapters/nativefunctions_linter.py', 'tools/linter/adapters/nativefunctions_linter.py',
'--native-functions-yml=aten/src/ATen/native/native_functions.yaml', '--native-functions-yml=aten/src/ATen/native/native_functions.yaml',
] ]
init_args = [ init_command = [
'python3', 'python3',
'tools/linter/adapters/pip_init.py', 'tools/linter/adapters/pip_init.py',
'--dry-run={{DRYRUN}}', '--dry-run={{DRYRUN}}',
'ruamel.yaml==0.17.4', 'ruamel.yaml==0.17.4',
] ]
bypass_matched_file_filter = true
[[linter]] [[linter]]
name = 'NEWLINE' code = 'NEWLINE'
include_patterns=['**'] include_patterns=['**']
exclude_patterns=[ exclude_patterns=[
'**/contrib/**', '**/contrib/**',
@ -218,7 +220,7 @@ exclude_patterns=[
'**/*.ipynb', '**/*.ipynb',
'tools/clang_format_hash/**', 'tools/clang_format_hash/**',
] ]
args = [ command = [
'python3', 'python3',
'tools/linter/adapters/newlines_linter.py', 'tools/linter/adapters/newlines_linter.py',
'--', '--',
@ -226,14 +228,14 @@ args = [
] ]
[[linter]] [[linter]]
name = 'SPACES' code = 'SPACES'
include_patterns = ['**'] include_patterns = ['**']
exclude_patterns = [ exclude_patterns = [
'**/contrib/**', '**/contrib/**',
'**/*.diff', '**/*.diff',
'third_party/**', 'third_party/**',
] ]
args = [ command = [
'python3', 'python3',
'tools/linter/adapters/grep_linter.py', 'tools/linter/adapters/grep_linter.py',
'--pattern=[[:blank:]]$', '--pattern=[[:blank:]]$',
@ -248,7 +250,7 @@ args = [
] ]
[[linter]] [[linter]]
name = 'TABS' code = 'TABS'
include_patterns = ['**'] include_patterns = ['**']
exclude_patterns = [ exclude_patterns = [
'**/*.svg', '**/*.svg',
@ -258,7 +260,7 @@ exclude_patterns = [
'**/.gitattributes', '**/.gitattributes',
'**/.gitmodules', '**/.gitmodules',
] ]
args = [ command = [
'python3', 'python3',
'tools/linter/adapters/grep_linter.py', 'tools/linter/adapters/grep_linter.py',
'--pattern=\t', '--pattern=\t',
@ -273,7 +275,7 @@ args = [
] ]
[[linter]] [[linter]]
name = 'INCLUDE' code = 'INCLUDE'
include_patterns = [ include_patterns = [
'c10/**', 'c10/**',
'aten/**', 'aten/**',
@ -282,7 +284,7 @@ include_patterns = [
exclude_patterns = [ exclude_patterns = [
'aten/src/ATen/native/quantized/cpu/qnnpack/**', 'aten/src/ATen/native/quantized/cpu/qnnpack/**',
] ]
args = [ command = [
'python3', 'python3',
'tools/linter/adapters/grep_linter.py', 'tools/linter/adapters/grep_linter.py',
'--pattern=#include "', '--pattern=#include "',
@ -297,7 +299,7 @@ args = [
] ]
[[linter]] [[linter]]
name = 'PYPIDEP' code = 'PYPIDEP'
include_patterns = ['.github/**'] include_patterns = ['.github/**']
exclude_patterns = [ exclude_patterns = [
'**/*.rst', '**/*.rst',
@ -305,7 +307,7 @@ exclude_patterns = [
'**/*.md', '**/*.md',
'**/*.diff', '**/*.diff',
] ]
args = [ command = [
'python3', 'python3',
'tools/linter/adapters/grep_linter.py', 'tools/linter/adapters/grep_linter.py',
"""--pattern=\ """--pattern=\

View File

@ -37,7 +37,6 @@ class LintMessage(NamedTuple):
original: Optional[str] original: Optional[str]
replacement: Optional[str] replacement: Optional[str]
description: Optional[str] description: Optional[str]
bypassChangedLineFiltering: Optional[bool]
IS_WINDOWS: bool = os.name == "nt" IS_WINDOWS: bool = os.name == "nt"
@ -90,7 +89,6 @@ def run_check(
stdout=err.stdout.decode("utf-8").strip() or "(empty)", stdout=err.stdout.decode("utf-8").strip() or "(empty)",
) )
), ),
bypassChangedLineFiltering=None,
) )
] ]
@ -113,7 +111,6 @@ def run_check(
"The checked-in CircleCI config.yml file does not match what was generated by the scripts. " "The checked-in CircleCI config.yml file does not match what was generated by the scripts. "
"Re-run with '-a' to accept changes." "Re-run with '-a' to accept changes."
), ),
bypassChangedLineFiltering=True,
) )
] ]

View File

@ -34,7 +34,6 @@ class LintMessage(NamedTuple):
original: Optional[str] original: Optional[str]
replacement: Optional[str] replacement: Optional[str]
description: Optional[str] description: Optional[str]
bypassChangedLineFiltering: Optional[bool]
def as_posix(name: str) -> str: def as_posix(name: str) -> str:
@ -115,7 +114,6 @@ def check_file(
"Please report an issue in pytorch/pytorch with the " "Please report an issue in pytorch/pytorch with the "
"label 'module: lint'" "label 'module: lint'"
), ),
bypassChangedLineFiltering=None,
) )
] ]
except (OSError, subprocess.CalledProcessError) as err: except (OSError, subprocess.CalledProcessError) as err:
@ -144,7 +142,6 @@ def check_file(
stdout=err.stdout.decode("utf-8").strip() or "(empty)", stdout=err.stdout.decode("utf-8").strip() or "(empty)",
) )
), ),
bypassChangedLineFiltering=None,
) )
] ]
@ -163,7 +160,6 @@ def check_file(
original=original.decode("utf-8"), original=original.decode("utf-8"),
replacement=replacement.decode("utf-8"), replacement=replacement.decode("utf-8"),
description="See https://clang.llvm.org/docs/ClangFormat.html.\nRun `lintrunner -a` to apply this patch.", description="See https://clang.llvm.org/docs/ClangFormat.html.\nRun `lintrunner -a` to apply this patch.",
bypassChangedLineFiltering=True,
) )
] ]

View File

@ -37,7 +37,6 @@ class LintMessage(NamedTuple):
original: Optional[str] original: Optional[str]
replacement: Optional[str] replacement: Optional[str]
description: Optional[str] description: Optional[str]
bypassChangedLineFiltering: Optional[bool]
def as_posix(name: str) -> str: def as_posix(name: str) -> str:
@ -146,7 +145,6 @@ def check_file(
description=( description=(
f"Failed due to {err.__class__.__name__}:\n{err}" f"Failed due to {err.__class__.__name__}:\n{err}"
), ),
bypassChangedLineFiltering=None,
) )
] ]
lint_messages = [] lint_messages = []
@ -171,7 +169,6 @@ def check_file(
severity=severities.get(match["severity"], LintSeverity.ERROR), severity=severities.get(match["severity"], LintSeverity.ERROR),
original=None, original=None,
replacement=None, replacement=None,
bypassChangedLineFiltering=None,
) )
lint_messages.append(message) lint_messages.append(message)
finally: finally:
@ -232,7 +229,6 @@ def main() -> None:
f"Could not find clang-tidy binary at {args.binary}," f"Could not find clang-tidy binary at {args.binary},"
" you may need to run `lintrunner init`." " you may need to run `lintrunner init`."
), ),
bypassChangedLineFiltering=None,
) )
print(json.dumps(err_msg._asdict()), flush=True) print(json.dumps(err_msg._asdict()), flush=True)
exit(0) exit(0)

View File

@ -35,7 +35,6 @@ class LintMessage(NamedTuple):
original: Optional[str] original: Optional[str]
replacement: Optional[str] replacement: Optional[str]
description: Optional[str] description: Optional[str]
bypassChangedLineFiltering: Optional[bool]
def as_posix(name: str) -> str: def as_posix(name: str) -> str:
@ -286,7 +285,6 @@ def check_file(
stdout=err.stdout.strip() or "(empty)", stdout=err.stdout.strip() or "(empty)",
) )
), ),
bypassChangedLineFiltering=None,
) )
] ]
@ -306,7 +304,6 @@ def check_file(
severity=severities.get(match["code"]) or get_issue_severity(match["code"]), severity=severities.get(match["code"]) or get_issue_severity(match["code"]),
original=None, original=None,
replacement=None, replacement=None,
bypassChangedLineFiltering=None,
) )
for match in RESULTS_RE.finditer(proc.stdout) for match in RESULTS_RE.finditer(proc.stdout)
] ]

View File

@ -37,7 +37,6 @@ class LintMessage(NamedTuple):
original: Optional[str] original: Optional[str]
replacement: Optional[str] replacement: Optional[str]
description: Optional[str] description: Optional[str]
bypassChangedLineFiltering: Optional[bool]
def as_posix(name: str) -> str: def as_posix(name: str) -> str:
@ -100,7 +99,6 @@ def lint_file(
stdout=err.stdout.decode("utf-8").strip() or "(empty)", stdout=err.stdout.decode("utf-8").strip() or "(empty)",
) )
), ),
bypassChangedLineFiltering=None,
) )
return LintMessage( return LintMessage(
@ -113,7 +111,6 @@ def lint_file(
original=original, original=original,
replacement=replacement, replacement=replacement,
description=error_description, description=error_description,
bypassChangedLineFiltering=None,
) )
@ -189,7 +186,6 @@ def main() -> None:
stdout=err.stdout.decode("utf-8").strip() or "(empty)", stdout=err.stdout.decode("utf-8").strip() or "(empty)",
) )
), ),
bypassChangedLineFiltering=None,
) )
print(json.dumps(err_msg._asdict()), flush=True) print(json.dumps(err_msg._asdict()), flush=True)
exit(0) exit(0)

View File

@ -35,7 +35,6 @@ class LintMessage(NamedTuple):
original: Optional[str] original: Optional[str]
replacement: Optional[str] replacement: Optional[str]
description: Optional[str] description: Optional[str]
bypassChangedLineFiltering: Optional[bool]
def as_posix(name: str) -> str: def as_posix(name: str) -> str:
@ -109,7 +108,6 @@ def check_file(
description=( description=(
f"Failed due to {err.__class__.__name__}:\n{err}" f"Failed due to {err.__class__.__name__}:\n{err}"
), ),
bypassChangedLineFiltering=None,
) )
] ]
stdout = str(proc.stdout, "utf-8").strip() stdout = str(proc.stdout, "utf-8").strip()
@ -126,7 +124,6 @@ def check_file(
severity=severities.get(match["severity"], LintSeverity.ERROR), severity=severities.get(match["severity"], LintSeverity.ERROR),
original=None, original=None,
replacement=None, replacement=None,
bypassChangedLineFiltering=None,
) )
for match in RESULTS_RE.finditer(stdout) for match in RESULTS_RE.finditer(stdout)
] ]

View File

@ -40,7 +40,6 @@ class LintMessage(NamedTuple):
original: Optional[str] original: Optional[str]
replacement: Optional[str] replacement: Optional[str]
description: Optional[str] description: Optional[str]
bypassChangedLineFiltering: Optional[bool]
if __name__ == "__main__": if __name__ == "__main__":
@ -75,7 +74,6 @@ if __name__ == "__main__":
original=None, original=None,
replacement=None, replacement=None,
description=f"Failed due to {err.__class__.__name__}:\n{err}", description=f"Failed due to {err.__class__.__name__}:\n{err}",
bypassChangedLineFiltering=None,
) )
print(json.dumps(msg._asdict()), flush=True) print(json.dumps(msg._asdict()), flush=True)
@ -102,7 +100,6 @@ if __name__ == "__main__":
"YAML roundtrip failed; run `lintrunner --take NATIVEFUNCTIONS -a` to apply the suggested changes. " "YAML roundtrip failed; run `lintrunner --take NATIVEFUNCTIONS -a` to apply the suggested changes. "
"If you think this is in error, please see tools/linter/adapters/nativefunctions_linter.py" "If you think this is in error, please see tools/linter/adapters/nativefunctions_linter.py"
), ),
bypassChangedLineFiltering=None,
) )
print(json.dumps(msg._asdict()), flush=True) print(json.dumps(msg._asdict()), flush=True)

View File

@ -31,7 +31,6 @@ class LintMessage(NamedTuple):
original: Optional[str] original: Optional[str]
replacement: Optional[str] replacement: Optional[str]
description: Optional[str] description: Optional[str]
bypassChangedLineFiltering: Optional[bool]
def correct_trailing_newlines(filename: str) -> bool: def correct_trailing_newlines(filename: str) -> bool:
@ -69,7 +68,6 @@ def check_file(filename: str) -> Optional[LintMessage]:
original=None, original=None,
replacement=None, replacement=None,
description="Trailing newline found. Run `lintunner --take NEWLINE -a` to apply changes.", description="Trailing newline found. Run `lintunner --take NEWLINE -a` to apply changes.",
bypassChangedLineFiltering=None,
) )
else: else:
@ -94,7 +92,6 @@ def check_file(filename: str) -> Optional[LintMessage]:
original=None, original=None,
replacement=None, replacement=None,
description=f"utf-8 decoding failed due to {err.__class__.__name__}:\n{err}", description=f"utf-8 decoding failed due to {err.__class__.__name__}:\n{err}",
bypassChangedLineFiltering=None,
) )
return LintMessage( return LintMessage(
@ -107,7 +104,6 @@ def check_file(filename: str) -> Optional[LintMessage]:
original=original, original=original,
replacement=original.rstrip("\n") + "\n", replacement=original.rstrip("\n") + "\n",
description="Trailing newline found. Run `lintunner --take NEWLINE -a` to apply changes.", description="Trailing newline found. Run `lintunner --take NEWLINE -a` to apply changes.",
bypassChangedLineFiltering=None,
) )