Skip to content

format_code.py: fix NameError when --d is specified #1356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2023

Conversation

dconeybe
Copy link
Contributor

@dconeybe dconeybe commented Jun 21, 2023

This PR fixes an apparent copy/paste error in format_code.py in the list_files_from_directory() function where it uses a local variable named line, that doesn't exist. The correct local variable name is filename.

The result of this bug is that when --d is specified as a command-line argument the app crashes with a NameError:

$ python3 scripts/format_code.py --verbose --d firestore/src --r
Searching files in directory: "firestore/src"
Traceback (most recent call last):
  File "scripts/format_code.py", line 276, in <module>
    app.run(main)
  File "site-packages/absl/app.py", line 308, in run
    _run_main(main, args)
  File "site-packages/absl/app.py", line 254, in _run_main
    sys.exit(main(argv))
  File "scripts/format_code.py", line 223, in main
    filenames += directory_search_list_files()
  File "scripts/format_code.py", line 191, in directory_search_list_files
    filenames += list_files_from_directory(directory, FLAGS.r)
  File "scripts/format_code.py", line 168, in list_files_from_directory
    if(FILE_PATHS_TO_IGNORE.match(line)):
NameError: name 'line' is not defined. Did you mean: 'slice'?

It appears that there is a copy/paste error in `list_files_from_directory()` where it uses a local variable named `line`; however, the _correct_ local variable name is `filename`.
@dconeybe dconeybe added the skip-release-notes Skip release notes check label Jun 21, 2023
@dconeybe dconeybe self-assigned this Jun 21, 2023
@dconeybe dconeybe enabled auto-merge (squash) June 21, 2023 17:23
@dconeybe dconeybe merged commit 055e879 into main Jun 21, 2023
@github-actions github-actions bot added the tests: in-progress This PR's integration tests are in progress. label Jun 21, 2023
@dconeybe dconeybe deleted the dconeybe/FormatCodeDirectoryNameErrorFix branch June 21, 2023 18:28
@github-actions
Copy link

github-actions bot commented Jun 21, 2023

Integration test with FLAKINESS (succeeded after retry)

Requested by @dconeybe on commit 055e879
Last updated: Wed Jun 21 14:13 PDT 2023
View integration test log & download artifacts

Failures Configs
gma [TEST] [FLAKINESS] [iOS] [macos] [1/2 ios_device: ios_target]
(1 failed tests)  CRASH/TIMEOUT

Add flaky tests to go/fpl-cpp-flake-tracker

@github-actions github-actions bot added the tests: succeeded This PR's integration tests succeeded. label Jun 21, 2023
@firebase-workflow-trigger firebase-workflow-trigger bot removed the tests: in-progress This PR's integration tests are in progress. label Jun 21, 2023
@firebase firebase locked and limited conversation to collaborators Jul 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
skip-release-notes Skip release notes check tests: succeeded This PR's integration tests succeeded.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants