class documentation

class PlaceholderNode(SymbolNode): (source)

View In Hierarchy

Temporary symbol node that will later become a real SymbolNode.

These are only present during semantic analysis when using the new semantic analyzer. These are created if some essential dependencies of a definition are not yet complete.

A typical use is for names imported from a module which is still incomplete (within an import cycle):

from m import f # Initially may create PlaceholderNode

This is particularly important if the imported shadows a name from an enclosing scope or builtins:

from m import int # Placeholder avoids mixups with builtins.int

Another case where this is useful is when there is another definition or assignment:

from m import f def f() -> None: ...

In the above example, the presence of PlaceholderNode allows us to handle the second definition as a redefinition.

They are also used to create PlaceholderType instances for types that refer to incomplete types. Example:

class C(Sequence[C]): ...

We create a PlaceholderNode (with becomes_typeinfo=True) for C so that the type C in Sequence[C] can be bound.

Attributes:

fullname: Full name of of the PlaceholderNode. node: AST node that contains the definition that caused this to

be created. This is useful for tracking order of incomplete definitions and for debugging.
becomes_typeinfo: If True, this refers something that could later
become a TypeInfo. It can't be used with type variables, in particular, as this would cause issues with class type variable detection.

The long-term purpose of placeholder nodes/types is to evolve into something that can support general recursive types.

Method __init__ Undocumented
Method accept Undocumented
Method serialize Undocumented
Class Variable __slots__ Undocumented
Instance Variable becomes​_typeinfo Undocumented
Instance Variable line Undocumented
Instance Variable node Undocumented
Property fullname Undocumented
Property name Undocumented
Instance Variable _fullname Undocumented

Inherited from SymbolNode:

Class Method deserialize Undocumented

Inherited from Node (via SymbolNode):

Method __str__ Undocumented

Inherited from Context (via SymbolNode, Node):

Method get​_column Don't use. Use x.column.
Method get​_line Don't use. Use x.line.
Method set​_line If target is a node, pull line (and column) information into this node. If column is specified, this will override any column information coming from a node.
Instance Variable column Undocumented
Instance Variable end​_line Undocumented
def __init__(self, fullname, node, line, *, becomes_typeinfo=False): (source)

Undocumented

Parameters
fullname:strUndocumented
node:NodeUndocumented
line:intUndocumented
becomes​_typeinfo:boolUndocumented
def accept(self, visitor): (source)

Undocumented

Parameters
visitor:NodeVisitor[T]Undocumented
Returns
TUndocumented
def serialize(self): (source)

Undocumented

Returns
JsonDictUndocumented
__slots__: tuple[str, ...] = (source)

Undocumented

becomes_typeinfo = (source)

Undocumented

line = (source)

Undocumented

node = (source)

Undocumented

@property
fullname: str = (source)

Undocumented

@property
name: str = (source)

Undocumented

_fullname = (source)

Undocumented