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

Function is_yield

src/black/nodes.py:769–787  ·  view source on GitHub ↗

Return True if `node` holds a `yield` or `yield from` expression.

(node: LN)

Source from the content-addressed store, hash-verified

767
768
769def is_yield(node: LN) -> bool:
770 """Return True if `node` holds a `yield` or `yield from` expression."""
771 if node.type == syms.yield_expr:
772 return True
773
774 if is_name_token(node) and node.value == "yield":
775 return True
776
777 if node.type != syms.atom:
778 return False
779
780 if len(node.children) != 3:
781 return False
782
783 lpar, expr, rpar = node.children
784 if lpar.type == token.LPAR and rpar.type == token.RPAR:
785 return is_yield(expr)
786
787 return False
788
789
790def is_vararg(leaf: Leaf, within: set[NodeType]) -> bool:

Callers 1

Calls 1

is_name_tokenFunction · 0.85

Tested by

no test coverage detected