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

Function strip_contents_from_if_stmt

mypy/nativeparse.py:1684–1696  ·  view source on GitHub ↗

Remove contents from IfStmt. Needed to still be able to check the conditions after the contents have been merged with the surrounding function overloads.

(stmt: IfStmt)

Source from the content-addressed store, hash-verified

1682
1683
1684def strip_contents_from_if_stmt(stmt: IfStmt) -> None:
1685 """Remove contents from IfStmt.
1686
1687 Needed to still be able to check the conditions after the contents
1688 have been merged with the surrounding function overloads.
1689 """
1690 if len(stmt.body) == 1:
1691 stmt.body[0].body = []
1692 if stmt.else_body and len(stmt.else_body.body) == 1:
1693 if isinstance(stmt.else_body.body[0], IfStmt):
1694 strip_contents_from_if_stmt(stmt.else_body.body[0])
1695 else:
1696 stmt.else_body.body = []
1697
1698
1699def is_stripped_if_stmt(stmt: Statement) -> bool:

Callers 1

fix_function_overloadsFunction · 0.85

Calls 2

lenFunction · 0.85
isinstanceFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…