Skip to content

Commit

Permalink
feat: lint in importing Lake in mathlib, inspired by #13779
Browse files Browse the repository at this point in the history
  • Loading branch information
grunweg committed Jun 14, 2024
1 parent 2268f78 commit 1d12263
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions scripts/lint-style.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
ERR_OPT = 6 # set_option
ERR_AUT = 7 # malformed authors list
ERR_TAC = 9 # imported Mathlib.Tactic
ERR_TAC2 = 10 # imported Lake in Mathlib
ERR_IBY = 11 # isolated by
ERR_DOT = 12 # isolated or low focusing dot
ERR_SEM = 13 # the substring " ;"
Expand Down Expand Up @@ -79,6 +80,8 @@
exceptions += [(ERR_ADN, path, None)]
elif errno == "ERR_TAC":
exceptions += [(ERR_TAC, path, None)]
elif errno == "ERR_TAC2":
exceptions += [(ERR_TAC2, path, None)]
elif errno == "ERR_NUM_LIN":
exceptions += [(ERR_NUM_LIN, path, extra[1])]
else:
Expand Down Expand Up @@ -312,6 +315,8 @@ def banned_import_check(lines, path):
break
if imports[1] in ["Mathlib.Tactic"]:
errors += [(ERR_TAC, line_nr, path)]
elif imports[1] == "Lake" or imports[1].startswith("Lake."):
errors += [(ERR_TAC2, line_nr, path)]
return errors, lines

def isolated_by_dot_semicolon_check(lines, path):
Expand Down Expand Up @@ -393,6 +398,8 @@ def format_errors(errors):
output_message(path, line_nr, "ERR_AUT", "Authors line should look like: 'Authors: Jean Dupont, Иван Иванович Иванов'")
if errno == ERR_TAC:
output_message(path, line_nr, "ERR_TAC", "Files in mathlib cannot import the whole tactic folder")
if errno == ERR_TAC2:
output_message(path, line_nr, "ERR_TAC2", "In the past, importing 'Lake' in mathlib has led to dramatic slow-downs of the linter (see e.g. mathlib4#13779). Please consider carefully if this import is useful and make sure to benchmark it. If this is fine, feel free to allow this linter.")
if errno == ERR_IBY:
output_message(path, line_nr, "ERR_IBY", "Line is an isolated 'by'")
if errno == ERR_DOT:
Expand Down

0 comments on commit 1d12263

Please sign in to comment.