Callable
Any symbol that can be invoked with arguments eg. Function, Class, Decorator, ExternalModule
Inherits from
Properties
call_sites
All invocations of this function elsewhere in the codebase
export
Returns the export object that exports this symbol. Returns none if this symbol is not exported.
exported_name
Returns the name the symbol is exported as. If the symbol is not exported, returns None.
is_exported
Returns True iff the symbol is exported from the file it’s defined in
is_reexported
Returns True if the symbol is re-exported from a file it is not defined in (if applicable)
parameters
All parameters of this callable
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
.
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)
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)
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
get_parameter
Returns the parameter with the given name, or None if it doesn’t exist.
get_parameter_by_index
Returns the parameter with the given index, or None if it doesn’t exist.
get_parameter_by_type
Returns the parameter of specified type, or None if it doesn’t exist.
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
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
Was this page helpful?