You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Python community typically likes OOP (object-oriented programming), so a class-based approach is more ergonomic for them. Our Python SDK currently currently only supports Inngest function definition with a function decorator, but users have expressed that they’re prefer a class.
We’ve also faced some type annotation challenges with our decorator approach.
Solution
Replace our decorator (@inngest_client.create_function) to with a base class. For example, if we currently have the following function:
Ideally, we continue supporting the decorator approach for a while to minimize disruption for users.
Other use cases
"Stepify" class methods
Class have a benefit of clearly organizing methods. This can be a great place to collect step methods, so we'll add decorator that will "stepify" a normal class method, effectively wrapping it with step.run:
Using a class allows us to access locally-scoped types outside of the local scope. For example, the following example shows that Input is accessible outside of the factory function even though it's defined within factory:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Problem
The Python community typically likes OOP (object-oriented programming), so a class-based approach is more ergonomic for them. Our Python SDK currently currently only supports Inngest function definition with a function decorator, but users have expressed that they’re prefer a class.
We’ve also faced some type annotation challenges with our decorator approach.
Solution
Replace our decorator (
@inngest_client.create_function) to with a base class. For example, if we currently have the following function:Then then we’d replace it with:
Ideally, we continue supporting the decorator approach for a while to minimize disruption for users.
Other use cases
"Stepify" class methods
Class have a benefit of clearly organizing methods. This can be a great place to collect step methods, so we'll add decorator that will "stepify" a normal class method, effectively wrapping it with
step.run:Generic input and output
The
Functionclass has 2 optional generic params: input type (i.e. event schema) and output type.Using a class allows us to access locally-scoped types outside of the local scope. For example, the following example shows that
Inputis accessible outside of thefactoryfunction even though it's defined withinfactory:Using a class
But if we use a decorator, we can't access the type annotations outside of
factory:Using a decorator
All reactions