Inherits from

Exportable

Properties


call_sites

All invocations of this function elsewhere in the codebase

def call_sites(self) -> list[FunctionCall]:
    ...

export

Returns the export object that exports this symbol. Returns none if this symbol is not exported.

def export(self) -> Export | None:
    ...

exported_name

Returns the name the symbol is exported as. If the symbol is not exported, returns None.

def exported_name(self) -> str | None:
    ...

is_exported

Returns True iff the symbol is exported from the file it’s defined in

def is_exported(self) -> bool:
    ...

is_reexported

Returns True if the symbol is re-exported from a file it is not defined in (if applicable)

def is_reexported(self) -> bool:
    ...

parameters

All parameters of this callable

def parameters(self) -> SymbolGroup[TParameter, Self] | None:
    ...

Methods


call_graph_successors

Returns all Callable objects that are reachable from this Callable.

Args: include_classes (bool): If True, includes class definitions in the code paths. include_external (bool): If True, includes external modules in the code paths.

Returns: list[Function | ExternalModule]: A list of Function or ExternalModule objects that are reachable from this Callable.

def call_graph_successors(
        self,
        *,
        include_classes: bool = True,
        include_external: bool = True,
    ) -> list[FunctionCallDefinition]:
    ...

get_all_symbol_usages

Returns a list of all symbols that uses this exportable object, via direct or indirect usages. Equivalent to get_symbol_usages(UsageType.DIRECT | UsageType.INDIRECT | UsageType.ALIASED)

def get_all_symbol_usages(self) -> list[Import | Symbol | Export]:
    ...

get_all_usages

Returns a list of all usages of this exportable object, via direct or indirect usages. Equivalent to get_usages(UsageType.DIRECT | UsageType.INDIRECT | UsageType.ALIASED)

def get_all_usages(self) -> list[Usage]:
    ...

get_import_string

Returns the import string needed to import this symbol.

  • If alias is specified, formats the import using the alias.
  • If module is specified, uses the specified module, otherwise defaults to the current module.
  • If import_type is ImportType.WILDCARD, imports the symbol’s module. e.g. from module import symbol as alias
def get_import_string(self, alias: str | None = None, module: str | None = None, import_type: ImportType = ImportType.UNKNOWN, is_type_import: bool = False) -> str:
    ...

get_parameter

Returns the parameter with the given name, or None if it doesn’t exist.

def get_parameter(self, name: str) -> TParameter | None:
    ...

get_parameter_by_index

Returns the parameter with the given index, or None if it doesn’t exist.

def get_parameter_by_index(self, index: int) -> TParameter | None:
    ...

get_parameter_by_type

Returns the parameter of specified type, or None if it doesn’t exist.

def get_parameter_by_type(self, type: "Symbol") -> TParameter | None:
    ...

get_symbol_usages

Symbols that uses this exportable object, or imports that imports this exportable object. By default, only returns direct usages, such as Imports or usages within the same file. In other words, it will tell you where this symbol is imported, but not where it is used. Inverse of dependencies.

Arguments: usage_types: What kind of usages to search for

def get_symbol_usages(self, usage_types: UsageType = UsageType.DIRECT | UsageType.CHAINED) -> list[Import | Symbol | Export]:
    ...

get_usages

Returns a list of usages of the exportable object. By default, only returns direct usages, such as Imports or usages within the same file. In other words, it will tell you where this symbol is imported, but not where it is used. Useful for dead code deletion.

Arguments: usage_types: What kind of usages to search for

def get_usages(self, usage_types: UsageType = UsageType.DIRECT | UsageType.CHAINED) -> list[Usage]:
    ...