fix crash with long type annotations (#1093)
This commit is contained in:
parent
d10b56e6f7
commit
53808e3902
8
black.py
8
black.py
@ -2601,9 +2601,11 @@ def bracket_split_build_line(
|
|||||||
# Since body is a new indent level, remove spurious leading whitespace.
|
# Since body is a new indent level, remove spurious leading whitespace.
|
||||||
normalize_prefix(leaves[0], inside_brackets=True)
|
normalize_prefix(leaves[0], inside_brackets=True)
|
||||||
# Ensure a trailing comma for imports and standalone function arguments, but
|
# Ensure a trailing comma for imports and standalone function arguments, but
|
||||||
# be careful not to add one after any comments.
|
# be careful not to add one after any comments or within type annotations.
|
||||||
no_commas = original.is_def and not any(
|
no_commas = (
|
||||||
l.type == token.COMMA for l in leaves
|
original.is_def
|
||||||
|
and opening_bracket.value == "("
|
||||||
|
and not any(l.type == token.COMMA for l in leaves)
|
||||||
)
|
)
|
||||||
|
|
||||||
if original.is_import or no_commas:
|
if original.is_import or no_commas:
|
||||||
|
@ -4,6 +4,11 @@ def f(a,):
|
|||||||
def f(a:int=1,):
|
def f(a:int=1,):
|
||||||
...
|
...
|
||||||
|
|
||||||
|
def xxxxxxxxxxxxxxxxxxxxxxxxxxxx() -> Set[
|
||||||
|
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||||
|
]:
|
||||||
|
pass
|
||||||
|
|
||||||
# output
|
# output
|
||||||
|
|
||||||
def f(a,):
|
def f(a,):
|
||||||
@ -12,3 +17,9 @@ def f(a,):
|
|||||||
|
|
||||||
def f(a: int = 1,):
|
def f(a: int = 1,):
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
|
def xxxxxxxxxxxxxxxxxxxxxxxxxxxx() -> Set[
|
||||||
|
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||||
|
]:
|
||||||
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user