Handles Expr node and pick up a comment if string.
(self, node: ast.Expr)
| 438 | self._handle_assignment(node) |
| 439 | |
| 440 | def visit_Expr(self, node: ast.Expr) -> None: |
| 441 | """Handles Expr node and pick up a comment if string.""" |
| 442 | if ( |
| 443 | isinstance(self.previous, AssignmentLikeType) |
| 444 | and isinstance(node.value, ast.Constant) |
| 445 | and isinstance(node.value.value, str) |
| 446 | ): |
| 447 | try: |
| 448 | targets = get_assign_targets(self.previous) |
| 449 | varnames = get_lvar_names(targets[0], self.get_self()) |
| 450 | for varname in varnames: |
| 451 | if isinstance(node.value.value, str): |
| 452 | docstring = node.value.value |
| 453 | else: |
| 454 | docstring = node.value.value.decode(self.encoding or 'utf-8') |
| 455 | |
| 456 | self.add_variable_comment(varname, dedent_docstring(docstring)) |
| 457 | self.add_entry(varname) |
| 458 | except TypeError: |
| 459 | pass # this assignment is not new definition! |
| 460 | |
| 461 | def visit_Try(self, node: ast.Try) -> None: |
| 462 | """Handles Try node and processes body and else-clause. |
nothing calls this directly
no test coverage detected