Skip to content

Commit

Permalink
type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
pomponchik committed Jan 7, 2024
1 parent 5a40916 commit 087b2e0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions astrologic/decorators/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def get_globals_by_function(self, function: Callable[..., Any]) -> Dict[str, Any
module = importlib.import_module(module_name)
except ModuleNotFoundError:
return {}

result = {}
for object_name in dir(module):
_object = getattr(module, object_name)
Expand Down
8 changes: 5 additions & 3 deletions astrologic/decorators/inline.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,22 @@ def change_tree(self, tree, original_function, function_text, *functions, **kwar
all_original_names: Set[str] = self.get_all_names(tree)

class VisiterCalls(ast.NodeTransformer):
def visit_Expr(_self, node):
def visit_Expr(_self, node: ast.Expr) -> Optional[Union[ast.AST, List[ast.AST]]]:
try:
value = node.value
_node = node

if isinstance(value, ast.Call):
node = value
if node.func.id in functions:
function_name = node.func.id
if node.func.id in functions: # type: ignore[attr-defined]
function_name = node.func.id # type: ignore[attr-defined]
function_tree = self.get_function_tree(function_name, original_function.__module__)
new_block, declarations = self.replace_names(all_original_names, function_tree, node)
new_block = new_block.body[0].body
return declarations + new_block
else:
return _node

except Exception:
return node

Expand Down

0 comments on commit 087b2e0

Please sign in to comment.