-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Add flake8 to pre-commit checks #2051
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
Conversation
|
@aphedges This is great - is it ready for review? |
|
@mrwyattii, not yet. I've been rebasing a local version periodically to fix new breakages, but I haven't pushed it yet. I also have a comment to finish writing up because I found some bugs that I've suppressed warnings for in favor of getting the checks implemented. I expect to finish my improvements and set it ready for review later this week. |
|
@mrwyattii, it's all ready! I've pushed my latest changes, updated the PR description with some additional information, and set the PR as ready for review. |
mrwyattii
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mostly looks good to me. I left some comments for changes that I'm unsure about if you could help me understand.
There are quite a few added #noqa for F401 and F821 - is this normal to need to add these when bringing flake into a project? I'd like to better understand why they are necessary.
I personally think it depends on the codebase, and the reason for locally suppressing the two checks are different: The usages of I needed to refresh myself about my usage of I also suppressed some checks in the pre-commit configuration itself. Some, like the I don't intend this to be an absolutely comprehensive PR for flake8 integration. This is just meant to be a step to fix some problems and prevent the introduction of some more in the future. Other people can improve on the work I've done here if more or better checks are desired. |
|
@mrwyattii, just following up on this. This kind of PR is annoying to rebase, so I'd like it get merged before one of the larger PRs makes it in. |
|
Hi @aphedges, thank you so much for doing this PR! I am looking it over now and overall it looks good, but just trying to make sure there aren't any subtle issues since it touches so many files. Let's try and merge it in this week but there are other PRs coming that we're working on today. |
|
I completely understand that you want to carefully review this. I'll keep updating it as new PRs make it to |
|
I have rebased against |
|
I have rebased against |
|
I have rebased against master again to fix the merge conflict and the new flake8 errors introduced in 69b7c97. The commit also introduced an error (calling |
|
I have fixed the new merge conflict caused by 844d9f3. |
|
@jeffra, have you gotten around to reviewing yet? |
|
I have rebased against |
|
I have rebased against The sooner this PR gets merged, the sooner PR authors can fix these mistakes themselves that will often cause their code to fail at runtime. |
|
There was a test failure but I couldn't rerun it myself, so I rebased and force-pushed. |
jeffra
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @aphedges for all your hard work on this! It's very much appreciated :)
|
@jeffra, thanks for merging it! I needed to suppress some errors for undeclared variables I could not fix myself. All of the lines would cause a crash if they are run. Should I make issues for them so they aren't just lost in this PR? They are all bugs waiting to happen. |
Back in #1602, I proposed adding flake8 checks, and @jeffra said it was a good idea. I've put in two PRs (#1601 and #2050) that likely would have been caught by flake8, so I decided to finally get some of the work I had done locally into a better state and into a PR.
I don't have the testing infrastructure to run the full test suite locally, so I'll be using periodic pushes to this PR to fix problems as needed. Hopefully it doesn't take too long to complete.All CI now passes.I changed a docstring but couldn't render the documentation to verify I didn't break anything. I think my almost complete lack of Ruby knowledge makes trying to fix the rendering errors not worth the effort.
I tried to fix as much code as I could, but I used
# noqa: F821to suppress some errors so the check can be used going forward. Here are the locations of my usage and when the error was introduced:print_rank_0was recently broken in 5349347 (2022-07-25).unfused_modewas recently broken in 8164ea9 (2022-05-24).Broken code removed in cf587b8 (2022-07-26)._dim_to_namehas always broken since it was added in 6996bb0 (2021-09-21).Broken code removed in 0f4f2f9 (2022-07-19).q_rangehas always broken since it was added in ed3de0c (2021-05-24).profilehas always broken since it was added in a128f34 (2021-04-07).checkpoint,cuda, andresolved_archive_filehave always broken since it was added in 734d899 (2020-05-29).None of these errors, which would have shown up if the code were ever run, are reported as issues, so I suspect the code is neither tested nor used. I suggest someone with more knowledge of these components look into fixes or remove what might be dead code.