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: dictnotebook document
version: intversion_minor: intrelax_add_props: boolWhether to allow extra property in the Json schema validating the notebook.
strip_invalid_metadata: boolWhether to strip metadata that does not exist in the Json schema when validating the notebook.
Returns
changes: intnumber of changes in the notebooks
notebook: dictdeep-copy of the original object with relevant changes.
Aliases
nbformat.validator.normalize