Open stephenpaulger opened 2 months ago
Hi @stephenpaulger ! Thanks for the suggestion! If I understand it correctly, I think unit tests would fail which should warn a codemod author that something is up. But we're open to PRs if you'd like to contribute.
It's possibly something that will be less important once there's some more documentation. While I was trying to create a codemod starting from the cookiecutter template that was working with just libcst I was seeing that my code to replace a node was running but the changes weren't applied and I had to use pdb to go up the stack to find why.
I'm happy to send a PR given you're open to them 😃
The code where I think it might be worth adding a warning is in the
apply
method ofLibcstTransformerPipeline
.In the case where
tree
has changes but the codemod author has not added to thefile_context.codemod_changes
array the changes they are expecting to be made will be discarded. I would say that when both conditions areFalse
it's likely the codemod author will expect nothing to happen but in cases where only one isFalse
it would be useful for there to be a warning printed as I think any time there is a element infile_context.codemod_changes
or there is a tree diff the codemod author intended for something to happen.