astx.collections.common

astx.collections.common

Source: packages/astx/src/astx/collections/common.py

title: ASTx shared collection helper AST nodes.
summary: >-
  Provide backend-neutral collection query nodes that frontends can target when
  they need common list, tuple, set, or dictionary operations without binding
  directly to one runtime representation.

Classes

CollectionLength(astx.base.DataType)

title: Common collection length query node.
summary: >-
  Return the logical length of a list, tuple, set, or dictionary as an
  Int32 value.
attributes:
  base:
    type: astx.AST
  type_:
    type: astx.Int32

Methods

get_struct(self, simplified: bool=False) -> astx.base.ReprStruct
title: Return the structured representation.
parameters:
  simplified:
    type: bool
returns:
  type: astx.base.ReprStruct

CollectionIsEmpty(astx.base.DataType)

title: Common collection emptiness query node.
summary: >-
  Return whether a list, tuple, set, or dictionary has no logical entries.
attributes:
  base:
    type: astx.AST
  type_:
    type: astx.Boolean

Methods

get_struct(self, simplified: bool=False) -> astx.base.ReprStruct
title: Return the structured representation.
parameters:
  simplified:
    type: bool
returns:
  type: astx.base.ReprStruct

CollectionContains(astx.base.DataType)

title: Common collection containment query node.
summary: >-
  Return whether a list, tuple, or set contains a value, or whether a
  dictionary contains a key.
attributes:
  base:
    type: astx.AST
  value:
    type: astx.AST
  type_:
    type: astx.Boolean

Methods

get_struct(self, simplified: bool=False) -> astx.base.ReprStruct
title: Return the structured representation.
parameters:
  simplified:
    type: bool
returns:
  type: astx.base.ReprStruct

CollectionIndex(astx.base.DataType)

title: Common sequence index query node.
summary: >-
  Return the first zero-based index of a value in a list or tuple. The
  initial ASTx contract returns -1 when the value is not found.
attributes:
  base:
    type: astx.AST
  value:
    type: astx.AST
  type_:
    type: astx.Int32

Methods

get_struct(self, simplified: bool=False) -> astx.base.ReprStruct
title: Return the structured representation.
parameters:
  simplified:
    type: bool
returns:
  type: astx.base.ReprStruct

CollectionCount(astx.base.DataType)

title: Common sequence count query node.
summary: >-
  Return how many times a value appears in a list or tuple as an Int32
  value.
attributes:
  base:
    type: astx.AST
  value:
    type: astx.AST
  type_:
    type: astx.Int32

Methods

get_struct(self, simplified: bool=False) -> astx.base.ReprStruct
title: Return the structured representation.
parameters:
  simplified:
    type: bool
returns:
  type: astx.base.ReprStruct