Given an ast of all the lines in a function, generate a list of variables in that function. Variables are tokens and what they link to. In this case, what it links to is just a string. However, that is resolved later. :param lines list[ast]: :param parent Group: :rtype:
(lines, parent)
| 105 | |
| 106 | |
| 107 | def make_local_variables(lines, parent): |
| 108 | """ |
| 109 | Given an ast of all the lines in a function, generate a list of |
| 110 | variables in that function. Variables are tokens and what they link to. |
| 111 | In this case, what it links to is just a string. However, that is resolved |
| 112 | later. |
| 113 | |
| 114 | :param lines list[ast]: |
| 115 | :param parent Group: |
| 116 | :rtype: list[Variable] |
| 117 | """ |
| 118 | variables = [] |
| 119 | for tree in lines: |
| 120 | for element in ast.walk(tree): |
| 121 | if type(element) == ast.Assign: |
| 122 | variables += process_assign(element) |
| 123 | if type(element) in (ast.Import, ast.ImportFrom): |
| 124 | variables += process_import(element) |
| 125 | if parent.group_type == GROUP_TYPE.CLASS: |
| 126 | variables.append(Variable('self', parent, lines[0].lineno)) |
| 127 | |
| 128 | variables = list(filter(None, variables)) |
| 129 | return variables |
| 130 | |
| 131 | |
| 132 | def get_inherits(tree): |
no test coverage detected