Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions user_tools/src/spark_rapids_pytools/common/sys_storage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023-2024, NVIDIA CORPORATION.
# Copyright (c) 2023-2025, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -239,7 +239,7 @@ def gen_dir_tree(cls,
dir_count = 0

def inner(dir_p: pathlib.Path, prefix: str = '', level=-1):
nonlocal files_count, dir_count, dir_patterns, file_patterns
nonlocal files_count, dir_count
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see dir_patterns and file_patterns are being used.
I guess it is because it is nort needed to be redefined as non_local.

Would this work for python 3.9+?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is correct. Since these are read-only variables (defined in the outer function), we do not need them to be non_local.

Yes, all tox tests passed for python versions 3.9-3.12.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK, Tox is not a 100% reliable way to tell because if the unit-tests do not cover that path, we won't know that something is wrong in runtime.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. That is true. In this case, I think it should be fine because these variables are read-only and these variables can be safely read in the inner function.

if not level:
return # 0, stop iterating
sub_items = []
Expand Down