mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 13:33:50 +00:00
Change default for Python version from 3.8 to 3.9 (#13896)
Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
parent
afeb217452
commit
1b180c8342
123 changed files with 90 additions and 5488 deletions
|
@ -0,0 +1 @@
|
|||
{"target_version": "py38"}
|
|
@ -0,0 +1 @@
|
|||
{"target_version": "py38"}
|
|
@ -1 +0,0 @@
|
|||
{"preview": "enabled"}
|
|
@ -1,82 +0,0 @@
|
|||
def foo():
|
||||
"""
|
||||
Docstring
|
||||
"""
|
||||
|
||||
# Here we go
|
||||
if x:
|
||||
|
||||
# This is also now fine
|
||||
a = 123
|
||||
|
||||
else:
|
||||
# But not necessary
|
||||
a = 123
|
||||
|
||||
if y:
|
||||
|
||||
while True:
|
||||
|
||||
"""
|
||||
Long comment here
|
||||
"""
|
||||
a = 123
|
||||
|
||||
if z:
|
||||
|
||||
for _ in range(100):
|
||||
a = 123
|
||||
else:
|
||||
|
||||
try:
|
||||
|
||||
# this should be ok
|
||||
a = 123
|
||||
except:
|
||||
|
||||
"""also this"""
|
||||
a = 123
|
||||
|
||||
|
||||
def bar():
|
||||
|
||||
if x:
|
||||
a = 123
|
||||
|
||||
|
||||
def baz():
|
||||
|
||||
# OK
|
||||
if x:
|
||||
a = 123
|
||||
|
||||
def quux():
|
||||
|
||||
new_line = here
|
||||
|
||||
|
||||
class Cls:
|
||||
|
||||
def method(self):
|
||||
|
||||
pass
|
||||
|
||||
|
||||
async def async_fn():
|
||||
|
||||
"""Docstring."""
|
||||
|
||||
|
||||
@decorated
|
||||
async def async_fn():
|
||||
|
||||
"""Docstring."""
|
||||
|
||||
|
||||
def top_level(
|
||||
a: int,
|
||||
b: str,
|
||||
) -> Whatever[Generic, Something]:
|
||||
|
||||
def nested(x: int) -> int:
|
||||
pass
|
|
@ -1,81 +0,0 @@
|
|||
def foo():
|
||||
"""
|
||||
Docstring
|
||||
"""
|
||||
|
||||
# Here we go
|
||||
if x:
|
||||
|
||||
# This is also now fine
|
||||
a = 123
|
||||
|
||||
else:
|
||||
# But not necessary
|
||||
a = 123
|
||||
|
||||
if y:
|
||||
|
||||
while True:
|
||||
|
||||
"""
|
||||
Long comment here
|
||||
"""
|
||||
a = 123
|
||||
|
||||
if z:
|
||||
|
||||
for _ in range(100):
|
||||
a = 123
|
||||
else:
|
||||
|
||||
try:
|
||||
|
||||
# this should be ok
|
||||
a = 123
|
||||
except:
|
||||
|
||||
"""also this"""
|
||||
a = 123
|
||||
|
||||
|
||||
def bar():
|
||||
|
||||
if x:
|
||||
a = 123
|
||||
|
||||
|
||||
def baz():
|
||||
|
||||
# OK
|
||||
if x:
|
||||
a = 123
|
||||
|
||||
|
||||
def quux():
|
||||
|
||||
new_line = here
|
||||
|
||||
|
||||
class Cls:
|
||||
|
||||
def method(self):
|
||||
|
||||
pass
|
||||
|
||||
|
||||
async def async_fn():
|
||||
"""Docstring."""
|
||||
|
||||
|
||||
@decorated
|
||||
async def async_fn():
|
||||
"""Docstring."""
|
||||
|
||||
|
||||
def top_level(
|
||||
a: int,
|
||||
b: str,
|
||||
) -> Whatever[Generic, Something]:
|
||||
|
||||
def nested(x: int) -> int:
|
||||
pass
|
|
@ -1 +0,0 @@
|
|||
{"preview": "enabled"}
|
|
@ -1,51 +0,0 @@
|
|||
def foo():
|
||||
"""
|
||||
Docstring
|
||||
"""
|
||||
|
||||
# Here we go
|
||||
if x:
|
||||
|
||||
# This is also now fine
|
||||
a = 123
|
||||
|
||||
else:
|
||||
# But not necessary
|
||||
a = 123
|
||||
|
||||
if y:
|
||||
|
||||
while True:
|
||||
|
||||
"""
|
||||
Long comment here
|
||||
"""
|
||||
a = 123
|
||||
|
||||
if z:
|
||||
|
||||
for _ in range(100):
|
||||
a = 123
|
||||
else:
|
||||
|
||||
try:
|
||||
|
||||
# this should be ok
|
||||
a = 123
|
||||
except:
|
||||
|
||||
"""also this"""
|
||||
a = 123
|
||||
|
||||
|
||||
def bar():
|
||||
|
||||
if x:
|
||||
a = 123
|
||||
|
||||
|
||||
def baz():
|
||||
|
||||
# OK
|
||||
if x:
|
||||
a = 123
|
|
@ -1,51 +0,0 @@
|
|||
def foo():
|
||||
"""
|
||||
Docstring
|
||||
"""
|
||||
|
||||
# Here we go
|
||||
if x:
|
||||
|
||||
# This is also now fine
|
||||
a = 123
|
||||
|
||||
else:
|
||||
# But not necessary
|
||||
a = 123
|
||||
|
||||
if y:
|
||||
|
||||
while True:
|
||||
|
||||
"""
|
||||
Long comment here
|
||||
"""
|
||||
a = 123
|
||||
|
||||
if z:
|
||||
|
||||
for _ in range(100):
|
||||
a = 123
|
||||
else:
|
||||
|
||||
try:
|
||||
|
||||
# this should be ok
|
||||
a = 123
|
||||
except:
|
||||
|
||||
"""also this"""
|
||||
a = 123
|
||||
|
||||
|
||||
def bar():
|
||||
|
||||
if x:
|
||||
a = 123
|
||||
|
||||
|
||||
def baz():
|
||||
|
||||
# OK
|
||||
if x:
|
||||
a = 123
|
|
@ -1 +0,0 @@
|
|||
{"preview": "enabled"}
|
|
@ -1,11 +0,0 @@
|
|||
async def func() -> (int):
|
||||
return 0
|
||||
|
||||
|
||||
@decorated
|
||||
async def func() -> (int):
|
||||
return 0
|
||||
|
||||
|
||||
async for (item) in async_iter:
|
||||
pass
|
|
@ -1,11 +0,0 @@
|
|||
async def func() -> int:
|
||||
return 0
|
||||
|
||||
|
||||
@decorated
|
||||
async def func() -> int:
|
||||
return 0
|
||||
|
||||
|
||||
async for item in async_iter:
|
||||
pass
|
|
@ -1 +0,0 @@
|
|||
{"preview": "enabled", "target_version": "py38"}
|
|
@ -1,31 +0,0 @@
|
|||
with \
|
||||
make_context_manager1() as cm1, \
|
||||
make_context_manager2() as cm2, \
|
||||
make_context_manager3() as cm3, \
|
||||
make_context_manager4() as cm4 \
|
||||
:
|
||||
pass
|
||||
|
||||
|
||||
with \
|
||||
make_context_manager1() as cm1, \
|
||||
make_context_manager2(), \
|
||||
make_context_manager3() as cm3, \
|
||||
make_context_manager4() \
|
||||
:
|
||||
pass
|
||||
|
||||
|
||||
with \
|
||||
new_new_new1() as cm1, \
|
||||
new_new_new2() \
|
||||
:
|
||||
pass
|
||||
|
||||
|
||||
with mock.patch.object(
|
||||
self.my_runner, "first_method", autospec=True
|
||||
) as mock_run_adb, mock.patch.object(
|
||||
self.my_runner, "second_method", autospec=True, return_value="foo"
|
||||
):
|
||||
pass
|
|
@ -1,18 +0,0 @@
|
|||
with make_context_manager1() as cm1, make_context_manager2() as cm2, make_context_manager3() as cm3, make_context_manager4() as cm4:
|
||||
pass
|
||||
|
||||
|
||||
with make_context_manager1() as cm1, make_context_manager2(), make_context_manager3() as cm3, make_context_manager4():
|
||||
pass
|
||||
|
||||
|
||||
with new_new_new1() as cm1, new_new_new2():
|
||||
pass
|
||||
|
||||
|
||||
with mock.patch.object(
|
||||
self.my_runner, "first_method", autospec=True
|
||||
) as mock_run_adb, mock.patch.object(
|
||||
self.my_runner, "second_method", autospec=True, return_value="foo"
|
||||
):
|
||||
pass
|
|
@ -1 +0,0 @@
|
|||
{"preview": "enabled", "target_version": "py39"}
|
|
@ -1,84 +0,0 @@
|
|||
with \
|
||||
make_context_manager1() as cm1, \
|
||||
make_context_manager2() as cm2, \
|
||||
make_context_manager3() as cm3, \
|
||||
make_context_manager4() as cm4 \
|
||||
:
|
||||
pass
|
||||
|
||||
|
||||
# Leading comment
|
||||
with \
|
||||
make_context_manager1() as cm1, \
|
||||
make_context_manager2(), \
|
||||
make_context_manager3() as cm3, \
|
||||
make_context_manager4() \
|
||||
:
|
||||
pass
|
||||
|
||||
|
||||
with \
|
||||
new_new_new1() as cm1, \
|
||||
new_new_new2() \
|
||||
:
|
||||
pass
|
||||
|
||||
|
||||
with (
|
||||
new_new_new1() as cm1,
|
||||
new_new_new2()
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
# Leading comment.
|
||||
with (
|
||||
# First comment.
|
||||
new_new_new1() as cm1,
|
||||
# Second comment.
|
||||
new_new_new2()
|
||||
# Last comment.
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
with \
|
||||
this_is_a_very_long_call(looong_arg1=looong_value1, looong_arg2=looong_value2) as cm1, \
|
||||
this_is_a_very_long_call(looong_arg1=looong_value1, looong_arg2=looong_value2, looong_arg3=looong_value3, looong_arg4=looong_value4) as cm2 \
|
||||
:
|
||||
pass
|
||||
|
||||
|
||||
with mock.patch.object(
|
||||
self.my_runner, "first_method", autospec=True
|
||||
) as mock_run_adb, mock.patch.object(
|
||||
self.my_runner, "second_method", autospec=True, return_value="foo"
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
with xxxxxxxx.some_kind_of_method(
|
||||
some_argument=[
|
||||
"first",
|
||||
"second",
|
||||
"third",
|
||||
]
|
||||
).another_method() as cmd:
|
||||
pass
|
||||
|
||||
|
||||
async def func():
|
||||
async with \
|
||||
make_context_manager1() as cm1, \
|
||||
make_context_manager2() as cm2, \
|
||||
make_context_manager3() as cm3, \
|
||||
make_context_manager4() as cm4 \
|
||||
:
|
||||
pass
|
||||
|
||||
async with some_function(
|
||||
argument1, argument2, argument3="some_value"
|
||||
) as some_cm, some_other_function(
|
||||
argument1, argument2, argument3="some_value"
|
||||
):
|
||||
pass
|
|
@ -1,85 +0,0 @@
|
|||
with (
|
||||
make_context_manager1() as cm1,
|
||||
make_context_manager2() as cm2,
|
||||
make_context_manager3() as cm3,
|
||||
make_context_manager4() as cm4,
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
# Leading comment
|
||||
with (
|
||||
make_context_manager1() as cm1,
|
||||
make_context_manager2(),
|
||||
make_context_manager3() as cm3,
|
||||
make_context_manager4(),
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
with new_new_new1() as cm1, new_new_new2():
|
||||
pass
|
||||
|
||||
|
||||
with new_new_new1() as cm1, new_new_new2():
|
||||
pass
|
||||
|
||||
|
||||
# Leading comment.
|
||||
with (
|
||||
# First comment.
|
||||
new_new_new1() as cm1,
|
||||
# Second comment.
|
||||
new_new_new2(),
|
||||
# Last comment.
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
with (
|
||||
this_is_a_very_long_call(
|
||||
looong_arg1=looong_value1, looong_arg2=looong_value2
|
||||
) as cm1,
|
||||
this_is_a_very_long_call(
|
||||
looong_arg1=looong_value1,
|
||||
looong_arg2=looong_value2,
|
||||
looong_arg3=looong_value3,
|
||||
looong_arg4=looong_value4,
|
||||
) as cm2,
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
with (
|
||||
mock.patch.object(self.my_runner, "first_method", autospec=True) as mock_run_adb,
|
||||
mock.patch.object(
|
||||
self.my_runner, "second_method", autospec=True, return_value="foo"
|
||||
),
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
with xxxxxxxx.some_kind_of_method(
|
||||
some_argument=[
|
||||
"first",
|
||||
"second",
|
||||
"third",
|
||||
]
|
||||
).another_method() as cmd:
|
||||
pass
|
||||
|
||||
|
||||
async def func():
|
||||
async with (
|
||||
make_context_manager1() as cm1,
|
||||
make_context_manager2() as cm2,
|
||||
make_context_manager3() as cm3,
|
||||
make_context_manager4() as cm4,
|
||||
):
|
||||
pass
|
||||
|
||||
async with (
|
||||
some_function(argument1, argument2, argument3="some_value") as some_cm,
|
||||
some_other_function(argument1, argument2, argument3="some_value"),
|
||||
):
|
||||
pass
|
|
@ -1 +0,0 @@
|
|||
{"preview": "enabled", "target_version": "py310"}
|
|
@ -1,15 +0,0 @@
|
|||
# This file uses pattern matching introduced in Python 3.10.
|
||||
|
||||
|
||||
match http_code:
|
||||
case 404:
|
||||
print("Not found")
|
||||
|
||||
|
||||
with \
|
||||
make_context_manager1() as cm1, \
|
||||
make_context_manager2() as cm2, \
|
||||
make_context_manager3() as cm3, \
|
||||
make_context_manager4() as cm4 \
|
||||
:
|
||||
pass
|
|
@ -1,15 +0,0 @@
|
|||
# This file uses pattern matching introduced in Python 3.10.
|
||||
|
||||
|
||||
match http_code:
|
||||
case 404:
|
||||
print("Not found")
|
||||
|
||||
|
||||
with (
|
||||
make_context_manager1() as cm1,
|
||||
make_context_manager2() as cm2,
|
||||
make_context_manager3() as cm3,
|
||||
make_context_manager4() as cm4,
|
||||
):
|
||||
pass
|
|
@ -1 +0,0 @@
|
|||
{"preview": "enabled", "target_version": "py311"}
|
|
@ -1,16 +0,0 @@
|
|||
# This file uses except* clause in Python 3.11.
|
||||
|
||||
|
||||
try:
|
||||
some_call()
|
||||
except* Error as e:
|
||||
pass
|
||||
|
||||
|
||||
with \
|
||||
make_context_manager1() as cm1, \
|
||||
make_context_manager2() as cm2, \
|
||||
make_context_manager3() as cm3, \
|
||||
make_context_manager4() as cm4 \
|
||||
:
|
||||
pass
|
|
@ -1,16 +0,0 @@
|
|||
# This file uses except* clause in Python 3.11.
|
||||
|
||||
|
||||
try:
|
||||
some_call()
|
||||
except* Error as e:
|
||||
pass
|
||||
|
||||
|
||||
with (
|
||||
make_context_manager1() as cm1,
|
||||
make_context_manager2() as cm2,
|
||||
make_context_manager3() as cm3,
|
||||
make_context_manager4() as cm4,
|
||||
):
|
||||
pass
|
|
@ -1 +0,0 @@
|
|||
{"preview": "enabled"}
|
|
@ -1,24 +0,0 @@
|
|||
# This file doesn't use any Python 3.9+ only grammars.
|
||||
|
||||
|
||||
# Make sure parens around a single context manager don't get autodetected as
|
||||
# Python 3.9+.
|
||||
with (a):
|
||||
pass
|
||||
|
||||
|
||||
with \
|
||||
make_context_manager1() as cm1, \
|
||||
make_context_manager2() as cm2, \
|
||||
make_context_manager3() as cm3, \
|
||||
make_context_manager4() as cm4 \
|
||||
:
|
||||
pass
|
||||
|
||||
|
||||
with mock.patch.object(
|
||||
self.my_runner, "first_method", autospec=True
|
||||
) as mock_run_adb, mock.patch.object(
|
||||
self.my_runner, "second_method", autospec=True, return_value="foo"
|
||||
):
|
||||
pass
|
|
@ -1,19 +0,0 @@
|
|||
# This file doesn't use any Python 3.9+ only grammars.
|
||||
|
||||
|
||||
# Make sure parens around a single context manager don't get autodetected as
|
||||
# Python 3.9+.
|
||||
with a:
|
||||
pass
|
||||
|
||||
|
||||
with make_context_manager1() as cm1, make_context_manager2() as cm2, make_context_manager3() as cm3, make_context_manager4() as cm4:
|
||||
pass
|
||||
|
||||
|
||||
with mock.patch.object(
|
||||
self.my_runner, "first_method", autospec=True
|
||||
) as mock_run_adb, mock.patch.object(
|
||||
self.my_runner, "second_method", autospec=True, return_value="foo"
|
||||
):
|
||||
pass
|
|
@ -1 +0,0 @@
|
|||
{"preview": "enabled", "target_version": "py39"}
|
|
@ -1,17 +0,0 @@
|
|||
# This file uses parenthesized context managers introduced in Python 3.9.
|
||||
|
||||
|
||||
with \
|
||||
make_context_manager1() as cm1, \
|
||||
make_context_manager2() as cm2, \
|
||||
make_context_manager3() as cm3, \
|
||||
make_context_manager4() as cm4 \
|
||||
:
|
||||
pass
|
||||
|
||||
|
||||
with (
|
||||
new_new_new1() as cm1,
|
||||
new_new_new2()
|
||||
):
|
||||
pass
|
|
@ -1,14 +0,0 @@
|
|||
# This file uses parenthesized context managers introduced in Python 3.9.
|
||||
|
||||
|
||||
with (
|
||||
make_context_manager1() as cm1,
|
||||
make_context_manager2() as cm2,
|
||||
make_context_manager3() as cm3,
|
||||
make_context_manager4() as cm4,
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
with new_new_new1() as cm1, new_new_new2():
|
||||
pass
|
|
@ -1 +0,0 @@
|
|||
{"preview": "enabled"}
|
|
@ -1,10 +0,0 @@
|
|||
def do_not_touch_this_prefix():
|
||||
R"""There was a bug where docstring prefixes would be normalized even with -S."""
|
||||
|
||||
|
||||
def do_not_touch_this_prefix2():
|
||||
FR'There was a bug where docstring prefixes would be normalized even with -S.'
|
||||
|
||||
|
||||
def do_not_touch_this_prefix3():
|
||||
u'''There was a bug where docstring prefixes would be normalized even with -S.'''
|
|
@ -1,10 +0,0 @@
|
|||
def do_not_touch_this_prefix():
|
||||
R"""There was a bug where docstring prefixes would be normalized even with -S."""
|
||||
|
||||
|
||||
def do_not_touch_this_prefix2():
|
||||
FR'There was a bug where docstring prefixes would be normalized even with -S.'
|
||||
|
||||
|
||||
def do_not_touch_this_prefix3():
|
||||
u'''There was a bug where docstring prefixes would be normalized even with -S.'''
|
|
@ -1 +0,0 @@
|
|||
{"preview": "enabled"}
|
|
@ -1,69 +0,0 @@
|
|||
from typing import NoReturn, Protocol, Union, overload
|
||||
|
||||
class Empty:
|
||||
...
|
||||
|
||||
def dummy(a): ...
|
||||
async def other(b): ...
|
||||
|
||||
|
||||
@overload
|
||||
def a(arg: int) -> int: ...
|
||||
@overload
|
||||
def a(arg: str) -> str: ...
|
||||
@overload
|
||||
def a(arg: object) -> NoReturn: ...
|
||||
def a(arg: Union[int, str, object]) -> Union[int, str]:
|
||||
if not isinstance(arg, (int, str)):
|
||||
raise TypeError
|
||||
return arg
|
||||
|
||||
class Proto(Protocol):
|
||||
def foo(self, a: int) -> int:
|
||||
...
|
||||
|
||||
def bar(self, b: str) -> str: ...
|
||||
def baz(self, c: bytes) -> str:
|
||||
...
|
||||
|
||||
|
||||
def dummy_two():
|
||||
...
|
||||
@dummy
|
||||
def dummy_three():
|
||||
...
|
||||
|
||||
def dummy_four():
|
||||
...
|
||||
|
||||
@overload
|
||||
def b(arg: int) -> int: ...
|
||||
|
||||
@overload
|
||||
def b(arg: str) -> str: ...
|
||||
@overload
|
||||
def b(arg: object) -> NoReturn: ...
|
||||
|
||||
def b(arg: Union[int, str, object]) -> Union[int, str]:
|
||||
if not isinstance(arg, (int, str)):
|
||||
raise TypeError
|
||||
return arg
|
||||
|
||||
def has_comment():
|
||||
... # still a dummy
|
||||
|
||||
if some_condition:
|
||||
...
|
||||
|
||||
if already_dummy: ...
|
||||
|
||||
class AsyncCls:
|
||||
async def async_method(self):
|
||||
...
|
||||
|
||||
async def async_function(self):
|
||||
...
|
||||
|
||||
@decorated
|
||||
async def async_function(self):
|
||||
...
|
|
@ -1,72 +0,0 @@
|
|||
from typing import NoReturn, Protocol, Union, overload
|
||||
|
||||
|
||||
class Empty: ...
|
||||
|
||||
|
||||
def dummy(a): ...
|
||||
async def other(b): ...
|
||||
|
||||
|
||||
@overload
|
||||
def a(arg: int) -> int: ...
|
||||
@overload
|
||||
def a(arg: str) -> str: ...
|
||||
@overload
|
||||
def a(arg: object) -> NoReturn: ...
|
||||
def a(arg: Union[int, str, object]) -> Union[int, str]:
|
||||
if not isinstance(arg, (int, str)):
|
||||
raise TypeError
|
||||
return arg
|
||||
|
||||
|
||||
class Proto(Protocol):
|
||||
def foo(self, a: int) -> int: ...
|
||||
|
||||
def bar(self, b: str) -> str: ...
|
||||
def baz(self, c: bytes) -> str: ...
|
||||
|
||||
|
||||
def dummy_two(): ...
|
||||
@dummy
|
||||
def dummy_three(): ...
|
||||
|
||||
|
||||
def dummy_four(): ...
|
||||
|
||||
|
||||
@overload
|
||||
def b(arg: int) -> int: ...
|
||||
|
||||
|
||||
@overload
|
||||
def b(arg: str) -> str: ...
|
||||
@overload
|
||||
def b(arg: object) -> NoReturn: ...
|
||||
|
||||
|
||||
def b(arg: Union[int, str, object]) -> Union[int, str]:
|
||||
if not isinstance(arg, (int, str)):
|
||||
raise TypeError
|
||||
return arg
|
||||
|
||||
|
||||
def has_comment(): ... # still a dummy
|
||||
|
||||
|
||||
if some_condition:
|
||||
...
|
||||
|
||||
if already_dummy:
|
||||
...
|
||||
|
||||
|
||||
class AsyncCls:
|
||||
async def async_method(self): ...
|
||||
|
||||
|
||||
async def async_function(self): ...
|
||||
|
||||
|
||||
@decorated
|
||||
async def async_function(self): ...
|
|
@ -1 +0,0 @@
|
|||
{"preview": "enabled"}
|
|
@ -1,116 +0,0 @@
|
|||
# Warning! This file contains form feeds (ASCII 0x0C, often represented by \f or ^L).
|
||||
# These may be invisible in your editor: ensure you can see them before making changes here.
|
||||
|
||||
# There's one at the start that'll get stripped
|
||||
|
||||
# Comment and statement processing is different enough that we'll test variations of both
|
||||
# contexts here
|
||||
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
|
||||
|
||||
|
||||
#
|
||||
|
||||
|
||||
|
||||
#
|
||||
|
||||
|
||||
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
|
||||
|
||||
|
||||
#
|
||||
|
||||
#
|
||||
|
||||
#
|
||||
|
||||
\
|
||||
#
|
||||
pass
|
||||
|
||||
pass
|
||||
|
||||
|
||||
pass
|
||||
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
||||
pass
|
||||
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
||||
pass
|
||||
|
||||
pass
|
||||
|
||||
pass
|
||||
|
||||
|
||||
# form feed after a dedent
|
||||
def foo():
|
||||
pass
|
||||
|
||||
pass
|
||||
|
||||
|
||||
# form feeds are prohibited inside blocks, or on a line with nonwhitespace
|
||||
defbar(a=1,b:bool=False):
|
||||
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class Baz:
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
||||
def something(self):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
#
|
||||
pass
|
||||
pass #
|
||||
a = 1
|
||||
#
|
||||
pass
|
||||
a = 1
|
||||
|
||||
a = [
|
||||
|
||||
]
|
||||
|
||||
# as internal whitespace of a comment is allowed but why
|
||||
"form feed literal in a string is okay"
|
||||
|
||||
# form feeds at the very end get removed.
|
|
@ -1,103 +0,0 @@
|
|||
# Warning! This file contains form feeds (ASCII 0x0C, often represented by \f or ^L).
|
||||
# These may be invisible in your editor: ensure you can see them before making changes here.
|
||||
|
||||
# There's one at the start that'll get stripped
|
||||
|
||||
# Comment and statement processing is different enough that we'll test variations of both
|
||||
# contexts here
|
||||
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
|
||||
#
|
||||
|
||||
#
|
||||
|
||||
#
|
||||
pass
|
||||
|
||||
pass
|
||||
|
||||
|
||||
pass
|
||||
|
||||
|
||||
pass
|
||||
|
||||
|
||||
pass
|
||||
|
||||
|
||||
pass
|
||||
|
||||
|
||||
pass
|
||||
|
||||
|
||||
pass
|
||||
|
||||
|
||||
pass
|
||||
|
||||
pass
|
||||
|
||||
pass
|
||||
|
||||
|
||||
# form feed after a dedent
|
||||
def foo():
|
||||
pass
|
||||
|
||||
|
||||
pass
|
||||
|
||||
|
||||
# form feeds are prohibited inside blocks, or on a line with nonwhitespace
|
||||
def bar(a=1, b: bool = False):
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class Baz:
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def something(self):
|
||||
pass
|
||||
|
||||
|
||||
#
|
||||
pass
|
||||
pass #
|
||||
a = 1
|
||||
#
|
||||
pass
|
||||
a = 1
|
||||
|
||||
a = []
|
||||
|
||||
# as internal whitespace of a comment is allowed but why
|
||||
"form feed literal in a string is okay"
|
||||
|
||||
# form feeds at the very end get removed.
|
|
@ -1 +0,0 @@
|
|||
{"preview": "enabled"}
|
|
@ -1,33 +0,0 @@
|
|||
def line_before_docstring():
|
||||
|
||||
"""Please move me up"""
|
||||
|
||||
|
||||
class LineBeforeDocstring:
|
||||
|
||||
"""Please move me up"""
|
||||
|
||||
|
||||
class EvenIfThereIsAMethodAfter:
|
||||
|
||||
"""I'm the docstring"""
|
||||
def method(self):
|
||||
pass
|
||||
|
||||
|
||||
class TwoLinesBeforeDocstring:
|
||||
|
||||
|
||||
"""I want to be treated the same as if I were closer"""
|
||||
|
||||
|
||||
class MultilineDocstringsAsWell:
|
||||
|
||||
"""I'm so far
|
||||
|
||||
and on so many lines...
|
||||
"""
|
||||
|
||||
class SingleQuotedDocstring:
|
||||
|
||||
"I'm a docstring but I don't even get triple quotes."
|
|
@ -1,28 +0,0 @@
|
|||
def line_before_docstring():
|
||||
"""Please move me up"""
|
||||
|
||||
|
||||
class LineBeforeDocstring:
|
||||
"""Please move me up"""
|
||||
|
||||
|
||||
class EvenIfThereIsAMethodAfter:
|
||||
"""I'm the docstring"""
|
||||
|
||||
def method(self):
|
||||
pass
|
||||
|
||||
|
||||
class TwoLinesBeforeDocstring:
|
||||
"""I want to be treated the same as if I were closer"""
|
||||
|
||||
|
||||
class MultilineDocstringsAsWell:
|
||||
"""I'm so far
|
||||
|
||||
and on so many lines...
|
||||
"""
|
||||
|
||||
|
||||
class SingleQuotedDocstring:
|
||||
"I'm a docstring but I don't even get triple quotes."
|
|
@ -1 +0,0 @@
|
|||
{"preview": "enabled", "target_version": "py310"}
|
|
@ -1,7 +0,0 @@
|
|||
match x:
|
||||
case "abcd" | "abcd" | "abcd" :
|
||||
pass
|
||||
case "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd" | "abcd":
|
||||
pass
|
||||
case xxxxxxxxxxxxxxxxxxxxxxx:
|
||||
pass
|
|
@ -1,23 +0,0 @@
|
|||
match x:
|
||||
case "abcd" | "abcd" | "abcd":
|
||||
pass
|
||||
case (
|
||||
"abcd"
|
||||
| "abcd"
|
||||
| "abcd"
|
||||
| "abcd"
|
||||
| "abcd"
|
||||
| "abcd"
|
||||
| "abcd"
|
||||
| "abcd"
|
||||
| "abcd"
|
||||
| "abcd"
|
||||
| "abcd"
|
||||
| "abcd"
|
||||
| "abcd"
|
||||
| "abcd"
|
||||
| "abcd"
|
||||
):
|
||||
pass
|
||||
case xxxxxxxxxxxxxxxxxxxxxxx:
|
||||
pass
|
|
@ -1 +0,0 @@
|
|||
{"preview": "enabled", "target_version": "py310"}
|
|
@ -1,14 +0,0 @@
|
|||
match maybe, multiple:
|
||||
case perhaps, 5:
|
||||
pass
|
||||
case perhaps, 6,:
|
||||
pass
|
||||
|
||||
|
||||
match more := (than, one), indeed,:
|
||||
case _, (5, 6):
|
||||
pass
|
||||
case [[5], (6)], [7],:
|
||||
pass
|
||||
case _:
|
||||
pass
|
|
@ -1,20 +0,0 @@
|
|||
match maybe, multiple:
|
||||
case perhaps, 5:
|
||||
pass
|
||||
case (
|
||||
perhaps,
|
||||
6,
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
match more := (than, one), indeed,:
|
||||
case _, (5, 6):
|
||||
pass
|
||||
case (
|
||||
[[5], (6)],
|
||||
[7],
|
||||
):
|
||||
pass
|
||||
case _:
|
||||
pass
|
|
@ -1 +0,0 @@
|
|||
{"preview": "enabled"}
|
|
@ -1,2 +0,0 @@
|
|||
x[(a:=0):]
|
||||
x[:(a:=0)]
|
|
@ -1,2 +0,0 @@
|
|||
x[(a := 0) :]
|
||||
x[: (a := 0)]
|
|
@ -1 +0,0 @@
|
|||
{"preview": "enabled"}
|
|
@ -1,20 +0,0 @@
|
|||
("" % a) ** 2
|
||||
("" % a)[0]
|
||||
("" % a)()
|
||||
("" % a).b
|
||||
|
||||
2 * ("" % a)
|
||||
2 @ ("" % a)
|
||||
2 / ("" % a)
|
||||
2 // ("" % a)
|
||||
2 % ("" % a)
|
||||
+("" % a)
|
||||
b + ("" % a)
|
||||
-("" % a)
|
||||
b - ("" % a)
|
||||
b + -("" % a)
|
||||
~("" % a)
|
||||
2 ** ("" % a)
|
||||
await ("" % a)
|
||||
b[("" % a)]
|
||||
b(("" % a))
|
|
@ -1,20 +0,0 @@
|
|||
("" % a) ** 2
|
||||
("" % a)[0]
|
||||
("" % a)()
|
||||
("" % a).b
|
||||
|
||||
2 * ("" % a)
|
||||
2 @ ("" % a)
|
||||
2 / ("" % a)
|
||||
2 // ("" % a)
|
||||
2 % ("" % a)
|
||||
+("" % a)
|
||||
b + "" % a
|
||||
-("" % a)
|
||||
b - "" % a
|
||||
b + -("" % a)
|
||||
~("" % a)
|
||||
2 ** ("" % a)
|
||||
await ("" % a)
|
||||
b[("" % a)]
|
||||
b(("" % a))
|
|
@ -1 +0,0 @@
|
|||
{"preview": "enabled"}
|
|
@ -1,11 +0,0 @@
|
|||
a = 1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1
|
||||
b = 1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1
|
||||
c = 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1 ** 1
|
||||
d = 1**1 ** 1**1 ** 1**1 ** 1**1 ** 1**1**1 ** 1 ** 1**1 ** 1**1**1**1**1 ** 1 ** 1**1**1 **1**1** 1 ** 1 ** 1
|
||||
e = 𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟
|
||||
f = 𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟
|
||||
|
||||
a = 1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0
|
||||
b = 1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0
|
||||
c = 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0 ** 1.0
|
||||
d = 1.0**1.0 ** 1.0**1.0 ** 1.0**1.0 ** 1.0**1.0 ** 1.0**1.0**1.0 ** 1.0 ** 1.0**1.0 ** 1.0**1.0**1.0
|
|
@ -1,83 +0,0 @@
|
|||
a = 1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1
|
||||
b = (
|
||||
1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
** 1
|
||||
)
|
||||
c = 1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1
|
||||
d = 1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1
|
||||
e = 𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟**𨉟
|
||||
f = (
|
||||
𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
** 𨉟
|
||||
)
|
||||
|
||||
a = 1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0
|
||||
b = (
|
||||
1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
** 1.0
|
||||
)
|
||||
c = 1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0
|
||||
d = 1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0**1.0
|
|
@ -1 +0,0 @@
|
|||
{"preview": "enabled"}
|
|
@ -1,106 +0,0 @@
|
|||
first_item, second_item = (
|
||||
some_looooooooong_module.some_looooooooooooooong_function_name(
|
||||
first_argument, second_argument, third_argument
|
||||
)
|
||||
)
|
||||
|
||||
some_dict["with_a_long_key"] = (
|
||||
some_looooooooong_module.some_looooooooooooooong_function_name(
|
||||
first_argument, second_argument, third_argument
|
||||
)
|
||||
)
|
||||
|
||||
# Make sure it works when the RHS only has one pair of (optional) parens.
|
||||
first_item, second_item = (
|
||||
some_looooooooong_module.SomeClass.some_looooooooooooooong_variable_name
|
||||
)
|
||||
|
||||
some_dict["with_a_long_key"] = (
|
||||
some_looooooooong_module.SomeClass.some_looooooooooooooong_variable_name
|
||||
)
|
||||
|
||||
# Make sure chaining assignments work.
|
||||
first_item, second_item, third_item, forth_item = m["everything"] = (
|
||||
some_looooooooong_module.some_looooooooooooooong_function_name(
|
||||
first_argument, second_argument, third_argument
|
||||
)
|
||||
)
|
||||
|
||||
# Make sure when the RHS's first split at the non-optional paren fits,
|
||||
# we split there instead of the outer RHS optional paren.
|
||||
first_item, second_item = some_looooooooong_module.some_loooooog_function_name(
|
||||
first_argument, second_argument, third_argument
|
||||
)
|
||||
|
||||
(
|
||||
first_item,
|
||||
second_item,
|
||||
third_item,
|
||||
forth_item,
|
||||
fifth_item,
|
||||
last_item_very_loooooong,
|
||||
) = some_looooooooong_module.some_looooooooooooooong_function_name(
|
||||
first_argument, second_argument, third_argument
|
||||
)
|
||||
|
||||
(
|
||||
first_item,
|
||||
second_item,
|
||||
third_item,
|
||||
forth_item,
|
||||
fifth_item,
|
||||
last_item_very_loooooong,
|
||||
) = everything = some_looooong_function_name(
|
||||
first_argument, second_argument, third_argument
|
||||
)
|
||||
|
||||
|
||||
# Make sure unsplittable type ignore won't be moved.
|
||||
some_kind_of_table[some_key] = util.some_function( # type: ignore # noqa: E501
|
||||
some_arg
|
||||
).intersection(pk_cols)
|
||||
|
||||
some_kind_of_table[
|
||||
some_key
|
||||
] = lambda obj: obj.some_long_named_method() # type: ignore # noqa: E501
|
||||
|
||||
some_kind_of_table[
|
||||
some_key # type: ignore # noqa: E501
|
||||
] = lambda obj: obj.some_long_named_method()
|
||||
|
||||
|
||||
# Make when when the left side of assignment plus the opening paren "... = (" is
|
||||
# exactly line length limit + 1, it won't be split like that.
|
||||
xxxxxxxxx_yyy_zzzzzzzz[
|
||||
xx.xxxxxx(x_yyy_zzzzzz.xxxxx[0]), x_yyy_zzzzzz.xxxxxx(xxxx=1)
|
||||
] = 1
|
||||
|
||||
|
||||
# Right side of assignment contains un-nested pairs of inner parens.
|
||||
some_kind_of_instance.some_kind_of_map[a_key] = (
|
||||
isinstance(some_var, SomeClass)
|
||||
and table.something_and_something != table.something_else
|
||||
) or (
|
||||
isinstance(some_other_var, BaseClass) and table.something != table.some_other_thing
|
||||
)
|
||||
|
||||
# Multiple targets
|
||||
a = b = (
|
||||
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
|
||||
)
|
||||
|
||||
a = b = c = d = e = f = g = (
|
||||
hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
|
||||
) = i = j = (
|
||||
kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
|
||||
)
|
||||
|
||||
a = (
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
) = c
|
||||
|
||||
a = (
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
) = (
|
||||
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
|
||||
) = ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
|
|
@ -1,106 +0,0 @@
|
|||
first_item, second_item = (
|
||||
some_looooooooong_module.some_looooooooooooooong_function_name(
|
||||
first_argument, second_argument, third_argument
|
||||
)
|
||||
)
|
||||
|
||||
some_dict["with_a_long_key"] = (
|
||||
some_looooooooong_module.some_looooooooooooooong_function_name(
|
||||
first_argument, second_argument, third_argument
|
||||
)
|
||||
)
|
||||
|
||||
# Make sure it works when the RHS only has one pair of (optional) parens.
|
||||
first_item, second_item = (
|
||||
some_looooooooong_module.SomeClass.some_looooooooooooooong_variable_name
|
||||
)
|
||||
|
||||
some_dict["with_a_long_key"] = (
|
||||
some_looooooooong_module.SomeClass.some_looooooooooooooong_variable_name
|
||||
)
|
||||
|
||||
# Make sure chaining assignments work.
|
||||
first_item, second_item, third_item, forth_item = m["everything"] = (
|
||||
some_looooooooong_module.some_looooooooooooooong_function_name(
|
||||
first_argument, second_argument, third_argument
|
||||
)
|
||||
)
|
||||
|
||||
# Make sure when the RHS's first split at the non-optional paren fits,
|
||||
# we split there instead of the outer RHS optional paren.
|
||||
first_item, second_item = some_looooooooong_module.some_loooooog_function_name(
|
||||
first_argument, second_argument, third_argument
|
||||
)
|
||||
|
||||
(
|
||||
first_item,
|
||||
second_item,
|
||||
third_item,
|
||||
forth_item,
|
||||
fifth_item,
|
||||
last_item_very_loooooong,
|
||||
) = some_looooooooong_module.some_looooooooooooooong_function_name(
|
||||
first_argument, second_argument, third_argument
|
||||
)
|
||||
|
||||
(
|
||||
first_item,
|
||||
second_item,
|
||||
third_item,
|
||||
forth_item,
|
||||
fifth_item,
|
||||
last_item_very_loooooong,
|
||||
) = everything = some_looooong_function_name(
|
||||
first_argument, second_argument, third_argument
|
||||
)
|
||||
|
||||
|
||||
# Make sure unsplittable type ignore won't be moved.
|
||||
some_kind_of_table[some_key] = util.some_function( # type: ignore # noqa: E501
|
||||
some_arg
|
||||
).intersection(pk_cols)
|
||||
|
||||
some_kind_of_table[
|
||||
some_key
|
||||
] = lambda obj: obj.some_long_named_method() # type: ignore # noqa: E501
|
||||
|
||||
some_kind_of_table[
|
||||
some_key # type: ignore # noqa: E501
|
||||
] = lambda obj: obj.some_long_named_method()
|
||||
|
||||
|
||||
# Make when when the left side of assignment plus the opening paren "... = (" is
|
||||
# exactly line length limit + 1, it won't be split like that.
|
||||
xxxxxxxxx_yyy_zzzzzzzz[
|
||||
xx.xxxxxx(x_yyy_zzzzzz.xxxxx[0]), x_yyy_zzzzzz.xxxxxx(xxxx=1)
|
||||
] = 1
|
||||
|
||||
|
||||
# Right side of assignment contains un-nested pairs of inner parens.
|
||||
some_kind_of_instance.some_kind_of_map[a_key] = (
|
||||
isinstance(some_var, SomeClass)
|
||||
and table.something_and_something != table.something_else
|
||||
) or (
|
||||
isinstance(some_other_var, BaseClass) and table.something != table.some_other_thing
|
||||
)
|
||||
|
||||
# Multiple targets
|
||||
a = b = (
|
||||
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
|
||||
)
|
||||
|
||||
a = b = c = d = e = f = g = (
|
||||
hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
|
||||
) = i = j = (
|
||||
kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
|
||||
)
|
||||
|
||||
a = (
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
) = c
|
||||
|
||||
a = (
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
) = (
|
||||
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
|
||||
) = ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
|
|
@ -1 +0,0 @@
|
|||
{"preview": "enabled"}
|
|
@ -1,8 +0,0 @@
|
|||
foo = 123 # fmt: skip # noqa: E501 # pylint
|
||||
bar = (
|
||||
123 ,
|
||||
( 1 + 5 ) # pylint # fmt:skip
|
||||
)
|
||||
baz = "a" + "b" # pylint; fmt: skip; noqa: E501
|
||||
skip_will_not_work = "a" + "b" # pylint fmt:skip
|
||||
skip_will_not_work2 = "a" + "b" # some text; fmt:skip happens to be part of it
|
|
@ -1,8 +0,0 @@
|
|||
foo = 123 # fmt: skip # noqa: E501 # pylint
|
||||
bar = (
|
||||
123 ,
|
||||
( 1 + 5 ) # pylint # fmt:skip
|
||||
)
|
||||
baz = "a" + "b" # pylint; fmt: skip; noqa: E501
|
||||
skip_will_not_work = "a" + "b" # pylint fmt:skip
|
||||
skip_will_not_work2 = "a" + "b" # some text; fmt:skip happens to be part of it
|
|
@ -1 +0,0 @@
|
|||
{"preview": "enabled"}
|
|
@ -1,24 +0,0 @@
|
|||
e = {
|
||||
"a": fun(msg, "ts"),
|
||||
"longggggggggggggggid": ...,
|
||||
"longgggggggggggggggggggkey": ..., "created": ...
|
||||
# "longkey": ...
|
||||
}
|
||||
f = [
|
||||
arg1,
|
||||
arg2,
|
||||
arg3, arg4
|
||||
# comment
|
||||
]
|
||||
g = (
|
||||
arg1,
|
||||
arg2,
|
||||
arg3, arg4
|
||||
# comment
|
||||
)
|
||||
h = {
|
||||
arg1,
|
||||
arg2,
|
||||
arg3, arg4
|
||||
# comment
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
e = {
|
||||
"a": fun(msg, "ts"),
|
||||
"longggggggggggggggid": ...,
|
||||
"longgggggggggggggggggggkey": ...,
|
||||
"created": ...,
|
||||
# "longkey": ...
|
||||
}
|
||||
f = [
|
||||
arg1,
|
||||
arg2,
|
||||
arg3,
|
||||
arg4,
|
||||
# comment
|
||||
]
|
||||
g = (
|
||||
arg1,
|
||||
arg2,
|
||||
arg3,
|
||||
arg4,
|
||||
# comment
|
||||
)
|
||||
h = {
|
||||
arg1,
|
||||
arg2,
|
||||
arg3,
|
||||
arg4,
|
||||
# comment
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
{"target_version": "py310"}
|
|
@ -1,19 +0,0 @@
|
|||
def http_status(status):
|
||||
|
||||
match status:
|
||||
|
||||
case 400:
|
||||
|
||||
return "Bad request"
|
||||
|
||||
case 401:
|
||||
|
||||
return "Unauthorized"
|
||||
|
||||
case 403:
|
||||
|
||||
return "Forbidden"
|
||||
|
||||
case 404:
|
||||
|
||||
return "Not found"
|
|
@ -1,13 +0,0 @@
|
|||
def http_status(status):
|
||||
match status:
|
||||
case 400:
|
||||
return "Bad request"
|
||||
|
||||
case 401:
|
||||
return "Unauthorized"
|
||||
|
||||
case 403:
|
||||
return "Forbidden"
|
||||
|
||||
case 404:
|
||||
return "Not found"
|
|
@ -1,67 +0,0 @@
|
|||
long_kwargs_single_line = my_function(
|
||||
foo="test, this is a sample value",
|
||||
bar=some_long_value_name_foo_bar_baz if some_boolean_variable else some_fallback_value_foo_bar_baz,
|
||||
baz="hello, this is a another value",
|
||||
)
|
||||
|
||||
multiline_kwargs_indented = my_function(
|
||||
foo="test, this is a sample value",
|
||||
bar=some_long_value_name_foo_bar_baz
|
||||
if some_boolean_variable
|
||||
else some_fallback_value_foo_bar_baz,
|
||||
baz="hello, this is a another value",
|
||||
)
|
||||
|
||||
imploding_kwargs = my_function(
|
||||
foo="test, this is a sample value",
|
||||
bar=a
|
||||
if foo
|
||||
else b,
|
||||
baz="hello, this is a another value",
|
||||
)
|
||||
|
||||
imploding_line = (
|
||||
1
|
||||
if 1 + 1 == 2
|
||||
else 0
|
||||
)
|
||||
|
||||
exploding_line = "hello this is a slightly long string" if some_long_value_name_foo_bar_baz else "this one is a little shorter"
|
||||
|
||||
positional_argument_test(some_long_value_name_foo_bar_baz if some_boolean_variable else some_fallback_value_foo_bar_baz)
|
||||
|
||||
def weird_default_argument(x=some_long_value_name_foo_bar_baz
|
||||
if SOME_CONSTANT
|
||||
else some_fallback_value_foo_bar_baz):
|
||||
pass
|
||||
|
||||
nested = "hello this is a slightly long string" if (some_long_value_name_foo_bar_baz if
|
||||
nesting_test_expressions else some_fallback_value_foo_bar_baz) \
|
||||
else "this one is a little shorter"
|
||||
|
||||
generator_expression = (
|
||||
some_long_value_name_foo_bar_baz if some_boolean_variable else some_fallback_value_foo_bar_baz for some_boolean_variable in some_iterable
|
||||
)
|
||||
|
||||
|
||||
def limit_offset_sql(self, low_mark, high_mark):
|
||||
"""Return LIMIT/OFFSET SQL clause."""
|
||||
limit, offset = self._get_limit_offset_params(low_mark, high_mark)
|
||||
return " ".join(
|
||||
sql
|
||||
for sql in (
|
||||
"LIMIT %d" % limit if limit else None,
|
||||
("OFFSET %d" % offset) if offset else None,
|
||||
)
|
||||
if sql
|
||||
)
|
||||
|
||||
|
||||
def something():
|
||||
clone._iterable_class = (
|
||||
NamedValuesListIterable
|
||||
if named
|
||||
else FlatValuesListIterable
|
||||
if flat
|
||||
else ValuesListIterable
|
||||
)
|
|
@ -1,90 +0,0 @@
|
|||
long_kwargs_single_line = my_function(
|
||||
foo="test, this is a sample value",
|
||||
bar=(
|
||||
some_long_value_name_foo_bar_baz
|
||||
if some_boolean_variable
|
||||
else some_fallback_value_foo_bar_baz
|
||||
),
|
||||
baz="hello, this is a another value",
|
||||
)
|
||||
|
||||
multiline_kwargs_indented = my_function(
|
||||
foo="test, this is a sample value",
|
||||
bar=(
|
||||
some_long_value_name_foo_bar_baz
|
||||
if some_boolean_variable
|
||||
else some_fallback_value_foo_bar_baz
|
||||
),
|
||||
baz="hello, this is a another value",
|
||||
)
|
||||
|
||||
imploding_kwargs = my_function(
|
||||
foo="test, this is a sample value",
|
||||
bar=a if foo else b,
|
||||
baz="hello, this is a another value",
|
||||
)
|
||||
|
||||
imploding_line = 1 if 1 + 1 == 2 else 0
|
||||
|
||||
exploding_line = (
|
||||
"hello this is a slightly long string"
|
||||
if some_long_value_name_foo_bar_baz
|
||||
else "this one is a little shorter"
|
||||
)
|
||||
|
||||
positional_argument_test(
|
||||
some_long_value_name_foo_bar_baz
|
||||
if some_boolean_variable
|
||||
else some_fallback_value_foo_bar_baz
|
||||
)
|
||||
|
||||
|
||||
def weird_default_argument(
|
||||
x=(
|
||||
some_long_value_name_foo_bar_baz
|
||||
if SOME_CONSTANT
|
||||
else some_fallback_value_foo_bar_baz
|
||||
),
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
nested = (
|
||||
"hello this is a slightly long string"
|
||||
if (
|
||||
some_long_value_name_foo_bar_baz
|
||||
if nesting_test_expressions
|
||||
else some_fallback_value_foo_bar_baz
|
||||
)
|
||||
else "this one is a little shorter"
|
||||
)
|
||||
|
||||
generator_expression = (
|
||||
(
|
||||
some_long_value_name_foo_bar_baz
|
||||
if some_boolean_variable
|
||||
else some_fallback_value_foo_bar_baz
|
||||
)
|
||||
for some_boolean_variable in some_iterable
|
||||
)
|
||||
|
||||
|
||||
def limit_offset_sql(self, low_mark, high_mark):
|
||||
"""Return LIMIT/OFFSET SQL clause."""
|
||||
limit, offset = self._get_limit_offset_params(low_mark, high_mark)
|
||||
return " ".join(
|
||||
sql
|
||||
for sql in (
|
||||
"LIMIT %d" % limit if limit else None,
|
||||
("OFFSET %d" % offset) if offset else None,
|
||||
)
|
||||
if sql
|
||||
)
|
||||
|
||||
|
||||
def something():
|
||||
clone._iterable_class = (
|
||||
NamedValuesListIterable
|
||||
if named
|
||||
else FlatValuesListIterable if flat else ValuesListIterable
|
||||
)
|
|
@ -1,30 +0,0 @@
|
|||
from typing import Union
|
||||
|
||||
@bird
|
||||
def zoo(): ...
|
||||
|
||||
class A: ...
|
||||
@bar
|
||||
class B:
|
||||
def BMethod(self) -> None: ...
|
||||
@overload
|
||||
def BMethod(self, arg : List[str]) -> None: ...
|
||||
|
||||
class C: ...
|
||||
@hmm
|
||||
class D: ...
|
||||
class E: ...
|
||||
|
||||
@baz
|
||||
def foo() -> None:
|
||||
...
|
||||
|
||||
class F (A , C): ...
|
||||
def spam() -> None: ...
|
||||
|
||||
@overload
|
||||
def spam(arg: str) -> str: ...
|
||||
|
||||
var : int = 1
|
||||
|
||||
def eggs() -> Union[str, int]: ...
|
|
@ -1,32 +0,0 @@
|
|||
from typing import Union
|
||||
|
||||
@bird
|
||||
def zoo(): ...
|
||||
|
||||
class A: ...
|
||||
|
||||
@bar
|
||||
class B:
|
||||
def BMethod(self) -> None: ...
|
||||
@overload
|
||||
def BMethod(self, arg: List[str]) -> None: ...
|
||||
|
||||
class C: ...
|
||||
|
||||
@hmm
|
||||
class D: ...
|
||||
|
||||
class E: ...
|
||||
|
||||
@baz
|
||||
def foo() -> None: ...
|
||||
|
||||
class F(A, C): ...
|
||||
|
||||
def spam() -> None: ...
|
||||
@overload
|
||||
def spam(arg: str) -> str: ...
|
||||
|
||||
var: int = 1
|
||||
|
||||
def eggs() -> Union[str, int]: ...
|
|
@ -1,16 +0,0 @@
|
|||
# flags: --preview --skip-string-normalization
|
||||
class C:
|
||||
|
||||
r"""Raw"""
|
||||
|
||||
def f():
|
||||
|
||||
r"""Raw"""
|
||||
|
||||
class SingleQuotes:
|
||||
|
||||
|
||||
r'''Raw'''
|
||||
|
||||
class UpperCaseR:
|
||||
R"""Raw"""
|
|
@ -1,14 +0,0 @@
|
|||
class C:
|
||||
r"""Raw"""
|
||||
|
||||
|
||||
def f():
|
||||
r"""Raw"""
|
||||
|
||||
|
||||
class SingleQuotes:
|
||||
r'''Raw'''
|
||||
|
||||
|
||||
class UpperCaseR:
|
||||
R"""Raw"""
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"preview": "enabled"
|
||||
}
|
|
@ -1,141 +0,0 @@
|
|||
def foo_brackets(request):
|
||||
return JsonResponse(
|
||||
{
|
||||
"var_1": foo,
|
||||
"var_2": bar,
|
||||
}
|
||||
)
|
||||
|
||||
def foo_square_brackets(request):
|
||||
return JsonResponse(
|
||||
[
|
||||
"var_1",
|
||||
"var_2",
|
||||
]
|
||||
)
|
||||
|
||||
func({"a": 37, "b": 42, "c": 927, "aaaaaaaaaaaaaaaaaaaaaaaaa": 11111111111111111111111111111111111111111})
|
||||
|
||||
func(["random_string_number_one","random_string_number_two","random_string_number_three","random_string_number_four"])
|
||||
|
||||
func(
|
||||
{
|
||||
# expand me
|
||||
'a':37,
|
||||
'b':42,
|
||||
'c':927
|
||||
}
|
||||
)
|
||||
|
||||
func(
|
||||
[
|
||||
'a',
|
||||
'b',
|
||||
'c',
|
||||
]
|
||||
)
|
||||
|
||||
func(
|
||||
[
|
||||
'a',
|
||||
'b',
|
||||
'c',
|
||||
],
|
||||
)
|
||||
|
||||
func( # a
|
||||
[ # b
|
||||
"c", # c
|
||||
"d", # d
|
||||
"e", # e
|
||||
] # f
|
||||
) # g
|
||||
|
||||
func( # a
|
||||
{ # b
|
||||
"c": 1, # c
|
||||
"d": 2, # d
|
||||
"e": 3, # e
|
||||
} # f
|
||||
) # g
|
||||
|
||||
func(
|
||||
# preserve me
|
||||
[
|
||||
"c",
|
||||
"d",
|
||||
"e",
|
||||
]
|
||||
)
|
||||
|
||||
func(
|
||||
[ # preserve me but hug brackets
|
||||
"c",
|
||||
"d",
|
||||
"e",
|
||||
]
|
||||
)
|
||||
|
||||
func(
|
||||
[
|
||||
# preserve me but hug brackets
|
||||
"c",
|
||||
"d",
|
||||
"e",
|
||||
]
|
||||
)
|
||||
|
||||
func(
|
||||
[
|
||||
"c",
|
||||
# preserve me but hug brackets
|
||||
"d",
|
||||
"e",
|
||||
]
|
||||
)
|
||||
|
||||
func(
|
||||
[
|
||||
"c",
|
||||
"d",
|
||||
"e",
|
||||
# preserve me but hug brackets
|
||||
]
|
||||
)
|
||||
|
||||
func(
|
||||
[
|
||||
"c",
|
||||
"d",
|
||||
"e",
|
||||
] # preserve me but hug brackets
|
||||
)
|
||||
|
||||
func(
|
||||
[
|
||||
"c",
|
||||
"d",
|
||||
"e",
|
||||
]
|
||||
# preserve me
|
||||
)
|
||||
|
||||
func([x for x in "short line"])
|
||||
func([x for x in "long line long line long line long line long line long line long line"])
|
||||
func([x for x in [x for x in "long line long line long line long line long line long line long line"]])
|
||||
|
||||
func({"short line"})
|
||||
func({"long line", "long long line", "long long long line", "long long long long line", "long long long long long line"})
|
||||
func({{"long line", "long long line", "long long long line", "long long long long line", "long long long long long line"}})
|
||||
|
||||
foooooooooooooooooooo(
|
||||
[{c: n + 1 for c in range(256)} for n in range(100)] + [{}], {size}
|
||||
)
|
||||
|
||||
baaaaaaaaaaaaar(
|
||||
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], {x}, "a string", [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
)
|
||||
|
||||
foo(*["long long long long long line", "long long long long long line", "long long long long long line"])
|
||||
|
||||
foo(*[str(i) for i in range(100000000000000000000000000000000000000000000000000000000000)])
|
|
@ -1,159 +0,0 @@
|
|||
def foo_brackets(request):
|
||||
return JsonResponse({
|
||||
"var_1": foo,
|
||||
"var_2": bar,
|
||||
})
|
||||
|
||||
|
||||
def foo_square_brackets(request):
|
||||
return JsonResponse([
|
||||
"var_1",
|
||||
"var_2",
|
||||
])
|
||||
|
||||
|
||||
func({
|
||||
"a": 37,
|
||||
"b": 42,
|
||||
"c": 927,
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaa": 11111111111111111111111111111111111111111,
|
||||
})
|
||||
|
||||
func([
|
||||
"random_string_number_one",
|
||||
"random_string_number_two",
|
||||
"random_string_number_three",
|
||||
"random_string_number_four",
|
||||
])
|
||||
|
||||
func({
|
||||
# expand me
|
||||
"a": 37,
|
||||
"b": 42,
|
||||
"c": 927,
|
||||
})
|
||||
|
||||
func([
|
||||
"a",
|
||||
"b",
|
||||
"c",
|
||||
])
|
||||
|
||||
func(
|
||||
[
|
||||
"a",
|
||||
"b",
|
||||
"c",
|
||||
],
|
||||
)
|
||||
|
||||
func([ # a # b
|
||||
"c", # c
|
||||
"d", # d
|
||||
"e", # e
|
||||
]) # f # g
|
||||
|
||||
func({ # a # b
|
||||
"c": 1, # c
|
||||
"d": 2, # d
|
||||
"e": 3, # e
|
||||
}) # f # g
|
||||
|
||||
func(
|
||||
# preserve me
|
||||
[
|
||||
"c",
|
||||
"d",
|
||||
"e",
|
||||
]
|
||||
)
|
||||
|
||||
func([ # preserve me but hug brackets
|
||||
"c",
|
||||
"d",
|
||||
"e",
|
||||
])
|
||||
|
||||
func([
|
||||
# preserve me but hug brackets
|
||||
"c",
|
||||
"d",
|
||||
"e",
|
||||
])
|
||||
|
||||
func([
|
||||
"c",
|
||||
# preserve me but hug brackets
|
||||
"d",
|
||||
"e",
|
||||
])
|
||||
|
||||
func([
|
||||
"c",
|
||||
"d",
|
||||
"e",
|
||||
# preserve me but hug brackets
|
||||
])
|
||||
|
||||
func([
|
||||
"c",
|
||||
"d",
|
||||
"e",
|
||||
]) # preserve me but hug brackets
|
||||
|
||||
func(
|
||||
[
|
||||
"c",
|
||||
"d",
|
||||
"e",
|
||||
]
|
||||
# preserve me
|
||||
)
|
||||
|
||||
func([x for x in "short line"])
|
||||
func([
|
||||
x for x in "long line long line long line long line long line long line long line"
|
||||
])
|
||||
func([
|
||||
x
|
||||
for x in [
|
||||
x
|
||||
for x in "long line long line long line long line long line long line long line"
|
||||
]
|
||||
])
|
||||
|
||||
func({"short line"})
|
||||
func({
|
||||
"long line",
|
||||
"long long line",
|
||||
"long long long line",
|
||||
"long long long long line",
|
||||
"long long long long long line",
|
||||
})
|
||||
func({
|
||||
{
|
||||
"long line",
|
||||
"long long line",
|
||||
"long long long line",
|
||||
"long long long long line",
|
||||
"long long long long long line",
|
||||
}
|
||||
})
|
||||
|
||||
foooooooooooooooooooo(
|
||||
[{c: n + 1 for c in range(256)} for n in range(100)] + [{}], {size}
|
||||
)
|
||||
|
||||
baaaaaaaaaaaaar(
|
||||
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], {x}, "a string", [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
)
|
||||
|
||||
foo(*[
|
||||
"long long long long long line",
|
||||
"long long long long long line",
|
||||
"long long long long long line",
|
||||
])
|
||||
|
||||
foo(*[
|
||||
str(i) for i in range(100000000000000000000000000000000000000000000000000000000000)
|
||||
])
|
|
@ -35,12 +35,12 @@ def import_fixture(fixture: Path, fixture_set: str):
|
|||
# If there's no output marker, treat the whole file as already pre-formatted
|
||||
expected = input
|
||||
|
||||
options = {}
|
||||
black_options = {}
|
||||
extension = "py"
|
||||
|
||||
if flags:
|
||||
if "--preview" in flags or "--unstable" in flags:
|
||||
options["preview"] = "enabled"
|
||||
black_options["preview"] = "enabled"
|
||||
|
||||
if "--pyi" in flags:
|
||||
extension = "pyi"
|
||||
|
@ -53,21 +53,23 @@ def import_fixture(fixture: Path, fixture_set: str):
|
|||
[_, length_and_rest] = flags.split("--line-length=", 1)
|
||||
length = length_and_rest.split(" ", 1)[0]
|
||||
length = int(length)
|
||||
options["line_width"] = 1 if length == 0 else length
|
||||
black_options["line_width"] = 1 if length == 0 else length
|
||||
|
||||
if "--minimum-version=" in flags:
|
||||
[_, version] = flags.split("--minimum-version=", 1)
|
||||
version = version.split(" ", 1)[0]
|
||||
# Convert 3.10 to py310
|
||||
options["target_version"] = f"py{version.strip().replace('.', '')}"
|
||||
black_options["target_version"] = f"py{version.strip().replace('.', '')}"
|
||||
|
||||
if "--skip-magic-trailing-comma" in flags:
|
||||
options["magic_trailing_comma"] = "ignore"
|
||||
black_options["magic_trailing_comma"] = "ignore"
|
||||
|
||||
fixture_path = output_directory.joinpath(fixture.name).with_suffix(f".{extension}")
|
||||
expect_path = fixture_path.with_suffix(f".{extension}.expect")
|
||||
options_path = fixture_path.with_suffix(".options.json")
|
||||
|
||||
options = OPTIONS_OVERRIDES.get(fixture.name, black_options)
|
||||
|
||||
if len(options) > 0:
|
||||
if extension == "pyi":
|
||||
options["source_type"] = "Stub"
|
||||
|
@ -109,6 +111,16 @@ IGNORE_LIST = [
|
|||
"line_ranges_outside_source.py",
|
||||
]
|
||||
|
||||
# Specs for which to override the formatter options
|
||||
OPTIONS_OVERRIDES = {
|
||||
"context_managers_38.py": {
|
||||
"target_version": "py38"
|
||||
},
|
||||
"context_managers_autodetect_38.py" : {
|
||||
"target_version": "py38"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def import_fixtures(black_dir: str):
|
||||
"""Imports all the black fixtures"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue