Skip to content

Commit

Permalink
Set target_version in black tests and update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser committed Dec 21, 2023
1 parent 8cb7950 commit 390adb4
Show file tree
Hide file tree
Showing 55 changed files with 996 additions and 466 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# split out from comments2 as it does not work with line-length=1, losing the comment
a = "type comment with trailing space" # type: str
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# split out from comments2 as it does not work with line-length=1, losing the comment
a = "type comment with trailing space" # type: str
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ def _init_host(self, parsed) -> None:
pass


a = "type comment with trailing space" # type: str

#######################
### SECTION COMMENT ###
#######################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,6 @@ class Test:
pass


a = "type comment with trailing space" # type: str

#######################
### SECTION COMMENT ###
#######################
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# l2 loses the comment with line-length=1 in preview mode
l1 = ["This list should be broken up", "into multiple lines", "because it is way too long"]
l2 = ["But this list shouldn't", "even though it also has", "way too many characters in it"] # fmt: skip
l3 = ["I have", "trailing comma", "so I should be braked",]
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# l2 loses the comment with line-length=1 in preview mode
l1 = [
"This list should be broken up",
"into multiple lines",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"preview": "enabled"}
{"preview": "enabled", "target_version": "py310"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"target_version": "py310"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"target_version": "py310"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"target_version": "py310"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"target_version": "py310"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"target_version": "py310"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"target_version": "py310"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"preview": "enabled"}
{"preview": "enabled", "target_version": "py310"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"target_version": "py38"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"target_version": "py38"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"target_version": "py310"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"target_version": "py39"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"target_version": "py38"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"target_version": "py311"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"target_version": "py311"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"target_version": "py311"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"preview": "enabled"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
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
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"preview": "enabled"}
{"preview": "enabled", "target_version": "py38"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"preview": "enabled"}
{"preview": "enabled", "target_version": "py39"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"preview": "enabled"}
{"preview": "enabled", "target_version": "py310"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"preview": "enabled"}
{"preview": "enabled", "target_version": "py311"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"preview": "enabled"}
{"preview": "enabled", "target_version": "py39"}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from typing import NoReturn, Protocol, Union, overload

class Empty:
...

def dummy(a): ...
def other(b): ...
async def other(b): ...


@overload
Expand Down Expand Up @@ -46,3 +48,11 @@ 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: ...
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from typing import NoReturn, Protocol, Union, overload


class Empty: ...


def dummy(a): ...
def other(b): ...
async def other(b): ...


@overload
Expand Down Expand Up @@ -46,3 +49,13 @@ 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:
...
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ pass

# form feeds are prohibited inside blocks, or on a line with nonwhitespace
def bar(a=1, b: bool = False):

pass


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,23 +124,6 @@ def foo_square_brackets(request):
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"}})
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")))
func([["long line", "long long line", "long long long line", "long long long long line", "long long long long long line"]])

# Do not hug if the argument fits on a single line.
func({"fit line", "fit line", "fit line", "fit line", "fit line", "fit line", "fit line"})
func(("fit line", "fit line", "fit line", "fit line", "fit line", "fit line", "fit line"))
func(["fit line", "fit line", "fit line", "fit line", "fit line", "fit line", "fit line"])
func(**{"fit line", "fit line", "fit line", "fit line", "fit line", "fit line", "fit---"})
func(*("fit line", "fit line", "fit line", "fit line", "fit line", "fit line", "fit----"))
array = [{"fit line", "fit line", "fit line", "fit line", "fit line", "fit line", "fit line"}]
array = [("fit line", "fit line", "fit line", "fit line", "fit line", "fit line", "fit line")]
array = [["fit line", "fit line", "fit line", "fit line", "fit line", "fit line", "fit line"]]

foooooooooooooooooooo(
[{c: n + 1 for c in range(256)} for n in range(100)] + [{}], {size}
)
Expand All @@ -150,14 +133,11 @@ def foo_square_brackets(request):
)

nested_mapping = {"key": [{"a very long key 1": "with a very long value", "a very long key 2": "with a very long value"}]}
nested_array = [[["long line", "long long line", "long long long line", "long long long long line", "long long long long long line"]]]
explicit_exploding = [[["short", "line",],],]
single_item_do_not_explode = Context({
"version": get_docs_version(),
})

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)])

foo(
Expand Down
Loading

0 comments on commit 390adb4

Please sign in to comment.