Skip to content

Commit f338e2a

Browse files
committed
chore(lint-style.py): remove the non-terminal simp check (leanprover-community#32207)
This has been superseded by the flexible linter, which is much more nuanced and can be silenced in a much better way.
1 parent bd16f75 commit f338e2a

1 file changed

Lines changed: 1 addition & 34 deletions

File tree

scripts/lint-style.py

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
ERR_CLN = 16 # line starts with a colon
4242
ERR_IND = 17 # second line not correctly indented
4343
ERR_ARR = 18 # space after "←"
44-
ERR_NSP = 20 # non-terminal simp
4544

4645
exceptions = []
4746
new_exceptions = False
@@ -140,36 +139,6 @@ def four_spaces_in_second_line(lines, path):
140139
newlines.append((next_line_nr, new_next_line))
141140
return errors, newlines
142141

143-
flexible_tactics = ["rfl", "ring", "aesop", "norm_num", "positivity", "abel", "omega", "linarith", "nlinarith"]
144-
145-
def nonterminal_simp_check(lines, path):
146-
errors = []
147-
newlines = []
148-
annotated_lines = list(annotate_comments(lines))
149-
for (line_nr, line, is_comment), (_, next_line, _) in zip(annotated_lines,
150-
annotated_lines[1:]):
151-
# Check if the current line matches whitespace followed by "simp"
152-
new_line = line
153-
# TODO it would be better to use a regex like r"^\s*simp( \[.*\])?( at .*)?$" and thereby
154-
# catch all possible simp invocations. Adding this will require more initial cleanup or
155-
# nolint.
156-
if (not is_comment) and re.search(r"^\s*simp$", line):
157-
# Calculate the number of spaces before the first non-space character in the line
158-
num_spaces = len(line) - len(line.lstrip())
159-
# Calculate the number of spaces before the first non-space character in the next line
160-
stripped_next_line = next_line.lstrip()
161-
162-
if not (next_line == '\n' or next_line.startswith("#") or stripped_next_line.startswith("--") or any(f in next_line for f in flexible_tactics)):
163-
num_next_spaces = len(next_line) - len(stripped_next_line)
164-
# Check if the number of leading spaces is the same
165-
if num_spaces == num_next_spaces:
166-
# If so, the simp is nonterminal
167-
errors += [(ERR_NSP, line_nr, path)]
168-
new_line = line.replace("simp", "simp?")
169-
newlines.append((line_nr, new_line))
170-
newlines.append(lines[-1])
171-
return errors, newlines
172-
173142

174143
def isolated_by_dot_semicolon_check(lines, path):
175144
errors = []
@@ -238,8 +207,6 @@ def format_errors(errors):
238207
output_message(path, line_nr, "ERR_IND", "If the theorem/def statement requires multiple lines, indent it correctly (4 spaces or 2 for `|`)")
239208
if errno == ERR_ARR:
240209
output_message(path, line_nr, "ERR_ARR", "Missing space after '←'.")
241-
if errno == ERR_NSP:
242-
output_message(path, line_nr, "ERR_NSP", "Non-terminal simp. Replace with `simp?` and use the suggested output")
243210

244211
def lint(path, fix=False):
245212
global new_exceptions
@@ -258,7 +225,7 @@ def lint(path, fix=False):
258225

259226
# if we haven't been asked to fix errors, or there are no errors or no fixes, we're done
260227
if fix and new_exceptions and enum_lines != newlines:
261-
path.with_name(path.name + '.bak').write_text("".join(l for _,l in newlines), encoding = "utf8")
228+
path.with_name(path.name + '.bak').write_text("".join(l for _, l in newlines), encoding = "utf8")
262229
shutil.move(path.with_name(path.name + '.bak'), path)
263230

264231
fix = "--fix" in sys.argv

0 commit comments

Comments
 (0)