Handles Assign node and pick up a variable comment.
(self, node: ast.Assign | ast.AnnAssign)
| 338 | return self.buffers[lineno - 1] |
| 339 | |
| 340 | def _handle_assignment(self, node: ast.Assign | ast.AnnAssign) -> None: |
| 341 | """Handles Assign node and pick up a variable comment.""" |
| 342 | try: |
| 343 | targets = get_assign_targets(node) |
| 344 | varnames: list[str] = functools.reduce( |
| 345 | operator.iadd, |
| 346 | [get_lvar_names(t, self=self.get_self()) for t in targets], |
| 347 | [], |
| 348 | ) |
| 349 | current_line = self.get_line(node.lineno) |
| 350 | except TypeError: |
| 351 | return # this assignment is not new definition! |
| 352 | |
| 353 | # record annotation |
| 354 | if hasattr(node, 'annotation') and node.annotation: |
| 355 | for varname in varnames: |
| 356 | self.add_variable_annotation(varname, node.annotation) |
| 357 | elif hasattr(node, 'type_comment') and node.type_comment: |
| 358 | for varname in varnames: |
| 359 | self.add_variable_annotation(varname, node.type_comment) # type: ignore[arg-type] |
| 360 | self._collect_doc_comment(node, varnames, current_line) |
| 361 | |
| 362 | def _collect_doc_comment( |
| 363 | self, |
no test coverage detected