Closed
Description
How do you use Sentry?
Sentry Saas (sentry.io)
Version
1.44.1
Steps to Reproduce
- Create two simple synchronous functions that returns a type, where one is decorated and the second calls the first:
from sentry_sdk.crons.decorator import monitor
@monitor(monitor_slug="test")
def foo() -> int:
return 1
def bar() -> int:
return foo()
- Run mypy on both and see if the behavior is the same in v1.44.0 and v1.44.1
Expected Result
The functions are synchronous and there is no type failure in v1.44.1.
Actual Result
When testing upgrading to 1.44.1, we got a type failure from mypy that was not there using the 1.44.0 sdk version. Our function returns a dictionary, not an int
, but the essentials are the same as above.
We see
Incompatible return value type (got "dict[str, list[dict[str, Any]]] | Awaitable[dict[str, list[dict[str, Any]]]]", expected "dict[str, list[dict[str, Any]]]") [return-value]
But since our function is synchronous, mypy should not be confused by the Awaitable
. I think this is ultimately due to inspect.iscoroutinefunction
being a runtime check that mypy does not use for type elimination.
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
No status