WithDynamicSharedPip

WithDynamicSharedPip#

class penzai.treescope.handlers.shared_value_postprocessor.WithDynamicSharedPip[source]#

Bases: DeferringToChild

Dynamic group that adds an orange marker to its child if it is shared.

This node is used to apply special rendering to nodes that are encountered in multiple places in the same input. It works by holding a particular node ID as well as a reference to a set of node IDs that have been seen more than once. When rendered, it checks if its node ID has been seen more than once and renders differently if so.

Note that we might have only seen this object once at the time the shared warning object is constructed, even if eventually we will see it again. This means the seen_more_than_once attribute has to be (a reference to) a mutable set modified elsewhere.

Shared markers always act like their child. They also do not disrupt children drawing themselves first.

Variables:
  • child (penzai.treescope.foldable_representation.part_interface.RenderableTreePart) – Child to render.

  • node_id (int) – Node ID of the node we are rendering. Used for the warning and also looked up in seen_more_than_once.

  • seen_more_than_once (set[int]) – Reference to an externally-maintaned set of node IDs we’ve seen more than once. Usually, this will be the same set from the active _shared_object_ids_seen context.

Inherited Attributes

collapsed_width

The length of this rendering if collapsed in one line, in characters.

newlines_in_expanded_parent

The number of newlines in this rendering if in an expanded parent.

tags_in_this_part

Returns a set of "tag" objects contained in this part.

Methods

__init__(child, node_id, seen_more_than_once)

html_setup_parts(setup_context)

render_to_html(stream, *[, at_beginning_of_line])

Attributes

collapsed_width

The length of this rendering if collapsed in one line, in characters.

newlines_in_expanded_parent

The number of newlines in this rendering if in an expanded parent.

tags_in_this_part

Returns a set of "tag" objects contained in this part.

child

node_id

seen_more_than_once

Inherited Methods

(expand to view inherited methods)

foldables_in_this_part()

render_to_text(stream, *, expanded_parent, ...)