python-trio / trio-typing

Type hints for Trio and related projects
Other
27 stars 16 forks source link

Fix `open_signal_receiver` misannotation #68

Closed gschaffner closed 1 year ago

gschaffner commented 1 year ago

Hi!

I believe open_signal_receiver's return type is misannotated. For example:

import signal
from typing import reveal_type

import trio

async def main() -> None:
    with trio.open_signal_receiver(signal.SIGINT, signal.SIGTERM) as signal_receiver:
        async for signum in signal_receiver:
            reveal_type(signum)  # int at runtime, but signal.Signals during type checking!
            print(signum.name)  # passes type checking, but AttributeError at runtime.
            raise SystemExit(1)

if __name__ == "__main__":
    trio.run(main)
trio-bot[bot] commented 1 year ago

Hey @gschaffner, it looks like that was the first time we merged one of your PRs! Thanks so much! :tada: :birthday:

If you want to keep contributing, we'd love to have you. So, I just sent you an invitation to join the python-trio organization on Github! If you accept, then here's what will happen:

If you want to read more, here's the relevant section in our contributing guide.

Alternatively, you're free to decline or ignore the invitation. You'll still be able to contribute as much or as little as you like, and I won't hassle you about joining again. But if you ever change your mind, just let us know and we'll send another invitation. We'd love to have you, but more importantly we want you to do whatever's best for you.

If you have any questions, well... I am just a humble Python script, so I probably can't help. But please do post a comment here, or in our chat, or on our forum, whatever's easiest, and someone will help you out!

VincentVanlaer commented 1 year ago

Thanks!