Find the first magic assignment (a = %foo) in the cell.
(cls, tokens_by_line)
| 213 | """Transformer for assignments from magics (a = %foo)""" |
| 214 | @classmethod |
| 215 | def find(cls, tokens_by_line): |
| 216 | """Find the first magic assignment (a = %foo) in the cell. |
| 217 | """ |
| 218 | for line in tokens_by_line: |
| 219 | assign_ix = _find_assign_op(line) |
| 220 | if (assign_ix is not None) \ |
| 221 | and (len(line) >= assign_ix + 2) \ |
| 222 | and (line[assign_ix+1].string == '%') \ |
| 223 | and (line[assign_ix+2].type == tokenize.NAME): |
| 224 | return cls(line[assign_ix+1].start) |
| 225 | |
| 226 | def transform(self, lines: List[str]): |
| 227 | """Transform a magic assignment found by the ``find()`` classmethod. |
nothing calls this directly
no test coverage detected