8000 Revert "Enable grep_linter to use -a (#144589)" · pytorch/pytorch@dddf52b · GitHub
[go: up one dir, main page]

Skip to content

Commit dddf52b

Browse files
Revert "Enable grep_linter to use -a (#144589)"
This reverts commit 3c55669. Reverted #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](#144589 (comment)))
1 parent 082c28c commit dddf52b

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

tools/linter/adapters/grep_linter.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,18 @@ def run_command(
6161

6262

6363
def lint_file(
64-
filename: str,
64+
matching_line: str,
6565
allowlist_pattern: str,
6666
replace_pattern: str,
6767
linter_name: str,
6868
error_name: str,
6969
error_description: str,
7070
) -> LintMessage | None:
71+
# matching_line looks like:
72+
# tools/linter/clangtidy_linter.py:13:import foo.bar.baz
73+
split = matching_line.split(":")
74+
filename = split[0]
75+
7176
if allowlist_pattern:
7277
try:
7378
proc = run_command(["grep", "-nEHI", allowlist_pattern, filename])
@@ -139,8 +144,8 @@ def lint_file(
139144
)
140145

141146
return LintMessage(
142-
path=filename,
143-
line=None,
147+
path=split[0],
148+
line=int(split[1]) if len(split) > 1 else None,
144149
char=None,
145150
code=linter_name,
146151
severity=LintSeverity.ERROR,
@@ -252,12 +257,9 @@ def main() -> None:
252257
sys.exit(0)
253258

254259
lines = proc.stdout.decode().splitlines()
255-
# matching_line looks like:
256-
# tools/linter/clangtidy_linter.py:13:import foo.bar.baz
257-
files = {line.split(":")[0] for line in lines}
258-
for file in files:
260+
for line in lines:
259261
lint_message = lint_file(
260-
file,
262+
line,
261263
args.allowlist_pattern,
262264
args.replace_pattern,
263265
args.linter_name,

0 commit comments

Comments
 (0)
0