class FunctionDef(LocalsDictNode, MultiLineBlock, Statement, ScopeSsaMixin, FunctionMixin): (source)
Known subclasses: klara.core.scoped_node_classes.AsyncFunctionDef
Undocumented
Method | __init__ |
Undocumented |
Method | __repr__ |
Undocumented |
Method | assign |
point the arg to the class_instance during inference stage. if duplicate_ins is True, the class_instance will be duplicated, this means that any attribute that assigned to the instance will not affect the original class instance... |
Method | generate |
generate an expression to rename all the decorators create stmt: Expr: decorators :return: Expr |
Method | generate |
generate multiple statement to simulate renaming of Scope without body. 1. generate Name object for scope name. 2. collect all Name object to be rename except body. create stmt: Assign: {self.func} = Proxy(self) Expr: {list of collected name} :return: tuple of statement... |
Method | get |
get the instance for arg This can be use to check the instance modify in this scope. E.g.: >>> from klara.tools.tree_rewriter import AstBuilder >>> tree = AstBuilder().string_build("def __init__(self): self... |
Method | get |
E.g. def foo(a: int) will return the type int Raise: |
Method | get |
Undocumented |
Method | init |
necessary initialization involving method. This will setup the `self` argument to contain the class available attribute. |
Method | is |
Undocumented |
Method | is |
Undocumented |
Method | postinit |
Undocumented |
Instance Variable | args |
Undocumented |
Instance Variable | body |
Undocumented |
Instance Variable | called |
Undocumented |
Instance Variable | decorator |
Undocumented |
Instance Variable | name |
Undocumented |
Instance Variable | return |
Undocumented |
Instance Variable | returns |
Undocumented |
Property | type |
return the function type for this node Possibles values are method, function, staticmethod and classmethod. Doesn't handle decorator resolving yet. Only statically check the functionDef itself. |
Class Variable | _fields |
Undocumented |
Class Variable | _other |
Undocumented |
Inherited from LocalsDictNode
:
Class Method | from |
Undocumented |
Method | create |
Undocumented |
Method | get |
return the latest statement in locals dict |
Method | get |
Get the latest version from stack, and get the corresponding statement |
Method | get |
get the version number of the var, create the var entry if it's not exists |
Method | remove |
Undocumented |
Method | resolve |
Undocumented |
Method | scope |
return the first containing scope |
Method | update |
increment the version of the var inside the dict and return the version number :param var: :param block_label: :return: |
Instance Variable | containing |
Undocumented |
Instance Variable | global |
Undocumented |
Instance Variable | instance |
Undocumented |
Instance Variable | locals |
Undocumented |
Instance Variable | ssa |
Undocumented |
Inherited from Statement
(via LocalsDictNode
):
Method | get |
Get all replaced links' statement, traversing the links |
Method | get |
To be implemented in Assign and Expr |
Method | get |
get targets variable that is associated with rhs variable var E.g. a.b = c.d = d calling get_lhs_value(d) will return [a.b, c.d] a.b, e.f, f.g = c.d, d.e, g = d, e, f calling get_lhs_value(f) will return [f... |
Method | get |
get variable in rhs that is associate with var in lhs E.g. a, b, c = d ,e, f = g, h, i calling `get_rhs_value(b)` will return h :param var: the variable in the targets :return: Variable in rhs |
Method | get |
To be implemented in Assign and AugAssign. Return the targets variable |
Method | get |
To be implemented in Assign and AugAssign |
Method | statement |
Undocumented |
Instance Variable | is |
Undocumented |
Instance Variable | replaced |
Undocumented |
Static Method | _get |
construct a real slice() object based on the relationship of var in container :param var: variable refer to construct the slice :param container: the container that contain variable var :return: a slice() object... |
Method | _get |
Get the `value` that is stored in `value_container` in the `target_container` also help to unpack the value. It follows the steps below: 1. get the real slice value from the relationship of `value` in `value_container` 2... |
Inherited from BaseNode
(via LocalsDictNode
, Statement
):
Static Method | get |
Undocumented |
Method | __contains__ |
Undocumented |
Method | accept |
Undocumented |
Method | dunder |
try to resolve the dunder method |
Method | generic |
Undocumented |
Method | get |
Undocumented |
Method | get |
Undocumented |
Method | get |
find the definition of `var` from outer scope recursively. Skip param will determine how many parent scope to skip :param var: variable of interest :param skip: how many layer of parent scope to skip :return:... |
Method | get |
Undocumented |
Method | get |
Undocumented |
Method | get |
get the assigning target instance rather than scope(). See #mr68u a.b.c = node calling node.get_target_instance() will return `a.b.c.instance()` |
Method | is |
check if the given node is part of 'self' or children |
Method | iter |
Yield a tuple of ``(fieldname, value)`` for each field in ``node._fields`` that is present on *node*. |
Method | prepare |
Undocumented |
Instance Variable | col |
Undocumented |
Instance Variable | explicit |
Undocumented |
Instance Variable | lineno |
Undocumented |
Instance Variable | parent |
Undocumented |
Instance Variable | refer |
Undocumented |
Inherited from FunctionMixin
(via LocalsDictNode
, Statement
, BaseNode
, ScopeSsaMixin
):
Method | mock |
insert a statement with targets=all the argument starting with offset. Mainly for renaming :param offset: The offset of arg to apply :return: None |
point the arg to the class_instance during inference stage. if duplicate_ins is True, the class_instance will be duplicated, this means that any attribute that assigned to the instance will not affect the original class instance. :param value: the argument :param class_instance: class instance to point to :param duplicate_ins: boolean for duplicating class instance :return: None
Parameters | |
value:Arg | Undocumented |
class | Undocumented |
duplicate | Undocumented |
generate multiple statement to simulate renaming of Scope without body. 1. generate Name object for scope name. 2. collect all Name object to be rename except body. create stmt: Assign: {self.func} = Proxy(self) Expr: {list of collected name} :return: tuple of statement
get the instance for arg This can be use to check the instance modify in this scope. E.g.: >>> from klara.tools.tree_rewriter import AstBuilder >>> tree = AstBuilder().string_build("def __init__(self): self.x = 1") >>> tree.body[0].get_arg_instance(0) `self` instance being added attribute of `x`. Can merge it back to the instance :param arg_number: the position of argument to :return:
necessary initialization involving method. This will setup the `self` argument to contain the class available attribute.
return the function type for this node Possibles values are method, function, staticmethod and classmethod. Doesn't handle decorator resolving yet. Only statically check the functionDef itself.