kynan / nbstripout

strip output from Jupyter and IPython notebooks
Other
1.19k stars 95 forks source link

Metadata python version attribute #72

Closed MaicoTimmerman closed 5 years ago

MaicoTimmerman commented 6 years ago

The metadata["language_info"]["version"] = ... causes merge conflicts when using different python versions. While this has no affect on the workings on the notebook, can we also stripout this attribute?

MishaVeldhoen commented 6 years ago

I agree that this would be quite useful to have as an option, and it doesn’t seem like removing the version number has any effect. Probably best done through an optional parameter --strip-version.

kynan commented 6 years ago

Agree, I have been thinking about this as well. The version dependent keys afaict are the following:

metadata["kernel_spec"]["display_name"]
metadata["kernel_spec"]["name"]
metadata["language_info"]["codemirror_mode"]["version"]
metadata["language_info"]["pygments_lexer"]
metadata["language_info"]["version"]

I'm not super happy hardcoding these values, but assuming the metadata representation is stable it may not be that bad.

For consistency I suggest stripping those by default, unless --keep-version is given.

For the implementation I think it's time to refactor strip_output to take an iterable of (hierarchical) keys to strip so we can do away with the many ifs.

I can't promise when I'll have time to work on this, but contributions are welcome!