MCPcopy Create free account
hub / github.com/python/mypy / is_stripped_if_stmt

Function is_stripped_if_stmt

mypy/nativeparse.py:1699–1716  ·  view source on GitHub ↗

Check stmt to make sure it is a stripped IfStmt. See also: strip_contents_from_if_stmt

(stmt: Statement)

Source from the content-addressed store, hash-verified

1697
1698
1699def is_stripped_if_stmt(stmt: Statement) -> bool:
1700 """Check stmt to make sure it is a stripped IfStmt.
1701
1702 See also: strip_contents_from_if_stmt
1703 """
1704 if not isinstance(stmt, IfStmt):
1705 return False
1706
1707 if not (len(stmt.body) == 1 and len(stmt.body[0].body) == 0):
1708 # Body not empty
1709 return False
1710
1711 if not stmt.else_body or len(stmt.else_body.body) == 0:
1712 # No or empty else_body
1713 return True
1714
1715 # For elif, IfStmt are stored recursively in else_body
1716 return is_stripped_if_stmt(stmt.else_body.body[0])
1717
1718
1719def fail_merge_overload(state: State, node: IfStmt) -> None:

Callers 1

Calls 2

isinstanceFunction · 0.85
lenFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…