Skip to content

Commit

Permalink
fix: Mypy typing fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ramedina86 committed Sep 30, 2024
1 parent 3237d8a commit 9f26fba
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/writer/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ def execute(self, args: dict):

class MiddlewareRegistry:

def __init__(self):
def __init__(self) -> None:
self.registry: List[MiddlewareExecutor] = []

def register(self, middleware: Callable):
Expand Down Expand Up @@ -1705,7 +1705,7 @@ def fn(payload, context, session):
writer.workflows.run_workflow_by_key(self.session, workflow_key, execution_env)
return fn

def _get_handler_callable(self, handler: str) -> Callable:
def _get_handler_callable(self, handler: str) -> Optional[Callable]:
if handler.startswith("$runWorkflow_"):
workflow_key = handler[13:]
return self._get_workflow_callable(workflow_key)
Expand Down
8 changes: 4 additions & 4 deletions src/writer/workflows.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict
from typing import Dict, List, Tuple
import writer.workflows_blocks
from writer.core_ui import Component
import writer.core
Expand All @@ -20,9 +20,9 @@ def run_workflow_by_key(session, workflow_key: str, execution_env: Dict):
state.add_log_entry("info", "Workflow", f"""Finished executing workflow "{workflow_key}".""")


def run_workflow(session, component_id: "Component", execution_env: Dict):
def run_workflow(session, component_id: str, execution_env: Dict):
final_nodes = _get_final_nodes(component_id)
execution = {}
execution: Dict = {}
for node in final_nodes:
_run_node(node, execution, session, execution_env)

Expand All @@ -36,7 +36,7 @@ def _get_final_nodes(component_id):
return final_nodes

def _get_dependencies(target_node: "Component"):
dependencies = []
dependencies:List[Tuple] = []
parent_id = target_node.parentId
if not parent_id:
return dependencies
Expand Down
3 changes: 2 additions & 1 deletion src/writer/workflows_blocks/blocks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Dict
from writer.ss_types import InstancePath
import writer.workflows_blocks
import writer.core
import writer.core_ui
Expand All @@ -19,7 +20,7 @@ def __init__(self, component: "writer.core_ui.Component", execution: Dict, sessi
self.execution_env = execution_env
self.result = None
self.evaluator = writer.core.Evaluator(session.session_state, session.session_component_tree)
self.instance_path = [{"componentId": self.component.id, "instanceNumber": 0}]
self.instance_path: InstancePath = [{"componentId": self.component.id, "instanceNumber": 0}]

def _get_field(self, field_key: str, as_json=False):
v = self.evaluator.evaluate_field(self.instance_path, field_key, base_context=self.execution_env, as_json=as_json)
Expand Down

0 comments on commit 9f26fba

Please sign in to comment.