Skip to content

Extend WorkflowParser to handle imports #159

@liamhuber

Description

@liamhuber

@samwaseda moved in an excellent direction in #158. Since WorkflowParser is also an ast.NodeVisitor, we can pull a similar trick there. For conditional branches, we'll need to make a copy of the scope: ScopeProxy so that imports inside conditional branches aren't made available outside that branch, but I think it should all be pretty straightforward.

The goal is that we can parse nodes like

from flowrep.models.parsers import workflow_parser

@workflow_parser.workflow
def my_sneaky_wf(func):
    import inspect
    
    src = inspect.getsource(func)
    return src

Instead of requiring that the import be outside the workflow definition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions