Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
devel:languages:python:jupyter
python-nbsmoke
nbsmoke-pr63-remove-id.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File nbsmoke-pr63-remove-id.patch of Package python-nbsmoke
From 86860f1900bbc38f0a1873001bb8f420f66d96d4 Mon Sep 17 00:00:00 2001 From: maximlt <mliquet@anaconda.com> Date: Mon, 3 Oct 2022 14:30:05 +0200 Subject: [PATCH 2/2] remove added id field when not required --- nbsmoke/lint/magics/__init__.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/nbsmoke/lint/magics/__init__.py b/nbsmoke/lint/magics/__init__.py index 8e991e8..c23f2ab 100644 --- a/nbsmoke/lint/magics/__init__.py +++ b/nbsmoke/lint/magics/__init__.py @@ -120,11 +120,23 @@ def _load_user_magic_handlers(path): def insert_get_ipython(nb): # define and use get_ipython (for pyflakes) if len(nb['cells']) > 0: + is_id_field = 'id' in nb['cells'][0] # the get_ipython() is so pyflakes doesn't complain if no # magics present (which would leave get_ipython unused) get_ipython_cell = nbformat.v4.new_code_cell( 'from IPython import get_ipython\nget_ipython()') nb['cells'].insert(0,get_ipython_cell) + # Starting from nbformat 4.5 notebook cells must have an id field. + # So adding a new cell with new_code_cell will add a cell with an id field. + # However, if the notebook was based on a previous version (e.g. 4.2), + # then it would contain a mix of id and non id cells. Newer versions + # of nbformat (5.6) raise an error when validating such notebook while + # before they were mutating it. nbconvert uses nbformat to validate + # it build proper notebooks, in particular after applying preprocessors. + # This change remove the id added by new_code_cell if the notebook + # didn't have ids (just checking the first cell...). + if 'id' in nb['cells'][0] and not is_id_field: + del nb['cells'][0]['id'] def ipython_to_python_for_flake_checks(self, ipy):
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor