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

Function is_one_tuple

src/black/nodes.py:616–629  ·  view source on GitHub ↗

Return True if `node` holds a tuple with one element, with or without parens.

(node: LN)

Source from the content-addressed store, hash-verified

614
615
616def is_one_tuple(node: LN) -> bool:
617 """Return True if `node` holds a tuple with one element, with or without parens."""
618 if node.type == syms.atom:
619 gexp = unwrap_singleton_parenthesis(node)
620 if gexp is None or gexp.type != syms.testlist_gexp:
621 return False
622
623 return len(gexp.children) == 2 and gexp.children[1].type == token.COMMA
624
625 return (
626 node.type in IMPLICIT_TUPLE
627 and len(node.children) == 2
628 and node.children[1].type == token.COMMA
629 )
630
631
632def is_tuple(node: LN) -> bool:

Calls 1

Tested by

no test coverage detected