isinstance
function.
if
block or a try/catch
statement.
Codegen supports this functionality with the Editable.is_wrapped_in(…) method.
.parent_statement
, which can be used to navigate the statement hierarchy.
wrap
and unwrap
are potentially unsafe changes and will modify
business logic.unwrap()
method preserves the indentation of the code block’s contents
while removing the wrapping structure. This is useful for refactoring nested
code structures.