dramatiq icon indicating copy to clipboard operation
dramatiq copied to clipboard

WIP: adds types for user facing API

Open sobolevn opened this issue 4 years ago โ€ข 10 comments

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'

sobolevn avatar Apr 12 '20 15:04 sobolevn

@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.

sobolevn avatar Apr 14 '20 11:04 sobolevn

I use # noqa: B950 because otherwise when I add new lines inside function definition python3.5 raises parsing errors. I don't know why.

sobolevn avatar Apr 14 '20 13:04 sobolevn

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.

sobolevn avatar Apr 14 '20 16:04 sobolevn

@Bogdanp let's decide what "public API" is.

I would say anything that is documented in the Reference is part of the public API.

Bogdanp avatar Apr 15 '20 12:04 Bogdanp

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.

sobolevn avatar Sep 08 '20 11:09 sobolevn

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.

Bogdanp avatar Sep 10 '20 08:09 Bogdanp

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.

orsinium avatar Sep 16 '22 07:09 orsinium

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.

Bogdanp avatar Sep 16 '22 10:09 Bogdanp

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 avatar Sep 16 '22 11:09 orsinium

@orsinium thanks! ๐Ÿ‘

sobolevn avatar Sep 16 '22 16:09 sobolevn

I believe this is covered by @orsinium 's recent changes so I'm going to go ahead and close this. Thank you both!

Bogdanp avatar Mar 27 '23 06:03 Bogdanp

@orsinium thank you for taking this over! Great work!

sobolevn avatar Mar 27 '23 07:03 sobolevn