dramatiq
dramatiq copied to clipboard
WIP: adds types for user facing API
Related #305
Here's how it works:
from dramatiq import actor
@actor
def test(arg: int) -> str:
return str(arg)
reveal_type(test)
reveal_type(test(1))
Output:
ยป mypy ex.py
ex.py:7: note: Revealed type is 'dramatiq.actor.Actor[def (arg: builtins.int) -> builtins.str]'
ex.py:8: note: Revealed type is 'builtins.str'
@Bogdanp let's decide what "public API" is. Because project has lots of files and classes / methods. I would be very grateful if you can help me in this field.
I use # noqa: B950
because otherwise when I add new lines inside function definition python3.5
raises parsing errors. I don't know why.
Self notes: I need to parametrize Message
as Generic
on its result. And get_result()
method will return the generic type.
This also means, that we need to somehow parametrize the result backend.
@Bogdanp let's decide what "public API" is.
I would say anything that is documented in the Reference is part of the public API.
Hi, @Bogdanp! I don't have any more time to work on this.
What is going to be the future of this PR? Looks like it is a good start.
I don't really have the time to carry it over either, but I'll happily make any necessary final adjustments and merge it if someone picks it up and finishes it.
I'd be happy to take over it. However, since dramatic doesn't support Python 2 anymore, no need to use stubs. Would you mind having type annotations right in the code? That's much easier to maintain than a bunch of duplicated signatures in separate stub files.
UPD: now I see, stubs were used only for __init__.py
. Interesting. I miss the historical context here, but I'm pretty sure it's not needed anymore.
I'd be happy to take over it. However, since dramatic doesn't support Python 2 anymore, no need to use stubs. Would you mind having type annotations right in the code? That's much easier to maintain than a bunch of duplicated signatures in separate stub files.
UPD: now I see, stubs were used only for
__init__.py
. Interesting. I miss the historical context here, but I'm pretty sure it's not needed anymore.
Feel free to pick it up! I have no opinion on the stubs and, if they're no longer necessary, then you should feel free to get rid of them.
Thank you :) Since I work at Sendcloud, I'm sure I can get some time to work on dramatiq. I'll pick it up in one of the upcoming sprints ๐๐ฟ
@orsinium thanks! ๐
I believe this is covered by @orsinium 's recent changes so I'm going to go ahead and close this. Thank you both!
@orsinium thank you for taking this over! Great work!