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

Method maybe_increment_lambda_arguments

src/black/brackets.py:188–199  ·  view source on GitHub ↗

In a lambda expression, there might be more than one argument. To avoid splitting on the comma in this situation, increase the depth of tokens between `lambda` and `:`.

(self, leaf: Leaf)

Source from the content-addressed store, hash-verified

186 return False
187
188 def maybe_increment_lambda_arguments(self, leaf: Leaf) -> bool:
189 """In a lambda expression, there might be more than one argument.
190
191 To avoid splitting on the comma in this situation, increase the depth of
192 tokens between `lambda` and `:`.
193 """
194 if leaf.type == token.NAME and leaf.value == "lambda":
195 self.depth += 1
196 self._lambda_argument_depths.append(self.depth)
197 return True
198
199 return False
200
201 def maybe_decrement_after_lambda_arguments(self, leaf: Leaf) -> bool:
202 """See `maybe_increment_lambda_arguments` above for explanation."""

Callers 1

markMethod · 0.95

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected