parent
df965b0558
commit
e94a41f92a
@ -823,6 +823,7 @@ More details can be found in [CONTRIBUTING](CONTRIBUTING.md).
|
|||||||
### 18.8b0
|
### 18.8b0
|
||||||
|
|
||||||
* fix parsing of `__future__` imports with renames (#389)
|
* fix parsing of `__future__` imports with renames (#389)
|
||||||
|
* fix scope of `# fmt: off` when directly preceding `yield` and other nodes (#385)
|
||||||
|
|
||||||
### 18.6b4
|
### 18.6b4
|
||||||
|
|
||||||
|
14
black.py
14
black.py
@ -797,18 +797,6 @@ def show(cls, code: Union[str, Leaf, Node]) -> None:
|
|||||||
syms.testlist_gexp,
|
syms.testlist_gexp,
|
||||||
syms.testlist_star_expr,
|
syms.testlist_star_expr,
|
||||||
}
|
}
|
||||||
SURROUNDED_BY_BRACKETS = {
|
|
||||||
syms.typedargslist,
|
|
||||||
syms.arglist,
|
|
||||||
syms.subscriptlist,
|
|
||||||
syms.vfplist,
|
|
||||||
syms.import_as_names,
|
|
||||||
syms.yield_expr,
|
|
||||||
syms.testlist_gexp,
|
|
||||||
syms.testlist_star_expr,
|
|
||||||
syms.listmaker,
|
|
||||||
syms.dictsetmaker,
|
|
||||||
}
|
|
||||||
TEST_DESCENDANTS = {
|
TEST_DESCENDANTS = {
|
||||||
syms.test,
|
syms.test,
|
||||||
syms.lambdef,
|
syms.lambdef,
|
||||||
@ -1853,7 +1841,7 @@ def container_of(leaf: Leaf) -> LN:
|
|||||||
if parent.type == syms.file_input:
|
if parent.type == syms.file_input:
|
||||||
break
|
break
|
||||||
|
|
||||||
if parent.type in SURROUNDED_BY_BRACKETS:
|
if parent.prev_sibling is not None and parent.prev_sibling.type in BRACKETS:
|
||||||
break
|
break
|
||||||
|
|
||||||
container = parent
|
container = parent
|
||||||
|
@ -48,6 +48,39 @@ def spaces2(result= _core.Value(None)):
|
|||||||
# fmt: off
|
# fmt: off
|
||||||
key: 'value',
|
key: 'value',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def subscriptlist():
|
||||||
|
atom[
|
||||||
|
# fmt: off
|
||||||
|
'some big and',
|
||||||
|
'complex subscript',
|
||||||
|
# fmt: on
|
||||||
|
goes + here, andhere,
|
||||||
|
]
|
||||||
|
|
||||||
|
def import_as_names():
|
||||||
|
# fmt: off
|
||||||
|
from hello import a, b
|
||||||
|
'unformatted'
|
||||||
|
# fmt: on
|
||||||
|
|
||||||
|
def testlist_star_expr():
|
||||||
|
# fmt: off
|
||||||
|
a , b = *hello
|
||||||
|
'unformatted'
|
||||||
|
# fmt: on
|
||||||
|
|
||||||
|
def yield_expr():
|
||||||
|
# fmt: off
|
||||||
|
yield hello
|
||||||
|
'unformatted'
|
||||||
|
# fmt: on
|
||||||
|
'formatted'
|
||||||
|
# fmt: off
|
||||||
|
( yield hello )
|
||||||
|
'unformatted'
|
||||||
|
# fmt: on
|
||||||
|
|
||||||
def example(session):
|
def example(session):
|
||||||
# fmt: off
|
# fmt: off
|
||||||
result = session\
|
result = session\
|
||||||
@ -142,6 +175,7 @@ def single_literal_yapf_disable():
|
|||||||
xxxxxxxxxx_xxxxxxxxxxx_xxxxxxx_xxxxxxxxx=5
|
xxxxxxxxxx_xxxxxxxxxxx_xxxxxxx_xxxxxxxxx=5
|
||||||
)
|
)
|
||||||
# fmt: off
|
# fmt: off
|
||||||
|
yield 'hello'
|
||||||
# No formatting to the end of the file
|
# No formatting to the end of the file
|
||||||
l=[1,2,3]
|
l=[1,2,3]
|
||||||
d={'a':1,
|
d={'a':1,
|
||||||
@ -219,6 +253,43 @@ def spaces2(result=_core.Value(None)):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def subscriptlist():
|
||||||
|
atom[
|
||||||
|
# fmt: off
|
||||||
|
'some big and',
|
||||||
|
'complex subscript',
|
||||||
|
# fmt: on
|
||||||
|
goes + here,
|
||||||
|
andhere,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def import_as_names():
|
||||||
|
# fmt: off
|
||||||
|
from hello import a, b
|
||||||
|
'unformatted'
|
||||||
|
# fmt: on
|
||||||
|
|
||||||
|
|
||||||
|
def testlist_star_expr():
|
||||||
|
# fmt: off
|
||||||
|
a , b = *hello
|
||||||
|
'unformatted'
|
||||||
|
# fmt: on
|
||||||
|
|
||||||
|
|
||||||
|
def yield_expr():
|
||||||
|
# fmt: off
|
||||||
|
yield hello
|
||||||
|
'unformatted'
|
||||||
|
# fmt: on
|
||||||
|
"formatted"
|
||||||
|
# fmt: off
|
||||||
|
( yield hello )
|
||||||
|
'unformatted'
|
||||||
|
# fmt: on
|
||||||
|
|
||||||
|
|
||||||
def example(session):
|
def example(session):
|
||||||
# fmt: off
|
# fmt: off
|
||||||
result = session\
|
result = session\
|
||||||
@ -327,6 +398,7 @@ def single_literal_yapf_disable():
|
|||||||
xxxxxxxxxx_xxxxxxxxxxx_xxxxxxx_xxxxxxxxx=5,
|
xxxxxxxxxx_xxxxxxxxxxx_xxxxxxx_xxxxxxxxx=5,
|
||||||
)
|
)
|
||||||
# fmt: off
|
# fmt: off
|
||||||
|
yield 'hello'
|
||||||
# No formatting to the end of the file
|
# No formatting to the end of the file
|
||||||
l=[1,2,3]
|
l=[1,2,3]
|
||||||
d={'a':1,
|
d={'a':1,
|
||||||
|
Loading…
Reference in New Issue
Block a user