Parse AST of definition.
(self, typ: str)
| 555 | self.finalize_block() |
| 556 | |
| 557 | def parse_definition(self, typ: str) -> None: |
| 558 | """Parse AST of definition.""" |
| 559 | name = self.fetch_token() |
| 560 | self.context.append(name.value) # type: ignore[union-attr] |
| 561 | funcname = '.'.join(self.context) |
| 562 | |
| 563 | if self.decorator: |
| 564 | start_pos = self.decorator.start[0] |
| 565 | self.decorator = None |
| 566 | else: |
| 567 | start_pos = name.start[0] # type: ignore[union-attr] |
| 568 | |
| 569 | self.fetch_until([OP, ':']) |
| 570 | if self.fetch_token().match(COMMENT, NEWLINE): # type: ignore[union-attr] |
| 571 | self.fetch_until(INDENT) |
| 572 | self.indents.append((typ, funcname, start_pos)) |
| 573 | else: |
| 574 | # one-liner |
| 575 | self.add_definition(funcname, (typ, start_pos, name.end[0])) # type: ignore[union-attr] |
| 576 | self.context.pop() |
| 577 | |
| 578 | def finalize_block(self) -> None: |
| 579 | """Finalize definition block.""" |
no test coverage detected