More tests for # fmt: off
Two more known limitations that I don't feel like solving now. Probably very low priority.
This commit is contained in:
parent
048efa7476
commit
c2327c83b2
3
black.py
3
black.py
@ -2577,6 +2577,9 @@ def convert_one_fmt_off_pair(node: Node) -> bool:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
ignored_nodes = list(generate_ignored_nodes(leaf))
|
ignored_nodes = list(generate_ignored_nodes(leaf))
|
||||||
|
if not ignored_nodes:
|
||||||
|
continue
|
||||||
|
|
||||||
first = ignored_nodes[0] # Can be a container node with the `leaf`.
|
first = ignored_nodes[0] # Can be a container node with the `leaf`.
|
||||||
parent = first.parent
|
parent = first.parent
|
||||||
prefix = first.prefix
|
prefix = first.prefix
|
||||||
|
@ -53,6 +53,27 @@ def example(session):
|
|||||||
.order_by(models.Customer.id.asc())\
|
.order_by(models.Customer.id.asc())\
|
||||||
.all()
|
.all()
|
||||||
# fmt: on
|
# fmt: on
|
||||||
|
def off_and_on_without_data():
|
||||||
|
"""All comments here are technically on the same prefix.
|
||||||
|
|
||||||
|
The comments between will be formatted. This is a known limitation.
|
||||||
|
"""
|
||||||
|
# fmt: off
|
||||||
|
|
||||||
|
|
||||||
|
#hey, that won't work
|
||||||
|
|
||||||
|
|
||||||
|
# fmt: on
|
||||||
|
pass
|
||||||
|
def on_and_off_broken():
|
||||||
|
"""Another known limitation."""
|
||||||
|
# fmt: on
|
||||||
|
# fmt: off
|
||||||
|
this=should.not_be.formatted()
|
||||||
|
but=it is formatted
|
||||||
|
because . the . handling . inside . generate_ignored_nodes()
|
||||||
|
doesnt . consider . ordering . within . one . prefix
|
||||||
def long_lines():
|
def long_lines():
|
||||||
if True:
|
if True:
|
||||||
typedargslist.extend(
|
typedargslist.extend(
|
||||||
@ -201,6 +222,29 @@ def example(session):
|
|||||||
# fmt: on
|
# fmt: on
|
||||||
|
|
||||||
|
|
||||||
|
def off_and_on_without_data():
|
||||||
|
"""All comments here are technically on the same prefix.
|
||||||
|
|
||||||
|
The comments between will be formatted. This is a known limitation.
|
||||||
|
"""
|
||||||
|
# fmt: off
|
||||||
|
|
||||||
|
# hey, that won't work
|
||||||
|
|
||||||
|
# fmt: on
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def on_and_off_broken():
|
||||||
|
"""Another known limitation."""
|
||||||
|
# fmt: on
|
||||||
|
# fmt: off
|
||||||
|
this = should.not_be.formatted()
|
||||||
|
but = it is formatted
|
||||||
|
because.the.handling.inside.generate_ignored_nodes()
|
||||||
|
doesnt.consider.ordering.within.one.prefix
|
||||||
|
|
||||||
|
|
||||||
def long_lines():
|
def long_lines():
|
||||||
if True:
|
if True:
|
||||||
typedargslist.extend(
|
typedargslist.extend(
|
||||||
|
Loading…
Reference in New Issue
Block a user