Activity method signature arguments type and correctness checking in python-sdk

Hi. When we want to call activity we must call them sth like this:

await workflow.execute_activity(
            method_name,
            args=[arg1, arg2, arg3],
        )

In this way IDEs and static type analysers cannot match method’s signature with it’s invocations and it’s common to misuse methods and refactoring method’s signature becomes very hard.
Have you any suggestion for this situation? (IDE config, Static Analysis tools config, Overriding @workflow.defn decorator, Use another sdk’s apis, …)

The Python SDK was built for the strongest typing possible. However, the MyPy implementations of ParamSpec and others leave a bit to be desired on multi-parameter situations. If you look at the overloads of execute_activity you’ll see that execute_activity is typed for no-parameter and single-parameter activities as callable function references. Temporal strongly recommends you only use a single parameter (e.g. a data class) that you can add fields to safely in the future.

If you use MyPy and you don’t use multi-parameter activites/workflows, your code will be well typed. Simply call execute_activity(my_activity_function, my_arg) and if my_arg is not the right type, your type checker will fail (and your IDE will warn too for most IDEs). The return type will be properly typed too. But if you use strings activity names and multi-argument activities you are opting out of typing.

See the README section on invoking activities and defining activities