(node, context)
| 690 | |
| 691 | |
| 692 | def _handle_annassign(node, context): |
| 693 | context_with_value = context.replace(current_value=getattr(node, "value", None)) |
| 694 | annotation_result = eval_node(node.annotation, context_with_value) |
| 695 | if _is_type_annotation(annotation_result): |
| 696 | annotation_value = _resolve_annotation(annotation_result, context) |
| 697 | # Use Value for generic types |
| 698 | use_value = ( |
| 699 | isinstance(annotation_value, GENERIC_CONTAINER_TYPES) and node.value is not None |
| 700 | ) |
| 701 | else: |
| 702 | annotation_value = annotation_result |
| 703 | use_value = False |
| 704 | |
| 705 | # LOCAL VARIABLE |
| 706 | if getattr(node, "simple", False) and isinstance(node.target, ast.Name): |
| 707 | name = node.target.id |
| 708 | if use_value: |
| 709 | return _handle_assign( |
| 710 | ast.Assign(targets=[node.target], value=node.value), context |
| 711 | ) |
| 712 | context.transient_locals[name] = annotation_value |
| 713 | return None |
| 714 | |
| 715 | # INSTANCE ATTRIBUTE |
| 716 | if _is_instance_attribute_assignment(node.target, context): |
| 717 | attr = node.target.attr |
| 718 | if use_value: |
| 719 | return _handle_assign( |
| 720 | ast.Assign(targets=[node.target], value=node.value), context |
| 721 | ) |
| 722 | context.class_transients[attr] = annotation_value |
| 723 | return None |
| 724 | |
| 725 | return None |
| 726 | |
| 727 | def _extract_args_and_kwargs(node: ast.Call, context: EvaluationContext): |
| 728 | args = [eval_node(arg, context) for arg in node.args] |
no test coverage detected
searching dependent graphs…