Type definition for @serverless_function seems wrong
How do you use Sentry?
Sentry Saas (sentry.io)
Version
1.9.10
Steps to Reproduce
Annotating a function with @serverless_function, eg:
@serverless_function
def main(msg: func.QueueMessage) -> None:
...
This gives a type signature of main: ((msg: QueueMessage) -> None) | (((msg: QueueMessage) -> None) -> ((msg: QueueMessage) -> None)). I cant quite fathom why this is like this. Looking at https://github.com/getsentry/sentry-python/blame/master/sentry_sdk/integrations/serverless.py#L42, the type signature is declared as:
# type: (Optional[F], bool) -> Union[F, Callable[[F], F]]
If I remove the decorator, then the type signature is simply main: (msg: QueueMessage) -> None) which is what I would expect the decorated function to also return.
Can you explain why the decorator type definition cannot just simply return the type of the wrapped function?, as per:
# type: (Optional[F], bool) -> F
Expected Result
pylance does not mark all my annotated handlers in a sea of type errors
Actual Result
pylance marks all my code in a sea of type errors
there's a couple of @overload's above that definition, so this should work out correctly?
If Optional[F] is None, we can't have the return type to be F, it's the other Callable thingy.
This issue has gone three weeks without activity. In another week, I will close it.
But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!
"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀