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

Function _is_ipython_magic

src/black/handle_ipynb_magics.py:342–354  ·  view source on GitHub ↗

Check if attribute is IPython magic. Note that the source of the abstract syntax tree will already have been processed by IPython's TransformerManager().transform_cell.

(node: ast.expr)

Source from the content-addressed store, hash-verified

340
341
342def _is_ipython_magic(node: ast.expr) -> TypeGuard[ast.Attribute]:
343 """Check if attribute is IPython magic.
344
345 Note that the source of the abstract syntax tree
346 will already have been processed by IPython's
347 TransformerManager().transform_cell.
348 """
349 return (
350 isinstance(node, ast.Attribute)
351 and isinstance(node.value, ast.Call)
352 and isinstance(node.value.func, ast.Name)
353 and node.value.func.id == "get_ipython"
354 )
355
356
357def _get_str_args(args: list[ast.expr]) -> list[str]:

Callers 3

visit_ExprMethod · 0.85
visit_AssignMethod · 0.85
visit_ExprMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected