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

Warnings persist in Context #1183

Open
jvansanten opened this issue Aug 1, 2024 · 2 comments
Open

Warnings persist in Context #1183

jvansanten opened this issue Aug 1, 2024 · 2 comments

Comments

@jvansanten
Copy link

I've been playing around with using libcst to copy (newly added) annotations from base class stubs to subclasses in a large legacy codebase. It's pretty neat!

There are some edge cases in this that I can't handle, and so kick them up to the user with Codemod.warn(). There is, however a minor UX issue when processing multiple files in one invocation: once I warn(), the warning persists in the Context for all subsequent files processed by that instance of the Codemod, and so I see spurious warnings attached to the wrong filename:

> python3 -m libcst.tool codemod --hide-blacklisted-warnings -x icetray_codemod.ApplyStubsToSubclasses --stubs ../codemod/stubs.pkl --exclude-patterns 'icecube\.gulliver' sim-services
Calculating full-repo metadata...
Executing codemod...
1.82s 6% complete, 27.87s estimated for 46 files to go...Found 1 error (1 fixed, 0 remaining).
Codemodding /Users/jakob/Documents/IceCube/metaprojects/icetray/src/sim-services/python/gcd_validation/gcd_sanity_checker.py
WARNING: Mismatched arguments. icecube.icetray.I3Module.Finish has 1/0/0 pos-only/normal/kw-only params, I3GCDSanityChecker.Finish has 0/2/0 
Successfully codemodded /Users/jakob/Documents/IceCube/metaprojects/icetray/src/sim-services/python/gcd_validation/gcd_sanity_checker.py with warnings

Codemodding /Users/jakob/Documents/IceCube/metaprojects/icetray/src/sim-services/python/gcd_validation/hit_generator.py
WARNING: Mismatched arguments. icecube.icetray.I3Module.Finish has 1/0/0 pos-only/normal/kw-only params, I3GCDSanityChecker.Finish has 0/2/0 
Successfully codemodded /Users/jakob/Documents/IceCube/metaprojects/icetray/src/sim-services/python/gcd_validation/hit_generator.py with warnings

Codemodding /Users/jakob/Documents/IceCube/metaprojects/icetray/src/sim-services/python/gcd_validation/pe_generator.py
WARNING: Mismatched arguments. icecube.icetray.I3Module.Finish has 1/0/0 pos-only/normal/kw-only params, I3GCDSanityChecker.Finish has 0/2/0 
Successfully codemodded /Users/jakob/Documents/IceCube/metaprojects/icetray/src/sim-services/python/gcd_validation/pe_generator.py with warnings

Codemodding /Users/jakob/Documents/IceCube/metaprojects/icetray/src/sim-services/python/label_events/__init__.py
WARNING: Mismatched arguments. icecube.icetray.I3Module.Finish has 1/0/0 pos-only/normal/kw-only params, I3GCDSanityChecker.Finish has 0/2/0 
Successfully codemodded /Users/jakob/Documents/IceCube/metaprojects/icetray/src/sim-services/python/label_events/__init__.py with warnings

Finished codemodding 49 files!
 - Transformed 31 files successfully.
 - Skipped 18 files.
 - Failed to codemod 0 files.
 - 4 warnings were generated.

Is this the expected behavior?

@kiri11
Copy link
Contributor

kiri11 commented Aug 1, 2024

It's a bug in libcst.tool. There is a PR to fix it, but it was never merged: #665

@kiri11
Copy link
Contributor

kiri11 commented Aug 6, 2024

@jvansanten Should be fixed now in the main branch!
There was no release yet, so you would need to build from source if you'd like to check it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants