Skip to content

[Merged by Bors] - chore(*): remove empty lines between variable statements#11418

Closed
jcommelin wants to merge 5 commits intomasterfrom
jmc-remove-empty-variable-lines
Closed

[Merged by Bors] - chore(*): remove empty lines between variable statements#11418
jcommelin wants to merge 5 commits intomasterfrom
jmc-remove-empty-variable-lines

Conversation

@jcommelin
Copy link
Copy Markdown
Member

@jcommelin jcommelin commented Mar 16, 2024

Empty lines were removed by executing the following Python script twice

import os
import re


# Loop through each file in the repository
for dir_path, dirs, files in os.walk('.'):
  for filename in files:
    if filename.endswith('.lean'):
      file_path = os.path.join(dir_path, filename)

      # Open the file and read its contents
      with open(file_path, 'r') as file:
        content = file.read()

      # Use a regular expression to replace sequences of "variable" lines separated by empty lines
      # with sequences without empty lines
      modified_content = re.sub(r'(variable.*\n)\n(variable(?! .* in))', r'\1\2', content)

      # Write the modified content back to the file
      with open(file_path, 'w') as file:
        file.write(modified_content)

Open in Gitpod

@jcommelin jcommelin added awaiting-review easy < 20s of review time. See the lifecycle page for guidelines. awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. labels Mar 16, 2024
@MichaelStollBayreuth
Copy link
Copy Markdown
Contributor

I object to the easy tag; the time to look through all of this is definitely more than 20 seconds!

@MichaelStollBayreuth
Copy link
Copy Markdown
Contributor

In general, I have no strong feelings here.

A thought: It may make sense to separate various bits of variable declarations also optically when they correspond to a natural grouping. But perhaps in this case, it would make sense to add comments.

There may be false positives like the very first change, where the line after the empty ony is actually variable ... in. This specific case should be easy to fix, but there may be other cases.

@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 Mar 16, 2024
@sgouezel
Copy link
Copy Markdown
Contributor

I agree that the variable ... in would need special treatment. @jcommelin, what do you think?

@sgouezel sgouezel added awaiting-author A reviewer has asked the author a question or requested changes. and removed awaiting-review easy < 20s of review time. See the lifecycle page for guidelines. labels Mar 16, 2024
@ghost ghost added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Mar 16, 2024
@jcommelin
Copy link
Copy Markdown
Member Author

Fair enough! Thanks a lot for spotting this. I think I should adapt the script, and regenerate a diff.

@jcommelin jcommelin added awaiting-review and removed awaiting-author A reviewer has asked the author a question or requested changes. labels Mar 16, 2024
@ghost ghost removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Mar 16, 2024
@adomani
Copy link
Copy Markdown
Contributor

adomani commented Mar 17, 2024

If this is an actual style recommendation, should the script be added to the linting/reviewdog to prevent future lapses?

@sgouezel
Copy link
Copy Markdown
Contributor

bors r+
Thanks!

@github-actions github-actions bot added ready-to-merge This PR has been sent to bors. and removed awaiting-review labels Mar 18, 2024
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Mar 18, 2024

Merge conflict.

@ghost ghost added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Mar 18, 2024
@jcommelin jcommelin removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Mar 18, 2024
@riccardobrasca
Copy link
Copy Markdown
Member

Thanks!

bors d+

@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Mar 18, 2024

✌️ jcommelin 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 the delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). label Mar 18, 2024
@jcommelin jcommelin added the auto-merge-after-CI Please do not add manually. Requests for a bot to merge automatically once CI is done. label Mar 18, 2024
@ghost
Copy link
Copy Markdown

ghost commented Mar 18, 2024

As this PR is labelled auto-merge-after-CI, we are now sending it to bors:

bors merge

mathlib-bors bot pushed a commit that referenced this pull request Mar 18, 2024
Empty lines were removed by executing the following Python script twice
```python
import os
import re


# Loop through each file in the repository
for dir_path, dirs, files in os.walk('.'):
  for filename in files:
    if filename.endswith('.lean'):
      file_path = os.path.join(dir_path, filename)

      # Open the file and read its contents
      with open(file_path, 'r') as file:
        content = file.read()

      # Use a regular expression to replace sequences of "variable" lines separated by empty lines
      # with sequences without empty lines
      modified_content = re.sub(r'(variable.*\n)\n(variable(?! .* in))', r'\1\2', content)

      # Write the modified content back to the file
      with open(file_path, 'w') as file:
        file.write(modified_content)
```
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Mar 18, 2024

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title chore(*): remove empty lines between variable statements [Merged by Bors] - chore(*): remove empty lines between variable statements Mar 18, 2024
@mathlib-bors mathlib-bors bot closed this Mar 18, 2024
@mathlib-bors mathlib-bors bot deleted the jmc-remove-empty-variable-lines branch March 18, 2024 17:38
dagurtomas pushed a commit that referenced this pull request Mar 22, 2024
Empty lines were removed by executing the following Python script twice
```python
import os
import re


# Loop through each file in the repository
for dir_path, dirs, files in os.walk('.'):
  for filename in files:
    if filename.endswith('.lean'):
      file_path = os.path.join(dir_path, filename)

      # Open the file and read its contents
      with open(file_path, 'r') as file:
        content = file.read()

      # Use a regular expression to replace sequences of "variable" lines separated by empty lines
      # with sequences without empty lines
      modified_content = re.sub(r'(variable.*\n)\n(variable(?! .* in))', r'\1\2', content)

      # Write the modified content back to the file
      with open(file_path, 'w') as file:
        file.write(modified_content)
```
utensil pushed a commit that referenced this pull request Mar 26, 2024
Empty lines were removed by executing the following Python script twice
```python
import os
import re


# Loop through each file in the repository
for dir_path, dirs, files in os.walk('.'):
  for filename in files:
    if filename.endswith('.lean'):
      file_path = os.path.join(dir_path, filename)

      # Open the file and read its contents
      with open(file_path, 'r') as file:
        content = file.read()

      # Use a regular expression to replace sequences of "variable" lines separated by empty lines
      # with sequences without empty lines
      modified_content = re.sub(r'(variable.*\n)\n(variable(?! .* in))', r'\1\2', content)

      # Write the modified content back to the file
      with open(file_path, 'w') as file:
        file.write(modified_content)
```
xgenereux pushed a commit that referenced this pull request Apr 15, 2024
Empty lines were removed by executing the following Python script twice
```python
import os
import re


# Loop through each file in the repository
for dir_path, dirs, files in os.walk('.'):
  for filename in files:
    if filename.endswith('.lean'):
      file_path = os.path.join(dir_path, filename)

      # Open the file and read its contents
      with open(file_path, 'r') as file:
        content = file.read()

      # Use a regular expression to replace sequences of "variable" lines separated by empty lines
      # with sequences without empty lines
      modified_content = re.sub(r'(variable.*\n)\n(variable(?! .* in))', r'\1\2', content)

      # Write the modified content back to the file
      with open(file_path, 'w') as file:
        file.write(modified_content)
```
atarnoam pushed a commit that referenced this pull request Apr 16, 2024
Empty lines were removed by executing the following Python script twice
```python
import os
import re


# Loop through each file in the repository
for dir_path, dirs, files in os.walk('.'):
  for filename in files:
    if filename.endswith('.lean'):
      file_path = os.path.join(dir_path, filename)

      # Open the file and read its contents
      with open(file_path, 'r') as file:
        content = file.read()

      # Use a regular expression to replace sequences of "variable" lines separated by empty lines
      # with sequences without empty lines
      modified_content = re.sub(r'(variable.*\n)\n(variable(?! .* in))', r'\1\2', content)

      # Write the modified content back to the file
      with open(file_path, 'w') as file:
        file.write(modified_content)
```
uniwuni pushed a commit that referenced this pull request Apr 19, 2024
Empty lines were removed by executing the following Python script twice
```python
import os
import re


# Loop through each file in the repository
for dir_path, dirs, files in os.walk('.'):
  for filename in files:
    if filename.endswith('.lean'):
      file_path = os.path.join(dir_path, filename)

      # Open the file and read its contents
      with open(file_path, 'r') as file:
        content = file.read()

      # Use a regular expression to replace sequences of "variable" lines separated by empty lines
      # with sequences without empty lines
      modified_content = re.sub(r'(variable.*\n)\n(variable(?! .* in))', r'\1\2', content)

      # Write the modified content back to the file
      with open(file_path, 'w') as file:
        file.write(modified_content)
```
callesonne pushed a commit that referenced this pull request Apr 22, 2024
Empty lines were removed by executing the following Python script twice
```python
import os
import re


# Loop through each file in the repository
for dir_path, dirs, files in os.walk('.'):
  for filename in files:
    if filename.endswith('.lean'):
      file_path = os.path.join(dir_path, filename)

      # Open the file and read its contents
      with open(file_path, 'r') as file:
        content = file.read()

      # Use a regular expression to replace sequences of "variable" lines separated by empty lines
      # with sequences without empty lines
      modified_content = re.sub(r'(variable.*\n)\n(variable(?! .* in))', r'\1\2', content)

      # Write the modified content back to the file
      with open(file_path, 'w') as file:
        file.write(modified_content)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-merge-after-CI Please do not add manually. Requests for a bot to merge automatically once CI is done. 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.

5 participants