Update some tests
This commit is contained in:
parent
c71b5e23bd
commit
cc3780fd9f
@ -40,8 +40,7 @@
|
||||
x = (0.000000006).hex()
|
||||
x = -100.0000j
|
||||
|
||||
if (10).real:
|
||||
...
|
||||
if (10).real: ...
|
||||
|
||||
y = 100[no]
|
||||
y = 100(no)
|
||||
|
@ -45,8 +45,7 @@ def wat():
|
||||
@deco2(with_args=True)
|
||||
# leading 3
|
||||
@deco3
|
||||
def decorated1():
|
||||
...
|
||||
def decorated1(): ...
|
||||
|
||||
|
||||
# leading 1
|
||||
@ -54,8 +53,7 @@ def decorated1():
|
||||
# leading 2
|
||||
@deco2(with_args=True)
|
||||
# leading function comment
|
||||
def decorated1():
|
||||
...
|
||||
def decorated1(): ...
|
||||
|
||||
|
||||
# Note: this is fixed in
|
||||
@ -65,8 +63,7 @@ def decorated1():
|
||||
|
||||
|
||||
# This comment should be split from `some_instruction` by two lines but isn't.
|
||||
def g():
|
||||
...
|
||||
def g(): ...
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -161,9 +161,7 @@ def tricky_asserts(self) -> None:
|
||||
8 STORE_ATTR 0 (x)
|
||||
10 LOAD_CONST 0 (None)
|
||||
12 RETURN_VALUE
|
||||
""" % (
|
||||
_C.__init__.__code__.co_firstlineno + 1,
|
||||
)
|
||||
""" % (_C.__init__.__code__.co_firstlineno + 1,)
|
||||
|
||||
assert (
|
||||
expectedexpectedexpectedexpectedexpectedexpectedexpectedexpectedexpect
|
||||
|
@ -347,9 +347,7 @@ def tricky_asserts(self) -> None:
|
||||
8 STORE_ATTR 0 (x)
|
||||
10 LOAD_CONST 0 (None)
|
||||
12 RETURN_VALUE
|
||||
""" % (
|
||||
_C.__init__.__code__.co_firstlineno + 1,
|
||||
)
|
||||
""" % (_C.__init__.__code__.co_firstlineno + 1,)
|
||||
|
||||
assert (
|
||||
expectedexpectedexpectedexpectedexpectedexpectedexpectedexpectedexpect
|
||||
|
@ -119,6 +119,7 @@ def f():
|
||||
if not prev:
|
||||
prevp = preceding_leaf(p)
|
||||
if not prevp or prevp.type in OPENING_BRACKETS:
|
||||
|
||||
return NO
|
||||
|
||||
if prevp.type == token.EQUAL:
|
||||
|
@ -514,18 +514,12 @@ async def f():
|
||||
force=False
|
||||
), "Short message"
|
||||
assert parens is TooMany
|
||||
for (x,) in (1,), (2,), (3,):
|
||||
...
|
||||
for y in ():
|
||||
...
|
||||
for z in (i for i in (1, 2, 3)):
|
||||
...
|
||||
for i in call():
|
||||
...
|
||||
for j in 1 + (2 + 3):
|
||||
...
|
||||
while this and that:
|
||||
...
|
||||
for (x,) in (1,), (2,), (3,): ...
|
||||
for y in (): ...
|
||||
for z in (i for i in (1, 2, 3)): ...
|
||||
for i in call(): ...
|
||||
for j in 1 + (2 + 3): ...
|
||||
while this and that: ...
|
||||
for (
|
||||
addr_family,
|
||||
addr_type,
|
||||
|
@ -243,12 +243,8 @@ def spaces_types(
|
||||
g: int = 1 if False else 2,
|
||||
h: str = "",
|
||||
i: str = r"",
|
||||
):
|
||||
...
|
||||
|
||||
|
||||
def spaces2(result=_core.Value(None)):
|
||||
...
|
||||
): ...
|
||||
def spaces2(result=_core.Value(None)): ...
|
||||
|
||||
|
||||
something = {
|
||||
|
@ -161,8 +161,7 @@ def this_wont_be_formatted ( self ) -> str: ...
|
||||
|
||||
|
||||
class Factory(t.Protocol):
|
||||
def this_will_be_formatted(self, **kwargs) -> Named:
|
||||
...
|
||||
def this_will_be_formatted(self, **kwargs) -> Named: ...
|
||||
|
||||
# fmt: on
|
||||
|
||||
|
@ -114,8 +114,7 @@ def func_no_args():
|
||||
c
|
||||
if True:
|
||||
raise RuntimeError
|
||||
if False:
|
||||
...
|
||||
if False: ...
|
||||
for i in range(10):
|
||||
print(i)
|
||||
continue
|
||||
@ -158,10 +157,7 @@ def spaces_types(
|
||||
g: int = 1 if False else 2,
|
||||
h: str = "",
|
||||
i: str = r"",
|
||||
):
|
||||
...
|
||||
|
||||
|
||||
): ...
|
||||
def spaces2(result=_core.Value(None)):
|
||||
assert fut is self._read_fut, (fut, self._read_fut)
|
||||
|
||||
|
@ -21,15 +21,21 @@ def http_status(status):
|
||||
|
||||
# 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"
|
@ -254,10 +254,12 @@
|
||||
+ CONCATENATED
|
||||
+ "using the '+' operator."
|
||||
)
|
||||
annotated_variable: Final = "This is a large string that has a type annotation attached to it. A type annotation should NOT stop a long string from being wrapped."
|
||||
annotated_variable: Literal[
|
||||
"fakse_literal"
|
||||
] = "This is a large string that has a type annotation attached to it. A type annotation should NOT stop a long string from being wrapped."
|
||||
annotated_variable: Final = (
|
||||
"This is a large string that has a type annotation attached to it. A type annotation should NOT stop a long string from being wrapped."
|
||||
)
|
||||
annotated_variable: Literal["fakse_literal"] = (
|
||||
"This is a large string that has a type annotation attached to it. A type annotation should NOT stop a long string from being wrapped."
|
||||
)
|
||||
|
||||
backslashes = "This is a really long string with \"embedded\" double quotes and 'single' quotes that also handles checking for an even number of backslashes \\"
|
||||
backslashes = "This is a really long string with \"embedded\" double quotes and 'single' quotes that also handles checking for an even number of backslashes \\\\"
|
||||
|
@ -23,24 +23,18 @@
|
||||
|
||||
# output
|
||||
|
||||
with CtxManager() as example:
|
||||
...
|
||||
with CtxManager() as example: ...
|
||||
|
||||
with CtxManager1(), CtxManager2():
|
||||
...
|
||||
with CtxManager1(), CtxManager2(): ...
|
||||
|
||||
with CtxManager1() as example, CtxManager2():
|
||||
...
|
||||
with CtxManager1() as example, CtxManager2(): ...
|
||||
|
||||
with CtxManager1(), CtxManager2() as example:
|
||||
...
|
||||
with CtxManager1(), CtxManager2() as example: ...
|
||||
|
||||
with CtxManager1() as example1, CtxManager2() as example2:
|
||||
...
|
||||
with CtxManager1() as example1, CtxManager2() as example2: ...
|
||||
|
||||
with (
|
||||
CtxManager1() as example1,
|
||||
CtxManager2() as example2,
|
||||
CtxManager3() as example3,
|
||||
):
|
||||
...
|
||||
): ...
|
||||
|
@ -24,10 +24,8 @@
|
||||
|
||||
def func(match: case, case: match) -> case:
|
||||
match Something():
|
||||
case func(match, case):
|
||||
...
|
||||
case another:
|
||||
...
|
||||
case func(match, case): ...
|
||||
case another: ...
|
||||
|
||||
|
||||
match a, *b, c:
|
||||
|
@ -1,8 +1,8 @@
|
||||
# flags: --minimum-version=3.10
|
||||
# Unparenthesized walruses are now allowed in indices since Python 3.10.
|
||||
x[a:=0]
|
||||
x[a:=0, b:=1]
|
||||
x[5, b:=0]
|
||||
x[a := 0]
|
||||
x[a := 0, b := 1]
|
||||
x[5, b := 0]
|
||||
|
||||
# Walruses are allowed inside generator expressions on function calls since 3.10.
|
||||
if any(match := pattern_error.match(s) for s in buffer):
|
||||
|
@ -96,12 +96,10 @@ async def await_the_walrus():
|
||||
foo(x=(y := f(x)))
|
||||
|
||||
|
||||
def foo(answer=(p := 42)):
|
||||
...
|
||||
def foo(answer=(p := 42)): ...
|
||||
|
||||
|
||||
def foo2(answer: (p := 42) = 5):
|
||||
...
|
||||
def foo2(answer: (p := 42) = 5): ...
|
||||
|
||||
|
||||
lambda: (x := 1)
|
||||
|
@ -15,19 +15,16 @@ def f():
|
||||
# output
|
||||
|
||||
@relaxed_decorator[0]
|
||||
def f():
|
||||
...
|
||||
def f(): ...
|
||||
|
||||
|
||||
@relaxed_decorator[
|
||||
extremely_long_name_that_definitely_will_not_fit_on_one_line_of_standard_length
|
||||
]
|
||||
def f():
|
||||
...
|
||||
def f(): ...
|
||||
|
||||
|
||||
@extremely_long_variable_name_that_doesnt_fit := complex.expression(
|
||||
with_long="arguments_value_that_wont_fit_at_the_end_of_the_line"
|
||||
)
|
||||
def f():
|
||||
...
|
||||
def f(): ...
|
@ -3,14 +3,14 @@
|
||||
|
||||
def foo1():
|
||||
|
||||
print("The newline above me should be deleted!")
|
||||
print("The newline above me should be kept!")
|
||||
|
||||
|
||||
def foo2():
|
||||
|
||||
|
||||
|
||||
print("All the newlines above me should be deleted!")
|
||||
print("All the newlines above me should be kept!")
|
||||
|
||||
|
||||
def foo3():
|
||||
@ -30,31 +30,31 @@ def foo4():
|
||||
class Foo:
|
||||
def bar(self):
|
||||
|
||||
print("The newline above me should be deleted!")
|
||||
print("The newline above me should be kept!")
|
||||
|
||||
|
||||
for i in range(5):
|
||||
|
||||
print(f"{i}) The line above me should be removed!")
|
||||
print(f"{i}) The line above me should be kept!")
|
||||
|
||||
|
||||
for i in range(5):
|
||||
|
||||
|
||||
|
||||
print(f"{i}) The lines above me should be removed!")
|
||||
print(f"{i}) The lines above me should be kept!")
|
||||
|
||||
|
||||
for i in range(5):
|
||||
|
||||
for j in range(7):
|
||||
|
||||
print(f"{i}) The lines above me should be removed!")
|
||||
print(f"{i}) The lines above me should be kept!")
|
||||
|
||||
|
||||
if random.randint(0, 3) == 0:
|
||||
|
||||
print("The new line above me is about to be removed!")
|
||||
print("The new line above me will be kept!")
|
||||
|
||||
|
||||
if random.randint(0, 3) == 0:
|
||||
@ -62,43 +62,45 @@ def bar(self):
|
||||
|
||||
|
||||
|
||||
print("The new lines above me is about to be removed!")
|
||||
print("The new lines above me will be kept!")
|
||||
|
||||
|
||||
if random.randint(0, 3) == 0:
|
||||
|
||||
if random.uniform(0, 1) > 0.5:
|
||||
print("Two lines above me are about to be removed!")
|
||||
|
||||
print("Two lines above me will be kept!")
|
||||
|
||||
|
||||
while True:
|
||||
|
||||
print("The newline above me should be deleted!")
|
||||
print("The newline above me should be kept!")
|
||||
|
||||
|
||||
while True:
|
||||
|
||||
|
||||
|
||||
print("The newlines above me should be deleted!")
|
||||
print("The newlines above me should be kept!")
|
||||
|
||||
|
||||
while True:
|
||||
|
||||
while False:
|
||||
|
||||
print("The newlines above me should be deleted!")
|
||||
print("The newlines above me should be kept!")
|
||||
|
||||
|
||||
with open("/path/to/file.txt", mode="w") as file:
|
||||
|
||||
file.write("The new line above me is about to be removed!")
|
||||
file.write("The new line above me will be kept!")
|
||||
|
||||
|
||||
with open("/path/to/file.txt", mode="w") as file:
|
||||
|
||||
|
||||
|
||||
file.write("The new lines above me is about to be removed!")
|
||||
file.write("The new lines above me will be kept!")
|
||||
|
||||
|
||||
with open("/path/to/file.txt", mode="r") as read_file:
|
||||
@ -113,20 +115,24 @@ def bar(self):
|
||||
|
||||
|
||||
def foo1():
|
||||
print("The newline above me should be deleted!")
|
||||
|
||||
print("The newline above me should be kept!")
|
||||
|
||||
|
||||
def foo2():
|
||||
print("All the newlines above me should be deleted!")
|
||||
|
||||
print("All the newlines above me should be kept!")
|
||||
|
||||
|
||||
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!")
|
||||
@ -134,56 +140,73 @@ def foo4():
|
||||
|
||||
class Foo:
|
||||
def bar(self):
|
||||
print("The newline above me should be deleted!")
|
||||
|
||||
print("The newline above me should be kept!")
|
||||
|
||||
|
||||
for i in range(5):
|
||||
print(f"{i}) The line above me should be removed!")
|
||||
|
||||
print(f"{i}) The line above me should be kept!")
|
||||
|
||||
|
||||
for i in range(5):
|
||||
print(f"{i}) The lines above me should be removed!")
|
||||
|
||||
print(f"{i}) The lines above me should be kept!")
|
||||
|
||||
|
||||
for i in range(5):
|
||||
|
||||
for j in range(7):
|
||||
print(f"{i}) The lines above me should be removed!")
|
||||
|
||||
print(f"{i}) The lines above me should be kept!")
|
||||
|
||||
|
||||
if random.randint(0, 3) == 0:
|
||||
print("The new line above me is about to be removed!")
|
||||
|
||||
print("The new line above me will be kept!")
|
||||
|
||||
|
||||
if random.randint(0, 3) == 0:
|
||||
print("The new lines above me is about to be removed!")
|
||||
|
||||
print("The new lines above me will be kept!")
|
||||
|
||||
|
||||
if random.randint(0, 3) == 0:
|
||||
|
||||
if random.uniform(0, 1) > 0.5:
|
||||
print("Two lines above me are about to be removed!")
|
||||
|
||||
print("Two lines above me will be kept!")
|
||||
|
||||
|
||||
while True:
|
||||
print("The newline above me should be deleted!")
|
||||
|
||||
print("The newline above me should be kept!")
|
||||
|
||||
|
||||
while True:
|
||||
print("The newlines above me should be deleted!")
|
||||
|
||||
print("The newlines above me should be kept!")
|
||||
|
||||
|
||||
while True:
|
||||
|
||||
while False:
|
||||
print("The newlines above me should be deleted!")
|
||||
|
||||
print("The newlines above me should be kept!")
|
||||
|
||||
|
||||
with open("/path/to/file.txt", mode="w") as file:
|
||||
file.write("The new line above me is about to be removed!")
|
||||
|
||||
file.write("The new line above me will be kept!")
|
||||
|
||||
|
||||
with open("/path/to/file.txt", mode="w") as file:
|
||||
file.write("The new lines above me is about to be removed!")
|
||||
|
||||
file.write("The new lines above me will be kept!")
|
||||
|
||||
|
||||
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())
|
||||
|
@ -75,15 +75,13 @@
|
||||
with open("bla.txt") as f, open("x"):
|
||||
pass
|
||||
|
||||
with CtxManager1() as example1, CtxManager2() as example2:
|
||||
...
|
||||
with CtxManager1() as example1, CtxManager2() as example2: ...
|
||||
|
||||
# Brackets remain when using magic comma
|
||||
with (
|
||||
CtxManager1() as example1,
|
||||
CtxManager2() as example2,
|
||||
):
|
||||
...
|
||||
): ...
|
||||
|
||||
# Brackets remain for multi-line context managers
|
||||
with (
|
||||
@ -92,8 +90,7 @@
|
||||
CtxManager2() as example2,
|
||||
CtxManager2() as example2,
|
||||
CtxManager2() as example2,
|
||||
):
|
||||
...
|
||||
): ...
|
||||
|
||||
# Don't touch assignment expressions
|
||||
with (y := open("./test.py")) as f:
|
||||
@ -116,5 +113,4 @@
|
||||
with open("bla.txt") as f:
|
||||
pass
|
||||
|
||||
with CtxManager1() as example1, CtxManager2() as example2:
|
||||
...
|
||||
with CtxManager1() as example1, CtxManager2() as example2: ...
|
||||
|
@ -88,7 +88,6 @@ def foo() -> tuple[int, int, int,]:
|
||||
return 2
|
||||
|
||||
# Magic trailing comma example, with params
|
||||
# this is broken - the trailing comma is transferred to the param list. Fixed in preview
|
||||
def foo(a,b) -> tuple[int, int, int,]:
|
||||
return 2
|
||||
|
||||
@ -194,30 +193,27 @@ def foo() -> tuple[int, int, int]:
|
||||
return 2
|
||||
|
||||
|
||||
def foo() -> (
|
||||
tuple[
|
||||
loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong,
|
||||
loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong,
|
||||
loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong,
|
||||
]
|
||||
):
|
||||
def foo() -> tuple[
|
||||
loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong,
|
||||
loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong,
|
||||
loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong,
|
||||
]:
|
||||
return 2
|
||||
|
||||
|
||||
# Magic trailing comma example
|
||||
def foo() -> (
|
||||
tuple[
|
||||
int,
|
||||
int,
|
||||
int,
|
||||
]
|
||||
):
|
||||
def foo() -> tuple[
|
||||
int,
|
||||
int,
|
||||
int,
|
||||
]:
|
||||
return 2
|
||||
|
||||
|
||||
# Magic trailing comma example, with params
|
||||
# this is broken - the trailing comma is transferred to the param list. Fixed in preview
|
||||
def foo(
|
||||
a, b
|
||||
) -> tuple[int, int, int,]:
|
||||
def foo(a, b) -> tuple[
|
||||
int,
|
||||
int,
|
||||
int,
|
||||
]:
|
||||
return 2
|
||||
|
Loading…
Reference in New Issue
Block a user