Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Improve comments in opentracing
Browse files Browse the repository at this point in the history
I tried to workaround the ignores but found it too much trouble.

I think the corresponding issue is
python/mypy#12909. The mypy repo has a PR
claiming to fix this (python/mypy#14677) which
might mean this gets resolved soon?
  • Loading branch information
David Robertson committed Feb 16, 2023
1 parent 029cfaf commit 14db7d4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions synapse/logging/opentracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -894,10 +894,14 @@ def _wrapping_logic(func: Callable[P, R], *args: P.args, **kwargs: P.kwargs) ->
"""

if inspect.iscoroutinefunction(func):

# In this branch, R = Awaitable[RInner], for some other type RInner
@wraps(func)
async def _wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
async def _wrapper(
*args: P.args, **kwargs: P.kwargs
) -> Any: # Return type is RInner
with wrapping_logic(func, *args, **kwargs):
# type-ignore: func() returns R, but mypy doesn't know that R is
# Awaitable here.
return await func(*args, **kwargs) # type: ignore[misc]

else:
Expand Down Expand Up @@ -965,6 +969,7 @@ def _decorator(func: Callable[P, R]) -> Callable[P, R]:
return func

# type-ignore: mypy seems to be confused by the ParamSpecs here.
# I think the problem is /~https://github.com/python/mypy/issues/12909
return _custom_sync_async_decorator(
func, _wrapping_logic # type: ignore[arg-type]
)
Expand Down Expand Up @@ -1014,6 +1019,7 @@ def _wrapping_logic(
yield

# type-ignore: mypy seems to be confused by the ParamSpecs here.
# I think the problem is /~https://github.com/python/mypy/issues/12909
return _custom_sync_async_decorator(func, _wrapping_logic) # type: ignore[arg-type]


Expand Down

0 comments on commit 14db7d4

Please sign in to comment.