sdk-python
sdk-python copied to clipboard
Fixing indent issue with kwargs["extra"]
What was changed
Fixing the indent the setting of kwargs["extra"] in the process method.
Why?
When you set workflow.logger.workflow_info_on_extra = False it caused the Workflow to fail with the error
File "/Users/masonegger/Code/Temporal/edu-102-python-code/venv/lib/python3.13/site-packages/temporalio/worker/_workflow_instance.py", line 391, in activate
self._run_once(check_conditions=index == 1 or index == 2)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/masonegger/Code/Temporal/edu-102-python-code/venv/lib/python3.13/site-packages/temporalio/worker/_workflow_instance.py", line 1857, in _run_once
raise self._current_activation_error
File "/Users/masonegger/Code/Temporal/edu-102-python-code/venv/lib/python3.13/site-packages/temporalio/worker/_workflow_instance.py", line 1875, in _run_top_level_workflow_function
await coro
File "/Users/masonegger/Code/Temporal/edu-102-python-code/venv/lib/python3.13/site-packages/temporalio/worker/_workflow_instance.py", line 872, in run_workflow
result = await self._inbound.execute_workflow(input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/masonegger/Code/Temporal/edu-102-python-code/venv/lib/python3.13/site-packages/temporalio/worker/_workflow_instance.py", line 2256, in execute_workflow
return await input.run_fn(*args)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/masonegger/Code/Temporal/edu-102-python-code/exercises/durable-execution/solution/workflow.py", line 24, in run
workflow.logger.info(f"TranslationWorkflow invoked with")
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/logging/__init__.py", line 1906, in info
self.log(INFO, msg, *args, **kwargs)
~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/logging/__init__.py", line 1943, in log
msg, kwargs = self.process(msg, kwargs)
~~~~~~~~~~~~^^^^^^^^^^^^^
File "/Users/masonegger/Code/Temporal/edu-102-python-code/venv/lib/python3.13/site-packages/temporalio/workflow.py", line 1364, in process
kwargs["extra"] = {**extra, **(kwargs.get("extra") or {})}
^^^^^
This was an error in https://github.com/temporalio/sdk-python/pull/664. We should configure linter / type-checker in CI to catch this (and we should ideally have coverage showing that the branch wasn't tested). Pyright catches it (reportPossiblyUnboundVariable, but VSCode must be set to strict for this to be enabled).
Extended tests so that they'll fail without this fix.