Skip to content

ClassScope

Bases: Scope

Represents a Scope that defines the scope of a class.

Attributes:

Name Type Description
class_variables dict[str, list[Symbol]]

The name of the class variable and a list of its Symbols (which represent a declaration). There can be multiple declarations of the same class variable, e.g. a = 1 and a = 2 since we cannot determine which one is used since we do not analyze the control flow. Also, it is impossible to distinguish between a declaration and a reassignment.

instance_variables dict[str, list[Symbol]]

The name of the instance variable and a list of its Symbols (which represent a declaration).

init_function FunctionScope | None

The init function of the class if it exists else None.

super_classes list[ClassScope]

The list of superclasses of the class if any.

Source code in src/library_analyzer/processing/api/purity_analysis/model/_module_data.py
@dataclass
class ClassScope(Scope):
    """Represents a Scope that defines the scope of a class.

    Attributes
    ----------
    class_variables :
        The name of the class variable and a list of its Symbols (which represent a declaration).
        There can be multiple declarations of the same class variable, e.g. `a = 1` and `a = 2`
        since we cannot determine which one is used since we do not analyze the control flow.
        Also, it is impossible to distinguish between a declaration and a reassignment.
    instance_variables :
        The name of the instance variable and a list of its Symbols (which represent a declaration).
    init_function :
        The init function of the class if it exists else None.
    super_classes :
        The list of superclasses of the class if any.
    """

    class_variables: dict[str, list[Symbol]] = field(default_factory=dict)
    instance_variables: dict[str, list[Symbol]] = field(default_factory=dict)
    new_function: FunctionScope | None = None
    init_function: FunctionScope | None = None
    post_init_function: FunctionScope | None = None
    super_classes: list[ClassScope] = field(default_factory=list)

class_variables: dict[str, list[Symbol]] = field(default_factory=dict) class-attribute instance-attribute

init_function: FunctionScope | None = None class-attribute instance-attribute

instance_variables: dict[str, list[Symbol]] = field(default_factory=dict) class-attribute instance-attribute

new_function: FunctionScope | None = None class-attribute instance-attribute

post_init_function: FunctionScope | None = None class-attribute instance-attribute

super_classes: list[ClassScope] = field(default_factory=list) class-attribute instance-attribute

__init__(_symbol, _children=list(), _parent=None, class_variables=dict(), instance_variables=dict(), new_function=None, init_function=None, post_init_function=None, super_classes=list())