-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Merged by Bors] - fix(*): fix many indentation mistakes #10163
Conversation
jcommelin
commented
Nov 4, 2021
•
edited
Loading
edited
apply linear_equiv.surjective, | ||
rw [←linear_map.range_eq_top, finsupp.range_total], | ||
simpa using s, }, | ||
-- We construct an surjective linear map `(w → R) →ₗ[R] (ι → R)`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-- We construct an surjective linear map `(w → R) →ₗ[R] (ι → R)`, | |
-- We construct a surjective linear map `(w → R) →ₗ[R] (ι → R)`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would destroy the "this PR only changes whitespace" property of this PR. Do we care?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to keep the changes whitespace-only, as there is enough to review in the linter itself :)
Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: tb65536 <tb65536@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I understand correctly that the indentation changes included in this PR are exactly those flagged by the linter, and there are no false positives you noticed? In that case, I'm happy to approve the overall design of the linter for now, and see how it responds to new code.
I suspect that doing the linter line-by-line is going to quickly make it hard to adapt if we need to keep tweaking it (already I don't really understand the order in which the different tokens in a line are handled): a better architecture would be to parse the file into tokens and advance the state token-by-token. That should make it easier to deal with situations like:
def blah := foo (some_complicated - expression) begin
correctly_indented_tac,
{ subtac },
{ another_subtac }
end
scripts/lint-style.py
Outdated
if line.find("begin") > 0 and in_prf == 0: | ||
# complicate proof block syntax | ||
check_rest_of_block = False | ||
if lstr.find("begin") > 0: | ||
# complicate proof block syntax | ||
check_rest_of_block = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have an example of a "normal" piece of Lean where the second if
would apply that is not handled by the first if
?
if line.find("begin") > 0 and in_prf == 0: | |
# complicate proof block syntax | |
check_rest_of_block = False | |
if lstr.find("begin") > 0: | |
# complicate proof block syntax | |
check_rest_of_block = False | |
# Don't check complicated proof block syntax: | |
# - a `begin` block in the middle of term mode | |
if line.find("begin") > 0 and in_prf == 0: | |
check_rest_of_block = False | |
# - another case where `begin` appears somewhere else in the line | |
if lstr.find("begin") > 0: | |
check_rest_of_block = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the first if
can just be removed. I don't want to check the indentation of subproofs of the form
have foo : bla := begin
stuff
end,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, nope. I clarified how they both do useful things in the other PR.
scripts/lint-style.py
Outdated
check_rest_of_block = True | ||
ended_with_comma = False | ||
inside_special = 0 | ||
if "match" in line or "calc" in line: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm concerned checks like if "keyword" in line
are too likely to get false positives, e.g. the check for end
will match all lines containing linear_indep
end
ent
, and cause the in_prf
counter to turn negative. (It's good that you explicitly say in_prf > 0
above rather than in_prf
, or we'd get some weird errors!)
More robust would be to use re.match("\bkeyword\b", line)
(where \b
is regex syntax for "word boundary").
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in the other PR
scripts/lint-style.py
Outdated
indent_lvl -= 2 | ||
in_prf -= 1 | ||
indent_lvl += 2 * line.count('{') # potential innocent(?) clash with set-builder notation | ||
indent_lvl -= 2 * line.count('}') # there can be multiple closing braces on one line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the motivation for checking [
/]
indent level before the "reset" logic and {
/}
indent level afterwards?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[
/]
is checking the nesting level, and if we're nested inside such a special block we don't want to do anything.
Moving these indent_lvl
lines for {
/}
would break the indent checking code in the lines above.
apply linear_equiv.surjective, | ||
rw [←linear_map.range_eq_top, finsupp.range_total], | ||
simpa using s, }, | ||
-- We construct an surjective linear map `(w → R) →ₗ[R] (ι → R)`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to keep the changes whitespace-only, as there is enough to review in the linter itself :)
Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>
bors merge |
bors r+ |
Pull request successfully merged into master. Build succeeded: |