X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/7e6d3fac197395b0a2b380cc60811536fe23626b..71a2daaacf92d361c09bc7613023b285df83e7bb:/src/black/nodes.py diff --git a/src/black/nodes.py b/src/black/nodes.py index a588077..90728f3 100644 --- a/src/black/nodes.py +++ b/src/black/nodes.py @@ -789,6 +789,16 @@ def is_import(leaf: Leaf) -> bool: ) +def is_with_stmt(leaf: Leaf) -> bool: + """Return True if the given leaf starts a with statement.""" + return bool( + leaf.type == token.NAME + and leaf.value == "with" + and leaf.parent + and leaf.parent.type == syms.with_stmt + ) + + def is_type_comment(leaf: Leaf, suffix: str = "") -> bool: """Return True if the given leaf is a special comment. Only returns true for type comments for now."""