MCPcopy
hub / github.com/psf/black / _rhs

Function _rhs

src/black/linegen.py:759–784  ·  view source on GitHub ↗

Wraps calls to `right_hand_split`. The calls increasingly `omit` right-hand trailers (bracket pairs with content), meaning the trailers get glued together to split on another bracket pair instead.

(
            self: object, line: Line, features: Collection[Feature], mode: Mode
        )

Source from the content-addressed store, hash-verified

757 else:
758
759 def _rhs(
760 self: object, line: Line, features: Collection[Feature], mode: Mode
761 ) -> Iterator[Line]:
762 """Wraps calls to `right_hand_split`.
763
764 The calls increasingly `omit` right-hand trailers (bracket pairs with
765 content), meaning the trailers get glued together to split on another
766 bracket pair instead.
767 """
768 for omit in generate_trailers_to_omit(line, mode.line_length):
769 lines = list(right_hand_split(line, mode, features, omit=omit))
770 # Note: this check is only able to figure out if the first line of the
771 # *current* transformation fits in the line length. This is true only
772 # for simple cases. All others require running more transforms via
773 # `transform_line()`. This check doesn't know if those would succeed.
774 if is_line_short_enough(lines[0], mode=mode) or (
775 omit and _over_length_only_due_to_subscript_comment(lines[0], mode)
776 ):
777 yield from lines
778 return
779
780 # All splits failed, best effort split with no omits.
781 # This mostly happens to multiline strings that are by definition
782 # reported as not fitting a single line, as well as lines that contain
783 # trailing commas (those have to be exploded).
784 yield from right_hand_split(line, mode, features=features)
785
786 # HACK: nested functions (like _rhs) compiled by mypyc don't retain their
787 # __name__ attribute which is needed in `run_transformer` further down.

Callers

nothing calls this directly

Calls 4

is_line_short_enoughFunction · 0.90
right_hand_splitFunction · 0.85

Tested by

no test coverage detected