Utility function to store a function as a magic of a specific kind. Parameters ---------- dct : dict A dictionary with 'line' and 'cell' subdicts. magic_kind : str Kind of magic to be stored. magic_name : str Key to store the magic as. func : function
(
dct: dict[str, dict[str, Any]],
magic_kind: _MagicSpec,
magic_name: str,
func: Any,
)
| 123 | |
| 124 | |
| 125 | def record_magic( |
| 126 | dct: dict[str, dict[str, Any]], |
| 127 | magic_kind: _MagicSpec, |
| 128 | magic_name: str, |
| 129 | func: Any, |
| 130 | ) -> None: |
| 131 | """Utility function to store a function as a magic of a specific kind. |
| 132 | |
| 133 | Parameters |
| 134 | ---------- |
| 135 | dct : dict |
| 136 | A dictionary with 'line' and 'cell' subdicts. |
| 137 | magic_kind : str |
| 138 | Kind of magic to be stored. |
| 139 | magic_name : str |
| 140 | Key to store the magic as. |
| 141 | func : function |
| 142 | Callable object to store. |
| 143 | """ |
| 144 | if magic_kind == "line_cell": |
| 145 | dct["line"][magic_name] = dct["cell"][magic_name] = func |
| 146 | else: |
| 147 | dct[magic_kind][magic_name] = func |
| 148 | |
| 149 | |
| 150 | def validate_type(magic_kind: str) -> None: |
no outgoing calls
no test coverage detected
searching dependent graphs…