Skip to content

[Merged by Bors] - style: a linter for four spaces#7283

Closed
mo271 wants to merge 21 commits intomasterfrom
mo271/four_spaces
Closed

[Merged by Bors] - style: a linter for four spaces#7283
mo271 wants to merge 21 commits intomasterfrom
mo271/four_spaces

Conversation

@mo271
Copy link
Copy Markdown
Collaborator

@mo271 mo271 commented Sep 20, 2023

Includes an auto-fix feature with the --fix flag so that spacing suggestions will be automatically applied in review also.


Open in Gitpod

@mo271
Copy link
Copy Markdown
Collaborator Author

mo271 commented Sep 21, 2023

should be rebased once #7286 is merged

@mo271
Copy link
Copy Markdown
Collaborator Author

mo271 commented Sep 21, 2023

after adding protected, we should wait for #7296 and then rebase...

@mo271
Copy link
Copy Markdown
Collaborator Author

mo271 commented Sep 22, 2023

@alexjbest I'm trying to get this to work with reviewdog, but the "lint and suggest" workflow is skipped. Is there a way to make sure it will not be skipped?

@mo271
Copy link
Copy Markdown
Collaborator Author

mo271 commented Sep 22, 2023

waiting also for #7321

@alexjbest
Copy link
Copy Markdown
Member

@alexjbest I'm trying to get this to work with reviewdog, but the "lint and suggest" workflow is skipped. Is there a way to make sure it will not be skipped?

I recently changed it to skip draft prs, is that the reason it is skipping? In which case I'm sure it's fine to make your pr not a draft and mark it WIP instead

@mo271 mo271 marked this pull request as ready for review September 22, 2023 08:47
@mo271 mo271 added the WIP Work in progress label Sep 22, 2023
@mo271
Copy link
Copy Markdown
Collaborator Author

mo271 commented Sep 22, 2023

@alexjbest I'm trying to get this to work with reviewdog, but the "lint and suggest" workflow is skipped. Is there a way to make sure it will not be skipped?

I recently changed it to skip draft prs, is that the reason it is skipping? In which case I'm sure it's fine to make your pr not a draft and mark it WIP instead

Cool, now it is at least running. But it doesn't manage to make suggestions. ./scripts/lint_style.sh --fix works fine locally and makes these changes, but they don't get picked up by the reviewdog...

@alexjbest
Copy link
Copy Markdown
Member

That's possibly as reviewdog only makes suggestions on lines changed in your pr? I don't see any lean files changed in this pr so in that case it won't suggest anything

@mo271
Copy link
Copy Markdown
Collaborator Author

mo271 commented Sep 22, 2023

That makes perfect sense! Then everything works as intended here...

Co-authored-by: Johan Commelin <johan@commelin.net>
@mo271 mo271 removed the WIP Work in progress label Sep 22, 2023
@mo271 mo271 added awaiting-review awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. labels Sep 29, 2023
@mo271
Copy link
Copy Markdown
Collaborator Author

mo271 commented Sep 29, 2023

During the time it took for the review of #7328, a few new cases where this new linter triggered where added to mathlib. I added fixed for them here.

@github-actions github-actions bot removed the awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. label Sep 29, 2023
@alexjbest
Copy link
Copy Markdown
Member

LGTM I think this will on average reduce the number of spacing comments people have to leave on PRs, so I'm in favour

maintainer merge

@github-actions
Copy link
Copy Markdown

🚀 Pull request has been placed on the maintainer queue by alexjbest.

annotated_lines = list(annotate_comments(lines))
for (_, line, is_comment), (next_line_nr, next_line, _) in zip(annotated_lines,
annotated_lines[1:]):
# Check if the current line matches "(lemma|theorem) .* :"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this match instance too?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, why not. I'm happy to add it either in this pull request or in a separate one....

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add it in this one

mo271 and others added 2 commits September 29, 2023 13:57
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
@fpvandoorn
Copy link
Copy Markdown
Member

LGTM

bors merge
bors d+
(if new conflicts have arisen)

@bors
Copy link
Copy Markdown

bors bot commented Sep 29, 2023

✌️ mo271 can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@github-actions github-actions bot added delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). ready-to-merge This PR has been sent to bors. and removed awaiting-review labels Sep 29, 2023
bors bot pushed a commit that referenced this pull request Sep 29, 2023
Includes an auto-fix feature with the `--fix` flag so that spacing suggestions will be automatically applied in review also.



Co-authored-by: Moritz Firsching <firsching@google.com>
annotated_lines[1:]):
# Check if the current line matches "(lemma|theorem) .* :"
new_next_line = next_line
if (not is_comment) and re.search(r"^(protected )?(def|lemma|theorem) (?!.*:=).*(where)?$",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (not is_comment) and re.search(r"^(protected )?(def|lemma|theorem) (?!.*:=).*(where)?$",
if (not is_comment) and re.search(r"^(protected )?(def|lemma|theorem|instance) (?!.*:=).*(where)?$",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also presumably won't match @[simp] lemma?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, but we could be here all day trying to reproduce the grammar of lean declarations in python.
Like irreducible_def, private, noncomputable, etc. etc.
I don't think there is anything wrong with adding attributes here too, but after a point we really need to either do these things in lean itself (I assume once someone makes one such linter making the rest will be easy), or use something like tree-sitter at least so we aren't reimplementing this all the time.

@bors
Copy link
Copy Markdown

bors bot commented Sep 29, 2023

Pull request successfully merged into master.

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot changed the title style: a linter for four spaces [Merged by Bors] - style: a linter for four spaces Sep 29, 2023
@bors bors bot closed this Sep 29, 2023
@bors bors bot deleted the mo271/four_spaces branch September 29, 2023 16:40
@alexjbest
Copy link
Copy Markdown
Member

If anyone is interested I just saw this linter in action #7442, looks like it is working well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). ready-to-merge This PR has been sent to bors.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants