nbstripout icon indicating copy to clipboard operation
nbstripout copied to clipboard

dry run seems to always print that a file would be changed

Open alonme opened this issue 3 years ago • 11 comments

I noticed that when using dry_run, all files are always printed as if they would be changed.

Looking at the code briefly, it does seem like this is what happens.

alonme avatar Jun 08 '21 07:06 alonme

all files are always printed as if they would be changed

Can you clarify what you mean? What are "all files" here?

kynan avatar Jun 08 '21 22:06 kynan

Yes, sorry for being unclear.

every file that is passed to nbstripout will print. Dry run: would have stripped {file}

this happens even if a strip a file and then right after that run a dry run.

my expectation is that only files that would have been changed if a "wet run" would have been used - would be printed

alonme avatar Jun 09 '21 05:06 alonme

OK, I see what you mean. It is a fair point, but not trivial to support unfortunately: it would mean checking if applying nbstripout would have created a diff, which we don't currently have an easy way to do.

I'll add it as a feature request to the backlog.

kynan avatar Jun 09 '21 18:06 kynan

Thanks.

Just so i understand - what is the current value of the dry-run option?

alonme avatar Jun 09 '21 19:06 alonme

It will tell you which files are in scope / would be touched. I agree that your definition is more useful.

kynan avatar Jun 12 '21 15:06 kynan

Could this be related to this other issue? https://github.com/kynan/nbstripout/issues/160

joaonc avatar Nov 01 '21 17:11 joaonc

@joaonc only tangentially. This request is about turning --dry-run into an "actual" dry run and only report if any changes would have been made.

kynan avatar Jan 02 '22 20:01 kynan

@alonme Would you be interested in implementing this?

kynan avatar Sep 24 '22 12:09 kynan

I am facing trouble here, I'll want to give this a try at implementing this @kynan

swateek avatar Oct 06 '22 12:10 swateek

@swateek sure! You'd need to change this line to not overwrite the notebook and then in the following if args.dry_run: block you'd need to check if any changes were applied and then only output if there is a diff. You should also do this for the Zeppelin notebook type above. Is this enough to get you started?

kynan avatar Oct 08 '22 12:10 kynan

let me try this out!

swateek avatar Oct 10 '22 02:10 swateek