{ } Raw JSON

bundles / nbformat 5.11.1 / nbformat / validator / normalize

function

nbformat.validator:normalize

source: /nbformat/validator.py:264

Signature

def normalize(nbdict: Any, version: int | None = None, version_minor: int | None = None, *, relax_add_props: bool = False, strip_invalid_metadata: bool = False) → tuple[int, Any]

Summary

Normalise a notebook prior to validation.

Extended Summary

This tries to implement a couple of normalisation steps to standardise notebooks and make validation easier.

You should in general not rely on this function and make sure the notebooks that reach nbformat are already in a normal form. If not you likely have a bug, and may have security issues.

Parameters

nbdict : dict

notebook document

version : int
version_minor : int
relax_add_props : bool

Whether to allow extra property in the Json schema validating the notebook.

strip_invalid_metadata : bool

Whether to strip metadata that does not exist in the Json schema when validating the notebook.

Returns

changes : int

number of changes in the notebooks

notebook : dict

deep-copy of the original object with relevant changes.

Aliases

  • nbformat.validator.normalize