Skip to content

modules

Classes:

NamespaceKind

Bases: str, Enum

Distinguish the semantic origin of one namespace-valued binding while keeping the user-facing expression model uniform.

NamespaceType

NamespaceType(
    namespace_key: str,
    *,
    namespace_kind: NamespaceKind = MODULE,
    display_name: str | None = None,
)

Bases: AnyType

Represent one imported namespace value during semantic analysis and lowering without modeling it as a user-defined runtime aggregate. attributes: namespace_key: type: str namespace_kind: type: NamespaceKind display_name: type: str | None

Methods:

Attributes:

Source code in packages/irx/src/irx/astx/modules.py
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
def __init__(
    self,
    namespace_key: str,
    *,
    namespace_kind: NamespaceKind = NamespaceKind.MODULE,
    display_name: str | None = None,
) -> None:
    """
    title: Initialize one namespace type.
    parameters:
      namespace_key:
        type: str
      namespace_kind:
        type: NamespaceKind
      display_name:
        type: str | None
    """
    super().__init__()
    self.namespace_key = namespace_key
    self.namespace_kind = namespace_kind
    self.display_name = display_name

module_key property

module_key: str

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/modules.py
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Build one repr structure for a namespace type.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    visible_name = self.display_name or self.namespace_key
    key = f"NAMESPACE[{self.namespace_kind.value}:{visible_name}]"
    return self._prepare_struct(key, visible_name, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )