Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Based on whether the metadata has "init_cell": true,
"keep_output": true, or the tags contain "keep_output" """
if 'metadata' not in cell:
return default
if 'init_cell' in cell.metadata:
return bool(cell.metadata.init_cell)
has_keep_output_metadata = 'keep_output' in cell.metadata
keep_output_metadata = bool(cell.metadata.get('keep_output', False))
has_keep_output_tag = 'keep_output' in cell.metadata.get('tags', [])
# keep_output between metadata and tags should not contradict each other
if has_keep_output_metadata and has_keep_output_tag and not keep_output_metadata:
raise MetadataError(
"cell metadata contradicts tags: "
"\"keep_output\": false, but keep_output in tags"
)
if has_keep_output_metadata or has_keep_output_tag:
return keep_output_metadata or has_keep_output_tag
return default