mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
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:
@ -61,13 +61,18 @@ def run_command(
|
|||||||
|
|
||||||
|
|
||||||
def lint_file(
|
def lint_file(
|
||||||
filename: str,
|
matching_line: str,
|
||||||
allowlist_pattern: str,
|
allowlist_pattern: str,
|
||||||
replace_pattern: str,
|
replace_pattern: str,
|
||||||
linter_name: str,
|
linter_name: str,
|
||||||
error_name: str,
|
error_name: str,
|
||||||
error_description: str,
|
error_description: str,
|
||||||
) -> LintMessage | None:
|
) -> 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:
|
if allowlist_pattern:
|
||||||
try:
|
try:
|
||||||
proc = run_command(["grep", "-nEHI", allowlist_pattern, filename])
|
proc = run_command(["grep", "-nEHI", allowlist_pattern, filename])
|
||||||
@ -139,8 +144,8 @@ def lint_file(
|
|||||||
)
|
)
|
||||||
|
|
||||||
return LintMessage(
|
return LintMessage(
|
||||||
path=filename,
|
path=split[0],
|
||||||
line=None,
|
line=int(split[1]) if len(split) > 1 else None,
|
||||||
char=None,
|
char=None,
|
||||||
code=linter_name,
|
code=linter_name,
|
||||||
severity=LintSeverity.ERROR,
|
severity=LintSeverity.ERROR,
|
||||||
@ -252,12 +257,9 @@ def main() -> None:
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
lines = proc.stdout.decode().splitlines()
|
lines = proc.stdout.decode().splitlines()
|
||||||
# matching_line looks like:
|
for line in lines:
|
||||||
# tools/linter/clangtidy_linter.py:13:import foo.bar.baz
|
|
||||||
files = {line.split(":")[0] for line in lines}
|
|
||||||
for file in files:
|
|
||||||
lint_message = lint_file(
|
lint_message = lint_file(
|
||||||
file,
|
line,
|
||||||
args.allowlist_pattern,
|
args.allowlist_pattern,
|
||||||
args.replace_pattern,
|
args.replace_pattern,
|
||||||
args.linter_name,
|
args.linter_name,
|
||||||
|
Reference in New Issue
Block a user