nbQA icon indicating copy to clipboard operation
nbQA copied to clipboard

name temporary files with a pattern which can be globbed

Open l0b0 opened this issue 2 years ago • 12 comments

When nbQA runs it extracts a foo[randomness].py file from foo.ipynb, and puts this file in the same directory as the notebook. This confuses my IDE, which is set to add any new files to VCS. It would probably be better to put this in a temporary directory.

l0b0 avatar Jan 13 '23 01:01 l0b0

It would probably be better to put this in a temporary directory.

It used to be like this, but then that caused issues for importing modules

The temporary files should be automatically cleaned up after nbqa finishes running though, is that not what you're seeing?

MarcoGorelli avatar Jan 13 '23 21:01 MarcoGorelli

can't reproduce this, even on windows - my only guess is that you repeatedly ran ctrl+C while nbQA was still running and someone intercepted the finally block which cleans up the temporary files?

closing for now then, but thanks for the report

MarcoGorelli avatar Jan 14 '23 18:01 MarcoGorelli

No, I didn't Ctrl-C. nbQA just ran long enough for the IDE to see the file and stage it.

l0b0 avatar Jan 15 '23 19:01 l0b0

I see - which IDE was it, just out of interest?

Either way, I'd suggest reporting to them (or seeing if they have a way of increasing the time for temporary files)

MarcoGorelli avatar Jan 15 '23 20:01 MarcoGorelli

JetBrains IDEA. It would be closed as not an issue, because it's a feature. I've set up my IDE to add all files to VCS when they are created.

l0b0 avatar Jan 15 '23 20:01 l0b0

doesn't this cause issues for you when using other tools that create temporary files, such as pytest or yesqa?

MarcoGorelli avatar Jan 15 '23 20:01 MarcoGorelli

Those are in .gitignore, so the IDE ignores them. nbQA is special since it creates a file in the same directory and with almost the same name, without any easy way to glob just for the temporary files.

l0b0 avatar Jan 15 '23 21:01 l0b0

so if the temporary file names all started with the same pattern, such as .nbqa.foo[randomness].py, then that would work as a solution for you?

if so, then sure, pull requests welcome

MarcoGorelli avatar Jan 15 '23 21:01 MarcoGorelli

so if the temporary file names all started with the same pattern, such as .nbqa.foo[randomness].py, then that would work as a solution for you?

Yeah, something like that would be great!

l0b0 avatar Jan 15 '23 21:01 l0b0

cool, here's the contributing guide if you're interested in submitting a PR https://nbqa.readthedocs.io/en/latest/contributing.html

MarcoGorelli avatar Jan 15 '23 21:01 MarcoGorelli