Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jschavesr
Copy link

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

@facebook-github-bot
Copy link

Hi @jschavesr!

Thank you for your pull request and welcome to our community.

Action Required

In 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.

Process

In 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 CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 24, 2022
@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

Copy link
Contributor

@stroxler stroxler left a 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.",
Copy link
Contributor

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?

@stroxler
Copy link
Contributor

stroxler commented Apr 7, 2022

Running CI, I'll merge if it comes back clean

Copy link
Contributor

@stroxler stroxler left a 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,
Copy link
Contributor

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.

@kiri11
Copy link
Contributor

kiri11 commented Jul 30, 2024

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants