-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove newline after code block open (#3035)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
- Loading branch information
1 parent
6d32ab0
commit 4bb7bf2
Showing
9 changed files
with
271 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
189 changes: 189 additions & 0 deletions
189
tests/data/preview/remove_newline_after_code_block_open.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
import random | ||
|
||
|
||
def foo1(): | ||
|
||
print("The newline above me should be deleted!") | ||
|
||
|
||
def foo2(): | ||
|
||
|
||
|
||
print("All the newlines above me should be deleted!") | ||
|
||
|
||
def foo3(): | ||
|
||
print("No newline above me!") | ||
|
||
print("There is a newline above me, and that's OK!") | ||
|
||
|
||
def foo4(): | ||
|
||
# There is a comment here | ||
|
||
print("The newline above me should not be deleted!") | ||
|
||
|
||
class Foo: | ||
def bar(self): | ||
|
||
print("The newline above me should be deleted!") | ||
|
||
|
||
for i in range(5): | ||
|
||
print(f"{i}) The line above me should be removed!") | ||
|
||
|
||
for i in range(5): | ||
|
||
|
||
|
||
print(f"{i}) The lines above me should be removed!") | ||
|
||
|
||
for i in range(5): | ||
|
||
for j in range(7): | ||
|
||
print(f"{i}) The lines above me should be removed!") | ||
|
||
|
||
if random.randint(0, 3) == 0: | ||
|
||
print("The new line above me is about to be removed!") | ||
|
||
|
||
if random.randint(0, 3) == 0: | ||
|
||
|
||
|
||
|
||
print("The new lines above me is about to be removed!") | ||
|
||
|
||
if random.randint(0, 3) == 0: | ||
if random.uniform(0, 1) > 0.5: | ||
print("Two lines above me are about to be removed!") | ||
|
||
|
||
while True: | ||
|
||
print("The newline above me should be deleted!") | ||
|
||
|
||
while True: | ||
|
||
|
||
|
||
print("The newlines above me should be deleted!") | ||
|
||
|
||
while True: | ||
|
||
while False: | ||
|
||
print("The newlines above me should be deleted!") | ||
|
||
|
||
with open("/path/to/file.txt", mode="w") as file: | ||
|
||
file.write("The new line above me is about to be removed!") | ||
|
||
|
||
with open("/path/to/file.txt", mode="w") as file: | ||
|
||
|
||
|
||
file.write("The new lines above me is about to be removed!") | ||
|
||
|
||
with open("/path/to/file.txt", mode="r") as read_file: | ||
|
||
with open("/path/to/output_file.txt", mode="w") as write_file: | ||
|
||
write_file.writelines(read_file.readlines()) | ||
|
||
# output | ||
|
||
import random | ||
|
||
|
||
def foo1(): | ||
print("The newline above me should be deleted!") | ||
|
||
|
||
def foo2(): | ||
print("All the newlines above me should be deleted!") | ||
|
||
|
||
def foo3(): | ||
print("No newline above me!") | ||
|
||
print("There is a newline above me, and that's OK!") | ||
|
||
|
||
def foo4(): | ||
# There is a comment here | ||
|
||
print("The newline above me should not be deleted!") | ||
|
||
|
||
class Foo: | ||
def bar(self): | ||
print("The newline above me should be deleted!") | ||
|
||
|
||
for i in range(5): | ||
print(f"{i}) The line above me should be removed!") | ||
|
||
|
||
for i in range(5): | ||
print(f"{i}) The lines above me should be removed!") | ||
|
||
|
||
for i in range(5): | ||
for j in range(7): | ||
print(f"{i}) The lines above me should be removed!") | ||
|
||
|
||
if random.randint(0, 3) == 0: | ||
print("The new line above me is about to be removed!") | ||
|
||
|
||
if random.randint(0, 3) == 0: | ||
print("The new lines above me is about to be removed!") | ||
|
||
|
||
if random.randint(0, 3) == 0: | ||
if random.uniform(0, 1) > 0.5: | ||
print("Two lines above me are about to be removed!") | ||
|
||
|
||
while True: | ||
print("The newline above me should be deleted!") | ||
|
||
|
||
while True: | ||
print("The newlines above me should be deleted!") | ||
|
||
|
||
while True: | ||
while False: | ||
print("The newlines above me should be deleted!") | ||
|
||
|
||
with open("/path/to/file.txt", mode="w") as file: | ||
file.write("The new line above me is about to be removed!") | ||
|
||
|
||
with open("/path/to/file.txt", mode="w") as file: | ||
file.write("The new lines above me is about to be removed!") | ||
|
||
|
||
with open("/path/to/file.txt", mode="r") as read_file: | ||
with open("/path/to/output_file.txt", mode="w") as write_file: | ||
write_file.writelines(read_file.readlines()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
def http_status(status): | ||
|
||
match status: | ||
|
||
case 400: | ||
|
||
return "Bad request" | ||
|
||
case 401: | ||
|
||
return "Unauthorized" | ||
|
||
case 403: | ||
|
||
return "Forbidden" | ||
|
||
case 404: | ||
|
||
return "Not found" | ||
|
||
# output | ||
def http_status(status): | ||
match status: | ||
case 400: | ||
return "Bad request" | ||
|
||
case 401: | ||
return "Unauthorized" | ||
|
||
case 403: | ||
return "Forbidden" | ||
|
||
case 404: | ||
return "Not found" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters