Skip to content

Conversation

@parthosa
Copy link
Collaborator

@parthosa parthosa commented Apr 1, 2025

Fixes #1608.

This PR fixes the code for a new warning added in the newly released flake8: PyCQA/pyflakes#825.

@parthosa parthosa added bug Something isn't working user_tools Scope the wrapper module running CSP, QualX, and reports (python) labels Apr 1, 2025
@parthosa parthosa self-assigned this Apr 1, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes warnings raised by flake8 7.2.0 by removing unused nonlocal declarations and updates the copyright year.

  • Updated copyright year from 2024 to 2025.
  • Removed unused nonlocal variables (dir_patterns and file_patterns) from the inner function.
Comments suppressed due to low confidence (1)

user_tools/src/spark_rapids_pytools/common/sys_storage.py:242

  • Confirm that the removal of 'dir_patterns' and 'file_patterns' from the nonlocal declaration does not affect any remaining references in the function. If these variables are no longer used, consider removing their declarations from the outer scope as well.
nonlocal files_count, dir_count

Signed-off-by: Partho Sarthi <[email protected]>
Copy link
Collaborator

@amahussein amahussein left a comment

Choose a reason for hiding this comment

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

Thanks @parthosa
QQ if this works on Py [3.9, 3.12]?


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.

@parthosa parthosa requested a review from amahussein April 1, 2025 19:12
Copy link
Collaborator

@amahussein amahussein left a comment

Choose a reason for hiding this comment

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

It is interesting to see that co-pilot reviews are enabled on our repo.

Thanks @parthosa !
P.s: check the comment about Tox.

LGTME

@parthosa
Copy link
Collaborator Author

parthosa commented Apr 2, 2025

P.s: check the comment about Tox.

Thanks @amahussein. I agree tox does not guarantee the coverage. But in this case, I think it should be fine because these variables are read-only and hence can be safely read in the inner function.

@parthosa parthosa merged commit e140710 into NVIDIA:dev Apr 2, 2025
14 checks passed
@parthosa parthosa deleted the spark-rapids-tools-1608 branch April 2, 2025 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working user_tools Scope the wrapper module running CSP, QualX, and reports (python)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Fix unused global warnings from new flake8 7.2.0

2 participants