Revert "Enable grep_linter to use -a (#144589)"

This reverts commit 3c55669b8814237e018a613a494564da5bea9f15.

Reverted https://github.com/pytorch/pytorch/pull/144589 on behalf of https://github.com/clee2000 due to the line parameter is kind of important and -a is not as important as I thought it was so I'm going to revert this ([comment](https://github.com/pytorch/pytorch/pull/144589#issuecomment-2608349155))
This commit is contained in:
PyTorch MergeBot
2025-01-22 21:55:27 +00:00
parent 082c28c3c6
commit dddf52b1b9

View File

@ -61,13 +61,18 @@ def run_command(
def lint_file(
filename: str,
matching_line: str,
allowlist_pattern: str,
replace_pattern: str,
linter_name: str,
error_name: str,
error_description: str,
) -> LintMessage | None:
# matching_line looks like:
# tools/linter/clangtidy_linter.py:13:import foo.bar.baz
split = matching_line.split(":")
filename = split[0]
if allowlist_pattern:
try:
proc = run_command(["grep", "-nEHI", allowlist_pattern, filename])
@ -139,8 +144,8 @@ def lint_file(
)
return LintMessage(
path=filename,
line=None,
path=split[0],
line=int(split[1]) if len(split) > 1 else None,
char=None,
code=linter_name,
severity=LintSeverity.ERROR,
@ -252,12 +257,9 @@ def main() -> None:
sys.exit(0)
lines = proc.stdout.decode().splitlines()
# matching_line looks like:
# tools/linter/clangtidy_linter.py:13:import foo.bar.baz
files = {line.split(":")[0] for line in lines}
for file in files:
for line in lines:
lint_message = lint_file(
file,
line,
args.allowlist_pattern,
args.replace_pattern,
args.linter_name,