Skip to content

Commit

Permalink
remove need to append header
Browse files Browse the repository at this point in the history
  • Loading branch information
Ogban Ugot committed Mar 16, 2024
1 parent 7f6102a commit 20438c2
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions ivy_lint/formatters/function_ordering.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,19 +607,10 @@ def _extended_rearrange_functions_and_classes(self, original_source_code: str, r
current_section.append((code, node))
sorted_sections[current_header] = current_section

for header, section in sorted_sections.items():
sorted_section = sorted(section, key=sort_key)
sorted_sections[header] = sorted_section

reordered_code_list_main = []
for header, section in sorted_sections.items():
if header == "":
reordered_code_list_main.extend(code for code, _ in section)
else:
header = header.strip("#")
reordered_code_list_main.append(f"#{header}")
pattern = re.compile(rf"#\s?({re.escape(header)}|-+)\s?#")
reordered_code_list_main.extend(pattern.sub("", code) for code, _ in section)
sorted_section = sorted(section, key=sort_key)
reordered_code_list_main.extend(code for code, _ in sorted_section)

tree = ast.parse(reordered_code)
nodes_with_comments = self._extract_all_nodes_with_comments(tree, reordered_code)
Expand Down

0 comments on commit 20438c2

Please sign in to comment.