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

Function unwrap_singleton_parenthesis

src/black/nodes.py:1008–1019  ·  view source on GitHub ↗

Returns `wrapped` if `node` is of the shape ( wrapped ). Parenthesis can be optional. Returns None otherwise

(node: LN)

Source from the content-addressed store, hash-verified

1006
1007
1008def unwrap_singleton_parenthesis(node: LN) -> LN | None:
1009 """Returns `wrapped` if `node` is of the shape ( wrapped ).
1010
1011 Parenthesis can be optional. Returns None otherwise"""
1012 if len(node.children) != 3:
1013 return None
1014
1015 lpar, wrapped, rpar = node.children
1016 if not (lpar.type == token.LPAR and rpar.type == token.RPAR):
1017 return None
1018
1019 return wrapped
1020
1021
1022def ensure_visible(leaf: Leaf) -> None:

Callers 6

is_one_tupleFunction · 0.85
is_tupleFunction · 0.85
is_tuple_containing_starFunction · 0.85
is_generatorFunction · 0.85
is_walrus_assignmentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected