(self, original_node: cst.FunctionDef, updated_node: cst.FunctionDef)
| 1003 | return node |
| 1004 | |
| 1005 | def leave_FunctionDef(self, original_node: cst.FunctionDef, updated_node: cst.FunctionDef): |
| 1006 | if self.current_class_name != self.class_name: |
| 1007 | return updated_node |
| 1008 | if updated_node.name.value.startswith("__") and updated_node.name.value.endswith("__"): |
| 1009 | return updated_node |
| 1010 | if updated_node.name.value == "_initAttributes": |
| 1011 | return self.update_init_attrs(updated_node) |
| 1012 | |
| 1013 | nodes = [] |
| 1014 | if updated_node.name.value == "_useAttributes": |
| 1015 | while self.current_property: |
| 1016 | prop = self.properties.pop(0) |
| 1017 | node = self.create_property_function(prop.name, prop.data_type, prop.deprecated) |
| 1018 | nodes.append(cst.EmptyLine(indent=False)) |
| 1019 | nodes.append(node) |
| 1020 | nodes.append(self.update_use_attrs(updated_node)) |
| 1021 | return cst.FlattenSentinel(nodes=nodes) |
| 1022 | |
| 1023 | updated_node_is_github_object_property = self.is_github_object_property(updated_node) |
| 1024 | |
| 1025 | while self.current_property and ( |
| 1026 | updated_node_is_github_object_property |
| 1027 | and self.current_property.name < updated_node.name.value |
| 1028 | or not updated_node_is_github_object_property |
| 1029 | ): |
| 1030 | prop = self.properties.pop(0) |
| 1031 | node = self.create_property_function(prop.name, prop.data_type, prop.deprecated) |
| 1032 | nodes.append(cst.EmptyLine(indent=False)) |
| 1033 | nodes.append(node) |
| 1034 | |
| 1035 | if updated_node_is_github_object_property: |
| 1036 | if ( |
| 1037 | not self.current_property |
| 1038 | or updated_node.name.value != self.current_property.name |
| 1039 | or self.current_property.deprecated |
| 1040 | ): |
| 1041 | nodes.append(self.deprecate_function(updated_node) if self.deprecate else updated_node) |
| 1042 | else: |
| 1043 | nodes.append(updated_node) |
| 1044 | if self.current_property and updated_node.name.value == self.current_property.name: |
| 1045 | self.properties.pop(0) |
| 1046 | else: |
| 1047 | nodes.append(updated_node) |
| 1048 | |
| 1049 | return cst.FlattenSentinel(nodes=nodes) |
| 1050 | |
| 1051 | def create_property_function( |
| 1052 | self, name: str, data_type: PythonType | GithubClass | None, deprecated: bool |
nothing calls this directly
no test coverage detected