-
Notifications
You must be signed in to change notification settings - Fork 192
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
Clean warnings in context when transforming multiple files #665
base: main
Are you sure you want to change the base?
Conversation
Hi @jschavesr! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
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.
Thanks for the fix @jschavesr!
) | ||
# Each module will generate 2 warnings, so we should get 6 warnings in total | ||
self.assertIn( | ||
"- 6 warnings were generated.", |
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.
I take it 6 because there are 2 per file - would it have been 2 + 4 + 6 = 12 prior to this fix?
Running CI, I'll merge if it comes back clean |
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.
Unfortunately we need to fix a Windows bug before we merge - I commented where I think the problem is coming from.
From now on, I think every time you push changes it should run CI automatically - it has to be manually approved the first time you make a PR
"libcst.tool", | ||
"codemod", | ||
"convert_format_to_fstring.ConvertFormatStringCommand", | ||
p, |
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.
Looks like we're getting test failures on Python 3.7 + Windows.
I think the problem may be here - the other test in this module calls str
on the Path before passing it to subprocess.run
.
@jschavesr Do you plan on completing this? Looks very useful, without this change it's impossible to use warnings in multiprocessing context. They all get duplicated and assigned to wrong files. If you are no longer interested, I could take over and submit an updated copy of this PR. Thanks! |
Summary
Using libCST cli tool allows to run a codemod over files inside a folder recursively. Context warning messages were not being cleaned between files, so warnings from one files could be passed to other files in the context. Because of that warnings were being shown wrongly in the summary and the total number of warnings was wrong as well.
Test Plan
python3 -m unittest libcst.codemod.tests.test_codemod_cli