Commit c2327c83 authored by Łukasz Langa's avatar Łukasz Langa
Browse files

More tests for `# fmt: off`

Two more known limitations that I don't feel like solving now.  Probably very
low priority.
parent 048efa74
Loading
Loading
Loading
Loading
+3 −0
Changes for black.py: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -2577,6 +2577,9 @@ def convert_one_fmt_off_pair(node: Node) -> bool:
                        continue

                ignored_nodes = list(generate_ignored_nodes(leaf))
                if not ignored_nodes:
                    continue

                first = ignored_nodes[0]  # Can be a container node with the `leaf`.
                parent = first.parent
                prefix = first.prefix
+44 −0
Changes for tests/data/fmtonoff.py: 44 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -53,6 +53,27 @@ def example(session):
        .order_by(models.Customer.id.asc())\
        .all()
    # 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():
    if True:
        typedargslist.extend(
@@ -201,6 +222,29 @@ def example(session):
    # 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():
    if True:
        typedargslist.extend(