Skip to content

Commit

Permalink
fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesbvll committed Jun 19, 2024
1 parent e6e95b1 commit f68a77d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/py/flwr_tool/init_py_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ def check_missing_init_files(absolute_path: str) -> List[str]:
return dir_list


def get_all_var_list(dir: str) -> Tuple[Path, List[str], List[str]]:
def get_all_var_list(init_dir: str) -> Tuple[Path, List[str], List[str]]:
"""Get the __all__ list of a __init__.py file.
The function returns the path of the '__init__.py' file of the given dir, as well as
the list itself, and the list of lines corresponding to the list.
"""
init_file = Path(dir) / "__init__.py"
init_file = Path(init_dir) / "__init__.py"
all_lines = []
all_list = []
capture = False
Expand All @@ -79,8 +79,8 @@ def check_all_init_files(dir_list: List[str]) -> None:
"""Check if __all__ is in alphabetical order in __init__.py files."""
warning_list = []

for dir in dir_list:
init_file, all_list, _ = get_all_var_list(dir)
for init_dir in dir_list:
init_file, all_list, _ = get_all_var_list(init_dir)

if all_list and not all_list == sorted(all_list):
warning_message = "- " + str(init_file)
Expand All @@ -104,5 +104,5 @@ def check_all_init_files(dir_list: List[str]) -> None:
)
for i, _ in enumerate(sys.argv):
abs_path: str = os.path.abspath(os.path.join(os.getcwd(), sys.argv[i]))
dir_list = check_missing_init_files(abs_path)
check_all_init_files(dir_list)
init_dirs = check_missing_init_files(abs_path)
check_all_init_files(init_dirs)
10 changes: 5 additions & 5 deletions src/py/flwr_tool/init_py_fix.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ def fix_all_init_files(dir_list: List[str]) -> None:
"""Sort the __all__ variables that are in __init__.py files."""
warning_list = []

for dir in dir_list:
init_file, all_list, all_lines = get_all_var_list(dir)
for init_dir in dir_list:
init_file, all_list, all_lines = get_all_var_list(init_dir)

if all_list:
sorted_all_list = sorted(all_list)
if not all_list == sorted_all_list:
warning_message = "- " + str(dir)
warning_message = "- " + str(init_dir)
warning_list.append(warning_message)

old_all_lines = "\n".join(all_lines)
Expand Down Expand Up @@ -65,5 +65,5 @@ def fix_all_init_files(dir_list: List[str]) -> None:
)
for i, _ in enumerate(sys.argv):
abs_path: str = os.path.abspath(os.path.join(os.getcwd(), sys.argv[i]))
warnings, dir_list = get_init_dir_list_and_warnings(abs_path)
fix_all_init_files(dir_list)
warnings, init_dirs = get_init_dir_list_and_warnings(abs_path)
fix_all_init_files(init_dirs)

0 comments on commit f68a77d

Please sign in to comment.