Parse the code and obtain comment after assignment.
(self)
| 218 | return tokens |
| 219 | |
| 220 | def parse(self) -> None: |
| 221 | """Parse the code and obtain comment after assignment.""" |
| 222 | # skip lvalue (or whole of AnnAssign) |
| 223 | while (tok := self.fetch_token()) and not tok.match( |
| 224 | [OP, '='], NEWLINE, COMMENT |
| 225 | ): |
| 226 | assert tok |
| 227 | assert tok is not None |
| 228 | |
| 229 | # skip rvalue (if exists) |
| 230 | if tok == [OP, '=']: |
| 231 | self.fetch_rvalue() |
| 232 | tok = self.current |
| 233 | assert tok is not None |
| 234 | |
| 235 | if tok == COMMENT: |
| 236 | self.comment = tok.value |
| 237 | |
| 238 | |
| 239 | class VariableCommentPicker(ast.NodeVisitor): |
no test coverage detected