temporalio / sdk-python

Temporal Python SDK
MIT License
474 stars 77 forks source link

[Feature Request] Make start_update/execute_update work with vscode/pyright and add pyright to CI #420

Closed cretz closed 3 months ago

cretz commented 1 year ago

Describe the solution you'd like

Right now vscode/pylance/pyright fails with: image

I think we probably just need to remove the typing for multi-param update (use Sequence[Any] like signal/query). Then we need to add https://github.com/microsoft/pyright to CI alongside MyPy if it's not too difficult.

cretz commented 1 year ago

Also note that the return type for execute_update and similar is not properly inferred from the method in Pyright like it is in MyPy

dandavison commented 9 months ago

Another example:

samples-python(main) .venv/bin/pyright --pythonpath .venv/bin/python hello/hello_activity.py
/Users/dan/src/temporalio/samples-python/hello/hello_activity.py
  /Users/dan/src/temporalio/samples-python/hello/hello_activity.py:58:24 - error: No overloads for "execute_workflow" match the provided arguments (reportCallIssue)
  /Users/dan/src/temporalio/samples-python/hello/hello_activity.py:59:13 - error: Argument of type "(self: GreetingWorkflow, name: str) -> Coroutine[Any, Any, str]" cannot be assigned to parameter "workflow" of type "str" in function "execute_workflow"
    "function" is incompatible with "str" (reportArgumentType)
2 errors, 0 warnings, 0 informations
samples-python(main) .venv/bin/pyright --version
pyright 1.1.350
samples-python(main) .venv/bin/python --version
Python 3.10.13
cretz commented 9 months ago

So #471 probably fixed this error, but leaving this open because we still want pyright in CI