Miksus / rocketry

Modern scheduling library for Python
https://rocketry.readthedocs.io
MIT License
3.23k stars 105 forks source link

Add Annotated supporting #208

Open Lancetnik opened 1 year ago

Lancetnik commented 1 year ago

FastAPI and Pydantic supports a new feature: Annotated, but rocketry still doesn't. It's a pretty usefull to declare some application-level Arguments and use it everywhere.

Code without Annotated:

arg = SimpleArg(1)

@app.task("...")
def func(dep: int = arg):
    ...

@app.task("...")
def func2(dep: int = arg):
    ...

Code with Annotated

from typing_extensions import Annotated

arg = SimpleArg(1)

ArgDep = Annotated[int, arg]

@app.task("...")
def func(dep: ArgDep):
    ...

@app.task("...")
def func2(dep: ArgDep):
    ...

I suppose, all packages, based on function signature, should implement this feature too. So, I am here to make it.

Lancetnik commented 1 year ago

@Miksus, please take a look here! I want to get some feedback that the project is alive and still developing in order to use it further.